<p>I am trying to deploy the container using yaml.
The POD is getting created but service is not getting mapped to POD. What I am missing here?</p>
<p>Be informed I am using trial subscription on Google Cloud and kubernetes-SDK on my machine.</p>
<p><strong>Deployment file</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: udemydocker1
  name: udemydocker
  namespace: default
spec:
  progressDeadlineSeconds: 30
  replicas: 1
  selector:
    matchLabels:
      app: udemydocker1
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: udemydocker1
    spec:
      containers:
      - image: lazyav/udemydocker:Release.1.0.0
        imagePullPolicy: Always
        name: udemydocker
      restartPolicy: Always
      
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: udemydocker1
  name: udemydocker
  namespace: default
spec:
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: udemydocker
  sessionAffinity: None
  type: LoadBalancer

</code></pre>
<p><strong>Dashboard screen shot and command line commands</strong></p>
<p><a href="https://i.stack.imgur.com/2JnWt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2JnWt.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/PJPNP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PJPNP.png" alt="enter image description here" /></a></p>

Abhishek Vyas
<p>The above issue is due to selector <strong>app: udemydocker</strong>. The service was unable to find the POD.
Changing it to <strong>app=udemydocker1</strong> solves the problem</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: udemydocker1
  name: udemydocker
  namespace: default
spec:
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: udemydocker1
  sessionAffinity: None
  type: LoadBalancer
</code></pre>
