I am trying to run Sonarqube
service using the following helm chart.
So the set-up is like it starts a MySQL and Sonarqube service in the minikube cluster and Sonarqube service talks to the MySQL service to dump the data.
When I do helm install
followed by kubectl get pods
I see the MySQL
pod status as running
, but the Sonarqube
pos status shows as CreateContainerConfigError
. I reckon it has to do with the mounting volume thingy: link. Although I am not quite sure how to fix it (pretty nnew to Kubernetes environment and till learning :) )
I ran into this problem myself today as I was trying to create secrets and using them in my pod definition yaml file. It would help if you check the output of kubectl get secrets
and kubectl get configmaps
if you are using any of them and validate if the # of data items you wanted are listed correctly.
I recognized that in my case problem was that when we create secrets with multiple data items: the output of kubectl get secrets <secret_name>
had only 1 item of data while I had specified 2 items in my secret_name_definition.yaml
. This is because of the difference between using kubectl create -f secret_name_definition.yaml
vs kubectl create secret <secret_name> --from-file=secret_name_definition.yaml
The difference is that in the case of the former, all the items listed in the data section of the yaml will be considered as key-value pairs and hence the # of items will be shown as the correct output when we query using kubectl get secrets secret_name
but in the case of the latter only the first data item in the secret_name_definition.yaml
will be evaluated for the key-value pairs and hence the output of kubectl get secrets secret_name
will show only 1 data item and this is when we see the error "CreateContainerConfigError".
Note that this problem wouldn't occur if we use kubectl create secret <secret_name>
with the options --from-literal=
because then we would have to use the prefix --from-literal=
for every key-value pair we want to define.
Similarly, if we are using --from-file=
option, we still have to specify the prefix multiple times, one for each key-value pair, but just that we can pass the raw value of the key when we use --from-literal
and the encoded form (i.e. value of the key will now be echo raw_value | base64
of it as a value when we use --from-file
.
For example, say the keys are "username" and "password", if creating the secret using the command kubectl create -f secret_definition.yaml
we need to have the values for both "username" and "password" encoded as mentioned in the "Create a Secret" section of https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/
I would like to highlight the "Note:" section in https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/ Also, https://kubernetes.io/docs/concepts/configuration/secret/ has a very clear explanation of creating secrets
Also make sure that the deployment.yaml now has the correct definiton for this container:
env:
- name: DB_HOST
value: 127.0.0.1
# These secrets are required to start the pod.
# [START cloudsql_secrets]
- name: DB_USER
valueFrom:
secretKeyRef:
name: cloudsql-db-credentials
key: username
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: cloudsql-db-credentials
key: password
# [END cloudsql_secrets]
As quoted by others, "kubectl describe pods pod_name
" would help but in my case I only understood that the container wasn't being created first of all and the output of "kubectl logs pod_name -c container_name
" didn't help much.