How to keep Sidecar alive with Kubernetes pod

10/3/2019

I've deployed a sidecar called debian-sidecar with nginx-service in one POD in Kubernetes farm My problem is the sidecar created then it terminated like the job completed

Name:               nginx-debug
Namespace:          devops
Priority:           0
PriorityClassName:  <none>
Node:               lab-kubernetes-node
Labels:             <none>
Annotations:        injector.tumblr.com/request=sidecar-debian
                    injector.tumblr.com/status=injected
                    kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1":{...}
Status:             Running
IP:                 xx.xxxx.xxxx.xx
Containers:
  nginx-debug:
    Container ID:   docker://bd903...
    Image:          nginx:latest
    Image ID:       docker-pullable://nginx@sha256:aeded...
    Port:           <none>
    Host Port:      <none>
    State:          ***Running***
      Started:      Thu, 03 Oct 2019 18:13:50 +0700
    Ready:          True
    Restart Count:  0
    Environment:
      HELLO:  world
      TEST:   test_that
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-m7jqs (ro)
  sidecar-debian:
    Container ID:   docker://c587bced...
    Image:          debian:latest
    Image ID:       docker-pullable://debian@sha256:e25b64a...
    Port:           <none>
    Host Port:      <none>
    State:          ***Terminated***
      Reason:       ***Completed***
      Exit Code:    0
      Started:      Thu, 03 Oct 2019 18:13:51 +0700
      Finished:     Thu, 03 Oct 2019 18:13:51 +0700
    Ready:          False
    Restart Count:  0
    Environment:
      ENV_IN_SIDECAR:  test-in-sidecar
      HELLO:           world
      TEST:            test_that
    Mounts:            <none>
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-m7jqs:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-m7jqs
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age   From                             Message
  ----    ------     ----  ----                             -------
  Normal  Scheduled  8m    default-scheduler                Successfully assigned devops/nginx-debug to lab-kubernetes-node-54
  Normal  Pulled     8m    kubelet, lab-kubernetes-node-54  Container image "nginx:latest" already present on machine
  Normal  Created    8m    kubelet, lab-kubernetes-node-54  Created container
  Normal  Started    8m    kubelet, lab-kubernetes-node-54  Started container
  Normal  Pulled     8m    kubelet, lab-kubernetes-node-54  Container image "debian:latest" already present on machine
  Normal  Created    8m    kubelet, lab-kubernetes-node-54  Created container
  Normal  Started    8m    kubelet, lab-kubernetes-node-54  Started container

Please notice the Status field of the two-container.

I wanna the container sidecar-debian keep alive along with the nginx container. How could I do that?

Thank for helping me. I'm very appreciate if some someone explain why it is being like that.

Thank you again!

-- Nguyen Duy Tan To
containers
kubernetes
pod

0 Answers