<p>I am currently having a problem with a deployment and can't figure out the problem at this time. The problem is that the endpoints of a service are not automatically bound and the selector labels match.</p>
<p><strong>A few words about the setup:</strong></p>
<ul>
<li>Host OS: Debian 10</li>
<li>Kubernetes version: 1.21</li>
<li>Ingress controller: Nginx</li>
<li>Firewall on the hosts of the nodes (allow list)</li>
</ul>
<p>Furthermore, in my K8s cluster, some successful Ingress routes (different namespace) and the associated automatic endpoint assignment are already successful, so I conclude that there can't be a problem with my basic setup. In addition, I can manually enter the appropriate IP address of the pod into the endpoint and subsequently the function is guaranteed.</p>
<p><strong>Now my deployment setup:</strong></p>
<ul>
<li>Tool: Helm</li>
</ul>
<p><strong>Deployment helm chart:</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: &quot;{{ .Values.basic.name }}-de&quot;
  namespace: &quot;{{ .Values.basic.namespace }}&quot;
  labels:
    app.kubernetes.io/name: &quot;{{ .Values.basic.name }}&quot;
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: &quot;{{ .Values.basic.name }}&quot;
  template:
    metadata:
      labels:
        app.kubernetes.io/name: &quot;{{ .Values.basic.name }}&quot;
    spec:
      containers:
        - name: &quot;{{ .Values.basic.database.name }}&quot;
          image: &quot;{{ .Values.docker.database.image }}:{{ .Values.docker.database.tag }}&quot;
          resources:
            requests:
              memory: &quot;64Mi&quot;
              cpu: &quot;250m&quot;
            limits:
              memory: &quot;128Mi&quot;
              cpu: &quot;500m&quot;
          securityContext:
            runAsUser: 500
          env:
            - name: LOGGING_REDIS_HOST
              value: &quot;144.91.86.56&quot;
            - name: LOGGING_REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: &quot;{{ .Values.basic.database.name }}-sc&quot;
                  key: LOGGING_REDIS_PASSWORD
            - name: POSTGRES_INITDB_NAME
              value: &quot;{{ .Values.config.database.POSTGRES_INITDB_NAME }}&quot;
            - name: POSTGRES_INITDB_ROOT_USERNAME
              value: &quot;{{ .Values.config.database.POSTGRES_INITDB_ROOT_USERNAME }}&quot;
            - name: POSTGRES_INITDB_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: &quot;{{ .Values.basic.database.name }}-sc&quot;
                  key: POSTGRES_INITDB_ROOT_PASSWORD
            - name: POSTGRES_INITDB_MONITORING_USERNAME
              value: &quot;{{ .Values.config.database.POSTGRES_INITDB_MONITORING_USERNAME }}&quot;
            - name: POSTGRES_INITDB_MONITORING_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: &quot;{{ .Values.basic.database.name }}-sc&quot;
                  key: POSTGRES_INITDB_MONITORING_PASSWORD
            - name: POSTGRES_INITDB_USER_USERNAME
              value: &quot;{{ .Values.config.database.POSTGRES_INITDB_USER_USERNAME }}&quot;
            - name: POSTGRES_INITDB_USER_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: &quot;{{ .Values.basic.database.name }}-sc&quot;
                  key: POSTGRES_INITDB_USER_PASSWORD
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /storage
              name: &quot;{{ .Values.basic.database.name }}-storage&quot;
              readOnly: false
        - name: &quot;{{ .Values.basic.app.name }}&quot;
          image: &quot;{{ .Values.docker.app.image }}:{{ .Values.docker.app.tag }}&quot;
          resources:
            requests:
              memory: &quot;1024Mi&quot;
              cpu: &quot;250m&quot;
            limits:
              memory: &quot;2048Mi&quot;
              cpu: &quot;500m&quot;
          securityContext:
            runAsUser: 500
          env:
            - name: LOGGING_REDIS_HOST
              value: &quot;144.91.86.56&quot;
            - name: LOGGING_REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: &quot;{{ .Values.basic.app.name }}-sc&quot;
                  key: LOGGING_REDIS_PASSWORD
            - name: JDBC_USER
              value: &quot;{{ .Values.config.database.POSTGRES_INITDB_USER_USERNAME }}&quot;
            - name: JDBC_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: &quot;{{ .Values.basic.app.name }}-sc&quot;
                  key: JDBC_PASSWORD
            - name: JDBC_URL
              value: &quot;{{ .Values.config.app.JDBC_URL }}&quot;
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /storage
              name: &quot;{{ .Values.basic.app.name }}-storage&quot;
              readOnly: false
      imagePullSecrets:
        - name: &quot;docker-registry-{{ .Values.basic.namespace }}-sc&quot;
      volumes:
        - name: &quot;{{ .Values.basic.database.name }}-storage&quot;
          persistentVolumeClaim:
            claimName: &quot;gluster-{{ .Values.basic.database.name }}-{{ .Values.basic.namespace }}-pvc&quot;
        - name: &quot;{{ .Values.basic.app.name }}-storage&quot;
          persistentVolumeClaim:
            claimName: &quot;gluster-{{ .Values.basic.app.name }}-{{ .Values.basic.namespace }}-pvc&quot;
      securityContext:
        fsGroup: 500
</code></pre>
<p><strong>Service helm chart:</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: &quot;{{ .Values.basic.name }}-sv&quot;
  namespace: &quot;{{ .Values.basic.namespace }}&quot;
  labels:
    app.kubernetes.io/name: &quot;{{ .Values.basic.name }}&quot;
spec:
  type: ClusterIP
  ports:
    - port: 9187
      targetPort: http
      protocol: TCP
      name: metrics
    - port: 9000
      targetPort: http
      protocol: TCP
      name: http
  selector:
    app.kubernetes.io/name: &quot;{{ .Values.basic.name }}&quot;
</code></pre>
<p><strong>Now the output of my K8s cluster:</strong></p>
<pre><code>kubectl get pods -l app.kubernetes.io/name=sonarqube -n development
NAME                           READY   STATUS    RESTARTS   AGE
sonarqube-de-b47bd9f75-tsbxc   2/2     Running   0          2d11h

kubectl get endpoints sonarqube-sv -n development
NAME           ENDPOINTS   AGE
sonarqube-sv   &lt;none&gt;      3d10h

kubectl get pods -l app.kubernetes.io/name=sonarqube -n development --show-labels
NAME                           READY   STATUS    RESTARTS   AGE     LABELS
sonarqube-de-b47bd9f75-tsbxc   2/2     Running   0          3d11h   app.kubernetes.io/name=sonarqube,pod-template-hash=b47bd9f75

kubectl get endpointslices  -n development --show-labels
NAME                       ADDRESSTYPE   PORTS     ENDPOINTS        AGE     LABELS
sonarqube-sv-fgsg2         IPv4          &lt;unset&gt;   192.168.202.213  3d11h   endpointslice.kubernetes.io/managed-by=endpointslice-controller.k8s.io,kubernetes.io/service-name=sonarqube-sv

kubectl get deployment sonarqube-de -n development --show-labels
NAME           READY   UP-TO-DATE   AVAILABLE   AGE     LABELS
sonarqube-de   1/1     1            1           4d10h   app.kubernetes.io/managed-by=Helm,app.kubernetes.io/name=sonarqube
</code></pre>
<p>Can you all help me to solve this problem?</p>

ZPascal
<p>I've solved the problem by removing of the <code>targetPort: http</code> inside the service helm YAML.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: &quot;{{ .Values.basic.name }}-sv&quot;
  namespace: &quot;{{ .Values.basic.namespace }}&quot;
  labels:
    app.kubernetes.io/name: &quot;{{ .Values.basic.name }}&quot;
spec:
  type: ClusterIP
  ports:
    - port: 9187
      protocol: TCP
      name: metrics
    - port: 9000
      protocol: TCP
      name: http
  selector:
    app.kubernetes.io/name: &quot;{{ .Values.basic.name }}&quot;
</code></pre>
