当我编辑并保存 pod yaml 时,如何修复“map[] 不包含声明的合并键:名称”错误?

Xia*_* Li 8 kubernetes kubernetes-pod kubernetes-secrets

我正在尝试从私人注册表中提取图像。但 pod 的状态是“ImagePullBackOff”,这意味着我需要向 pod 添加一个 Secret。

Events:
  Type     Reason   Age                  From                                          Message
  ----     ------   ----                 ----                                          -------
  Normal   Pulling  52m (x255 over 22h)  kubelet, cn-huhehaote.i-hp3fkfzlcf1u9cigq2h7  pulling image "xxx/fcp"
  Normal   BackOff  8m (x5597 over 22h)  kubelet, cn-huhehaote.i-hp3fkfzlcf1u9cigq2h7  Back-off pulling image "xxx/fcp"
  Warning  Failed   3m (x5618 over 22h)  kubelet, cn-huhehaote.i-hp3fkfzlcf1u9cigq2h7  Error: ImagePullBackOff
Run Code Online (Sandbox Code Playgroud)

所以我在 pod yaml 中添加了以下代码。

spec:
      containers:
      - name: private-reg-container
        image: <your-private-image>
      imagePullSecrets:
      - name: my-secret
Run Code Online (Sandbox Code Playgroud)

然后我得到了

error: map: map[] does not contain declared merge key: name
Run Code Online (Sandbox Code Playgroud)

我找到的解决方案是删除“imagePullSecret”,这对我不起作用。我想知道如何修复该错误。谁能帮我?

kubectl 版本是

 kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.5", GitCommit:"753b2dbc622f5cc417845f0ff8a77f539a4213ea", GitTreeState:"clean", BuildDate:"2018-11-26T14:41:50Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.5", GitCommit:"753b2dbc622f5cc417845f0ff8a77f539a4213ea", GitTreeState:"clean", BuildDate:"2018-11-26T14:31:35Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

Run Code Online (Sandbox Code Playgroud)

9il*_*0lo 8

我偶然发现了同样的问题(使用 helm),并且我发现不允许编辑imagePullSecret部署中的部分...

解决方案是删除部署并重新创建它。


Vit*_*Vit -2

正如@fiunchinho 在评论中提到的以及根据Kubefed 的联合- 集群联合已被弃用。

强烈建议不要使用 Federation v1。Federation V1 从未达到 GA 状态,并且不再积极开发。文档仅用于历史目的。

解决方案是使用 Kubernetes Federation v2。更多详细信息可以参考Federation v2用户指南Federation v开发指南

  • 我看不出这个答案和问题之间的联系...... (4认同)