Minikube集群中的Pod状态为"CreateContainerConfigError" [英] Pod status as `CreateContainerConfigError` in Minikube cluster

查看:586
本文介绍了Minikube集群中的Pod状态为"CreateContainerConfigError"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下 helm图表运行Sonarqube服务.

I am trying to run Sonarqube service using the following helm chart.

因此设置类似于在minikube集群中启动MySQL和Sonarqube服务,而Sonarqube服务与MySQL服务进行通信以转储数据.

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.

当我依次执行helm installkubectl get pods时,我看到MySQL窗格状态为running,但是Sonarqube pos状态显示为CreateContainerConfigError.我认为这与安装量有关:链接.尽管我不太确定如何解决它(对于Kubernetes环境来说还很陌生,直到学习:))

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 :) )

推荐答案

我今天在尝试创建机密并将其用于pod定义yaml文件中时遇到了这个问题.如果您正在检查kubectl get secretskubectl get configmaps的输出,并使用它们验证它们的正确性,则将很有帮助.

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.

我认识到我的问题是,当我们创建包含多个数据项的机密时:kubectl get secrets <secret_name>的输出只有1个数据项,而我在secret_name_definition.yaml中指定了2个项.这是因为使用kubectl create -f secret_name_definition.yamlkubectl create secret <secret_name> --from-file=secret_name_definition.yaml之间存在差异,不同之处在于,对于前者,yaml数据部分中列出的所有项目都将被视为键值对,因此#当我们使用kubectl get secrets secret_name查询时,这些项目将显示为正确的输出,但对于后者,仅对secret_name_definition.yaml中的第一个数据项进行键值对评估,因此,kubectl get secrets secret_name的输出将仅显示1个数据项,这是当我们看到错误"CreateContainerConfigError"时.

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".

请注意,如果我们将kubectl create secret <secret_name>与选项--from-literal=一起使用,则不会发生此问题,因为那样的话,我们必须为要定义的每个键值对使用前缀--from-literal=.

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.

类似地,如果我们使用--from-file=选项,我们仍然必须多次指定前缀,每个键值对一次,但是只是当我们使用--from-literal时我们可以传递键的原始值和编码形式(即,当我们使用--from-file时,键的值现在将作为值的echo raw_value | base64.

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.

例如,假设密钥是用户名"和密码",如果使用命令kubectl create -f secret_definition.yaml创建密钥,我们需要对用户名"和密码"的值进行编码,如创建"中所述 https://kubernetes.io/docs的秘密"部分/tasks/inject-data-application/distribute-credentials-secure/

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

还请确保Deployment.yaml现在对该容器具有正确的定义:

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]

正如其他人所引用的,"kubectl describe pods pod_name"会有所帮助,但是在我的情况下,我只明白并不是首先创建了容器,并且"kubectl logs pod_name -c container_name"的输出并没有太大帮助.

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.

这篇关于Minikube集群中的Pod状态为"CreateContainerConfigError"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆