Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Kubernetes CreateContainerConfigError

Tags:

kubernetes

I'm trying to learn configuring Kubernetes and am currently studying configuring pods with configmaps.

I just created a simple pod with nginx, trying to link it to a configmap called options with the following yaml file:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: pod
  name: pod
spec:
  containers:
  - image: nginx
    name: pod
    resources: {}
    env:
      - name: options
        valueFrom:
          configMapKeyRef:
            name: option
            key: var5
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

When looking at my pods, I see a CreateContainerConfigError error. My question is: How can you debug a pod that has a config error? I am not interested in what went wrong in this specific case, is it possible to, for example, go into the pod and see what was wrong?

like image 254
hY8vVpf3tyR57Xib Avatar asked Jun 27 '20 08:06

hY8vVpf3tyR57Xib


People also ask

How do I debug Kubernetes deployment?

To debug a Kubernetes deployment, IT teams must start by following the basic rules of troubleshooting and then move to the smaller details to find the root cause of the problem. Kubernetes is complicated, with many components and variables that make it difficult to understand how, why and when something goes wrong.

What is createcontainerconfigerror or createcontainererror in Kubernetes?

What is CreateContainerConfigError or CreateContainerError? CreateContainerConfigError and CreateContainerError are two errors that occur when a Kubernetes tries to create a container in a pod, but fails before the container enters the Running state.

What is a container in Kubernetes?

A container is a packaged software application that includes all the necessary dependencies and binaries required to run the application. When you deploy a pod in Kubernetes, Kubernetes creates the container from the image you specify in the pod object.

What to do if secret is missing in Kubernetes?

Secret is missing —a Secret is used to store sensitive information such as credentials. Identify the missing Secret and create it in the namespace, or mount another, existing Secret. You need to understand whether a ConfigMap or Secret is missing. Run the kubectl describe and look for a message indicating one of these conditions, such as:

Why is my Kubernetes container not cleaning up?

This means the container runtime did not clean up an older container created under the same name. Sign in with root access on the node and open the kubelet log—usually located at /var/log/kubelet.log.


1 Answers

Run kubectl describe pod <podname> -n <namespace>, you might see the cause of failing.

If pod not started then you can not exec into pod, In this case run kubectl get pods -o wide and check in which node the pod is scheduled. Go to that node and run docker ps -a and get the container id desired container. then check docker logs -f <container id>

like image 172
hoque Avatar answered Sep 22 '22 13:09

hoque