Cyberithub

How to Solve Kubernetes Pod CreateContainerConfigError

Advertisements

In this article, we will see how to solve Kubernetes Pod CreateContainerConfigError. In Kubernetes, there are many different types of error which can occur at any point of time due to certain reasons, CreateContainerConfigError is one such error which we are going to look here in detail with the solution steps that you can take to solve this error. But before that it is first important to understand why this error occurs and how to identify the root cause of this error so that you can take all the necessary steps to solve this error.

 

How to Solve Kubernetes Pod CreateContainerConfigError

How to Solve Kubernetes Pod CreateContainerConfigError

Also Read: Solved "Kubernetes Pod CrashLoopBackOff with Exit Code 1" Error

Advertisements

You might encounter few reasons for CreateContainerConfigError in your Kubernetes cluster but most of the time this error occurs due to some issue in either ConfigMaps or in Kubernetes Secrets. We will see both the cases in detail. So when you start checking the error, the first thing you need to verify is the pod status by using kubectl get pods command as shown below.

[cyberithub@node1]$ kubectl get pods
NAME                         READY  STATUS                      RESTARTS AGE
app-fscm-66b6c48dd5-8n9sh    0/1    CreateContainerConfigError  0        2h
app-hcm-74d6a52ee7-q72cf     1/1    Running                     0        13d
app-portal-51g9d36ab6-z8tgd  1/1    Running                     0        41d

After seeing CreateContainerConfigError on the output, you can start looking for the cause of the error by checking below given cases.

Advertisements

 

Case 1: Due to ConfigMaps

The first and foremost thing that you should always check when you face CreateContainerConfigError is the ConfigMap. Many times, ConfigMap data either be missing or incorrect. In both the situations, you will face issue with the container creation. To check the list of ConfigMaps you need to use kubectl get configmaps command as shown below.

[cyberithub@node1]$ kubectl get configmaps

If you see 0 in ConfigMap DATA then it means a configmap is created but there is no data in it. This can be verified by checking the ConfigMap data section using kubectl get configmaps <configmap_name> -o yaml command. For example, if you have a configmap called app-fscm-config then you can check its data section by using kubectl get configmaps app-fscm-config -o yaml command as shown below.

Advertisements
[cyberithub@node1]$ kubectl get configmaps app-fscm-config -o yaml

If you see there is no data available then to fix the error you need to recreate the ConfigMap with appropriate data in it which is in the form of key value pairs.

 

Case 2: Due to Kubernetes Secrets

Sometimes when there is an issue with Kubernetes secrets then also it will show you CreateContainerConfigError only. For example, if you have some key missing in the secrets config file then post deployment you will see "Error: couldn't find key <key_name> in secret <secret_name>" under pod description. For example, if you have a pod called app-fscm-66b6c48dd5-8n9sh then you can use kubectl describe pod app-fscm-66b6c48dd5-8n9sh command to check the description.

Advertisements
[cyberithub@node1]$ kubectl describe pod app-fscm-66b6c48dd5-8n9sh

If there is no error related to key in description then you can probably check the secrets created using kubectl get secrets command as shown below.

[cyberithub@node1]$ kubectl get secrets
NAME                          TYPE                DATA  AGE
app-fscm-secret               Opaque              0     2h
app-hcm-secret                Opaque              2     13d
app-portal-secret             Opaque              4     41d

On the output, you will see a list of secrets created along with the number of data. If the secret is available but the data is showing as 0 then you need to verify the secrets data by using kubectl get secrets <secret_name> -o yaml command.

For example, if you have a secret called app-fscm-secret then you need to use kubectl get secrets app-fscm-secret -o yaml command as shown below. If you see the data section as empty("data":{}) then it means secrets data is missing. In this case, you need to deploy the secrets again with the appropriate secrets data to fix CreateContainerConfigError.

[cyberithub@node1]$ kubectl get secrets app-fscm-secret -o yaml

Hope, above solution would be enough to solve your CreateContainerConfigError. However, if you are still not able to solve then I would request you to please provide your feedback in the comment box so that I can take a look into your case as well.

Leave a Comment