<p>I am new to Kubernetes.</p>
<p>Following is the yaml I am running:</p>
<pre><code>---
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: k8-demo-aishwarya
    app.kubernetes.io/version: version1
  name: k8-demo-aishwarya
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
  selector:
    app.kubernetes.io/name: k8-demo-aishwarya
    app.kubernetes.io/version: version1
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: k8-demo-aishwarya
    app.kubernetes.io/version: version1
  name: k8-demo-aishwarya
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: k8-demo-aishwarya
      app.kubernetes.io/version: version1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: k8-demo-aishwarya
        app.kubernetes.io/version: version1
    spec:
      containers:
      - env:
        - name: KUBERNETES_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: docker.io/aishvaryaps/spring-boot-on-kubernetes-example:0.12-SNAPSHOT
        imagePullPolicy: IfNotPresent
        name: k8-demo-aishwarya
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
</code></pre>
<hr />
<p>Getting a crashloopbackoff error</p>
<p>Can anyone guide me?</p>
<p>No issue with the image, it runs properly, I have tested that on Docker.</p>
<p><strong>Kubernetes pod logs are as follows</strong>:</p>
<pre><code>1. Successfully assigned default/k8-demo-aishwarya-fdd8d58c6-lvxp9 to gke-cluster-3-pool-1-997819b9-j3b2
2. Container image &quot;docker.io/aishvaryaps/spring-boot-on-kubernetes-example:0.12-SNAPSHOT&quot; already present on machine
3. Created container k8-demo-aishwarya
4. Started container k8-demo-aishwarya
5. Back-off restarting failed container
</code></pre>

<p>The container is running and is printing the hello world message and exiting. See below the logs from container.</p>
<pre><code>$ docker ps -a
CONTAINER ID        IMAGE                                                         COMMAND                  CREATED             STATUS                      PORTS               NAMES
2b177abdbae1        aishvaryaps/spring-boot-on-kubernetes-example:0.12-SNAPSHOT   &quot;/bin/sh -c 'java ${…&quot;   12 seconds ago      Exited (0) 10 seconds ago                       dummy


$ docker logs -f 2b1
Hello World by Aishwarya S!
</code></pre>
<p>If you want to keep the container running, the process inside the container should continue to run. You might need to print the message from a while or for loop.</p>
