Common causes of this error :
1)ConfigMap is missing—a ConfigMap stores configuration data as key-value pairs.
Resolution : Identify the missing ConfigMap and create it in the namespace, or mount another, existing ConfigMap.
2)Secret is missing—a Secret is used to store sensitive information such as credentials.
Resolution : Identify the missing Secret and create it in the namespace, or mount another, existing Secret.
Try below possible solutions :
Solution 1:
The reason is due to when we create secret it regards the whole text as one single string as config.yaml
It does not take username or password as key
To workaround it, we need to get decoded string via base64
echo 'test' | base64 ---> dGVzdAo=
Then correct yaml file is :
apiVersion: v1kind: Secretmetadata: name: test-stg-secret
type: Opaque
data:
username: dGVzdAo=
password: dGVzdAo=
Please go through Henry Xie 's blog & similar SO for more information.
Solution 2 :
You need to understand whether a ConfigMap or Secret is missing. Run kubectl describe pod <podname> -n <namespace>
, you might see the cause of failing.
Run one of these commands to see if the requested ConfigMap or Secret exists in the cluster:
<pre”>kubectl get configmap kubectl get secret
If the command returns null, the ConfigMap or Secret is indeed missing. Follow these instructions to create the missing object mounted by the failed container: create a ConfigMap or create a secret.
If the pod has 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 and
then check docker logs -f <container id>
. Note : (you can ssh into the node.)
Please go through Fixing CreateContainerConfig Error for more information
Solution 3: Before the container goes into the Running state it goes through the deployment configuration and validates all the necessary configurations which are needed for the successful deployment of the docker container. During the validation phase it tries to find the secretKeyRef
with the name
, key
but it could not find those secrets available inside the kubernetes cluster leading to CreateContainerConfigError
.
1)Replicate the error CreateContainerConfigError
2)How to Check the container logs for finding the missing Kubernetes Secret
3)Create and apply the correct kubernetes secret
4)Re-run the kubernetes deployment after fixing the kubernetes secret
5)Debugging of the CreateContainerConfigError by looking into the POD logs using the kubectl describe Pod
command.
Please go through Solving Error CreateContainerConfig for more information.