<p>im trying to access a deloyment on our Kubernetes cluster on Azure. This is a Azure Kubernetes Service (AKS). Here are the configuration files for the deployment and the service that should expose the deployment.</p>

<h2>Configurations</h2>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mira-api-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mira-api
  template:
    metadata:
      labels:
        app: mira-api
    spec:
      containers:
        - name: backend
          image: registry.gitlab.com/izit/mira-backend
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
      imagePullSecrets:
        - name: regcred
</code></pre>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mira-api-service
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 8080
      protocol: TCP
      name: http
  selector:
    run: mira-api
</code></pre>

<p>When I check the cluster after applying these configurations I, I see the pod running correctly. Also the service is created and has public IP assigned.</p>

<p><a href="https://i.stack.imgur.com/Pvk3U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pvk3U.png" alt="Services shown after applying configuration"></a></p>

<p>After this deployment I don't see any requests getting handled. I get a error message in my browser saying the site is inaccessible. Any ideas what I could have configured wrong? </p>

<p>Your service selector labels and pod labels do not match.</p>

<p>You have <code>app: mira-api</code> label in deployment's pod template but have <code>run: mira-api</code> in service's label selector. </p>

<p>Change your service selector label to match the pod label as follows.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mira-api-service
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 8080
      protocol: TCP
      name: http
  selector:
    app: mira-api
</code></pre>

<p>To make sure your service is selecting the backend pods or not, you can run <code>kubectl describe svc &lt;svc name&gt;</code> command and check if it has any <code>Endpoints</code> listed.</p>

<pre><code># kubectl describe svc postgres
Name:              postgres
Namespace:         default
Labels:            app=postgres
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"postgres"},"name":"postgres","namespace":"default"},"s...
Selector:          app=postgres
Type:              ClusterIP
IP:                10.106.7.183
Port:              default  5432/TCP
TargetPort:        5432/TCP
Endpoints:         10.244.2.117:5432    &lt;------- This line
Session Affinity:  None
Events:            &lt;none&gt;
</code></pre>
