Why are there 2 containers in a pod in Kubernetes?

9/10/2019

I am deploying a simple application in Kubernetes in GKE. Deployment yaml file is given below. I initialized the pod using kubectl apply -f [name of the yaml file].

When I deploy, by default the pod is having 2 containers. Why is that?

kind: Deployment
metadata:
  name: springboot-app
  labels:
    app: springboot-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: springboot-app
  template:
    metadata:
      labels:
        app: springboot-app
    spec:
      containers:
      - name: springboot-app
        image: anushiya/app:latest
        resources:
            limits:
                cpu: "1"
            requests:
                cpu: "0.5"
        ports:
        - containerPort: 9000

EDIT:

When I run the following command

kubectl get pod -n default springboot-app-f54d8459d-7ngrw -o jsonpath='{.metadata.uid}'

I get this as my output

190b2fae-d2d1-11e9-a58a-42010a8000c0

-- anushiya-thevapalan
containers
kubernetes

0 Answers