When adding command: in my deployment.yaml my pod goes CrashLoopBackOff

9/17/2019

When I add any command into deployment.yaml, my pod goes CrashLoopBackOff, if I remove the commands it works fine. The kubectl logs show me "Hello" but the http seems dont start.

    spec:
      containers:
      - name: {{ .Chart.Name }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        env:
    {{- range $pkey, $pval := .Values.env }}
        - name: {{ $pkey }}
          value: {{ quote $pval }}
{{- end }}
        **command: ["echo hello"]**
        ports:
        - containerPort: {{ .Values.service.internalPort }}
        livenessProbe:
          httpGet:
            path: {{ .Values.probePath }}
            port: {{ .Values.service.internalPort }}
          initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
          periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
          successThreshold: {{ .Values.livenessProbe.successThreshold }}
          timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
        readinessProbe:
          httpGet:
            path: {{ .Values.probePath }}
            port: {{ .Values.service.internalPort }}
          periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
          successThreshold: {{ .Values.readinessProbe.successThreshold }}
          timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
        resources:
{{ toYaml .Values.resources | indent 12 }}
      terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- end }}

can anyone help me?? thank you

-- Matias Haller
kubernetes-helm

1 Answer

9/17/2019

Docker container gets killed once the process running inside it is exited. In your case the Pod starts a container but then there is nothing to do after echo hello, thus container gets terminated with success code. But kubernetes will by default try to bring it up again, thus it spawns another container but that exits again, and this happens in a loop, thus you get CrashLoopBackOff

-- siddhesh bhasme
Source: StackOverflow