<p>I am facing an issue when trying to create a deployment on Google Cloud using a Kubernetes YAML file. I see that no pods are created when using a YAML file; however, if I use <code>kubectl create deployment...</code>, pods do get created.</p>

<p>My YAML file is as follows :</p>

<pre><code>#Deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
  generation: 1
  labels:
    app: hello-world
  name: hello-world
  namespace: default
  resourceVersion: "3691124"
spec:
  progressDeadlineSeconds: 600
  replicas: 3
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: hello-world
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - image: myrepo/hello-world:0.0.4.RELEASE
        imagePullPolicy: IfNotPresent
        name: hello-world
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
#Service
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hello-world
  name: hello-world
  namespace: default
  resourceVersion: "3691877"
spec:
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 32448
    port: 8080
    protocol: TCP
    targetPort: 8001
  selector:
    app: hello-world
  sessionAffinity: None
  type: LoadBalancer
</code></pre>

<p>This is what I see when I run <code>kubectl get all</code> :</p>

<pre><code>NAME                           TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)          AGE
service/hello-world            LoadBalancer   Some IP        Some IP 3     8001:32449/TCP    15m
service/kubernetes             ClusterIP      Some IP 2      &lt;none&gt;         444/TCP           12d
</code></pre>

<p>As you can see, the only resource that started was the service. I neither see any deployment nor see any pods being created.</p>

<p><strong>Note</strong> I have replaced the actual IP addresses with "Some IP" above for obvious reasons..</p>

<p><strong>Question:</strong> Why are no pods getting created when I use the YAML but pods get created when I use <code>kubectl create deployment</code> instead of using a YAML configuration file?</p>

Ping
<ol>
<li>You should use <code>---</code> in YAML, when you have multiple resources in a single file.</li>
<li>You have to set <code>apiVersion: apps/v1</code> in deployment.</li>
</ol>

<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
  generation: 1
  labels:
    app: hello-world
  name: hello-world
  namespace: default
  resourceVersion: "3691124"
spec:
  progressDeadlineSeconds: 600
  replicas: 3
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: hello-world
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - image: myrepo/hello-world:0.0.4.RELEASE
        imagePullPolicy: IfNotPresent
        name: hello-world
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hello-world
  name: hello-world
  namespace: default
  resourceVersion: "3691877"
spec:
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 32448
    port: 8080
    protocol: TCP
    targetPort: 8001
  selector:
    app: hello-world
  sessionAffinity: None
  type: LoadBalancer
</code></pre>

<p>Output</p>

<pre><code>$ kubectl get deply,po,svc
NAME                          READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/hello-world   0/3     3            0           5m34s

NAME                               READY   STATUS             RESTARTS   AGE

pod/hello-world-6bd8d58486-7lzh9   0/1     ImagePullBackOff   0          3m49s
pod/hello-world-6bd8d58486-m56rq   0/1     ImagePullBackOff   0          3m49s
pod/hello-world-6bd8d58486-z9xmz   0/1     ImagePullBackOff   0          3m49s

NAME                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE
service/hello-world   LoadBalancer   10.108.65.81     &lt;pending&gt;     8080:32448/TCP    3m49s
service/kubernetes    ClusterIP      10.96.0.1        &lt;none&gt;        443/TCP           9d
</code></pre>
