K8s: Multicontainered pod

6/3/2019

I'm writing helm chart for multicontainer pod. One container must work always, but another may gracefully shutdown. But when it's get down the service entered state whitout endpoint IP. Pod status in this time is Running< but its conditions: ready: false, ContainerReady: false How can I handle?

I can distribute containers in two pods with PV, but i don't want to do it. Now i'm using shared volumes to communicate between containers.

apiVersion: batch/v1beta1
kind: CronJob
  schedule: "{{ .Values.schedule }}"
  concurrencyPolicy: Replace
    jobTemplate:
      spec:
        template:
          spec:
            restartPolicy: Never
            volumes:
            - name: "shared-dir"
            emptyDir: {}
            containers:
            - name: {{ .Values.*.name }}
            image: ...
            - name: {{ .Values.*.name }}
            image: ...

I expected, that one container generates few files, place it in shared volume and gracefully shutdown it's work, while nginx will be share it to other services. Next time for job, all containers will be restarted by the concurrencyPolicy

-- Sakojpa
kubernetes

1 Answer

6/3/2019

Have you considered using init containers instead? This will allow you to prepare your volume before use. It only runs once during the deployment's life cycle. Configuring probes may also serve you well.

-- quantomworks
Source: StackOverflow