Score:0

Kubernetes cluster external connection

gg flag

I have 2 services (1 -- httpd + php, 2 -- go gin). They have same configuration. The problem is that I can connect externally only to one of these, while the second one throws error, but if I connect from within cluster, all is ok. I deploy them through helm using 1 base chart for each.

IPs

192.168.49.1 -- abc. port: 9999 192.168.49.2 -- my-k8s-app. port: 80

Error

curl: (7) Failed to connect to 192.168.49.1 port 9999 after 0 ms: Couldn't connect to server

Values.yaml

abc:
  image: regretto/gateway:latest
  port: 9999
  service:
    type: LoadBalancer
    externalPort: 9999

my-k8s-app:
  image: regretto/myk8sapp:latest
  port: 80
  service:
    type: LoadBalancer
    externalPort: 8080

service.yml

apiVersion: v1
kind: Service
metadata:
  name: "{{ .Chart.Name | lower | replace "_" "-"}}"
  labels:
    proj: "{{ .Release.Name }}"
    slave_microservice: "{{ .Chart.Name | lower | replace "_" "-" }}"
spec:
  type: {{default "ClusterIP" .Values.service.type}}
  ports:
    - port: {{ .Values.port }}
      NodePort: {{ default .Values.port .Values.service.externalPort }}
      protocol: {{default "TCP" .Values.service.protocol}}
  selector:
    app: {{.Chart.Name | lower | replace "_" "-"}}

deployment.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: "{{ .Chart.Name | lower | replace "_" "-"}}"
  labels:
    proj: "{{ .Release.Name | lower}}"
    app: {{ .Chart.Name | lower | replace "_" "-" }}
spec:
  replicas: {{ .Values.hpa.minReplicas }}
  selector:
    matchLabels:
      proj: "{{ .Release.Name | lower}}"
  template:
    metadata:
      labels:
        proj: "{{ .Release.Name | lower }}"
        app: "{{ .Chart.Name | lower | replace "_" "-"}}"
    spec:
      containers:
        - name: {{ .Chart.Name | lower | replace "_" "-"}}
          image: {{ tpl .Values.image . }}
          imagePullPolicy: {{ default "Always" .Values.pull_policy }}
          ports:
            - containerPort: {{ .Values.port }}
          args: {{ toYaml .Values.args | nindent 12}}
drookie avatar
za flag
The main issue of this question it a total lack of any disgnostics. I.e. like `kubectl get services -o wide`, but not only it. Did you try to like.... investigate ?
Score:0
ms flag

It looks that you are creating LoadBalancer type of services. In that case the kubectl get services -n <your namespace>should also give you a value in the EXTERNAL-IP field. You should use that to access your service from the outside.

Could you provide the result of the kubectl get svc,ep -n <your namespace> command?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.