【问题标题】:kubernetes pod deployment not updatingKubernetes pod 部署未更新
【发布时间】:2021-09-21 22:18:34
【问题描述】:

我有一个 pod egress-operator-controller-manager 通过命令 make deploy IMG=my_azure_repo/egress-operator:v0.1makefile 创建。

此 pod 在描述中显示 unexpected status: 401 Unauthorized 错误,因此我创建了 imagePullSecrets 并尝试通过创建 pod 的 deployment.yaml [egress-operator-manager.yaml] 文件来使用秘密更新此 pod。
但是当我应用这个 yaml 文件时,它给出了以下错误:

root@Ubuntu18-VM:~/egress-operator# kubectl apply -f /home/user/egress-operator-manager.yaml
The Deployment "egress-operator-controller-manager" is invalid: spec.selector: Invalid value:
 v1.LabelSelector{MatchLabels:map[string]string{"moduleId":"egress-operator"}, 
MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable

egress-operator-manager.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: egress-operator-controller-manager
  namespace: egress-operator-system
  labels:
    moduleId: egress-operator
spec:
  replicas: 1
  selector:
    matchLabels:
      moduleId: egress-operator
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        moduleId: egress-operator
    spec:
      containers:
        - image: my_azure_repo/egress-operator:v0.1
          name: egress-operator
      imagePullSecrets:
        - name: mysecret

有人可以告诉我如何更新这个 pod 的 deployment.yaml 吗?

【问题讨论】:

  • 这个文件在你的 k8s 集群上的当前配置是什么?错误消息表明“[]v1.LabelSelectorRequirement(nil)}:”已被修改。 nil 值可能表示该值在您的 yaml 文件中不可用,但在当前应用的配置中可用。很可能添加此值将让您应用新配置
  • 我正在使用 que 中提到的“make deploy”命令部署这个 pod,如何找到现有 pod 的部署?是否有任何 kubectl 命令来获取正在运行的 pod 的现有部署/配置?
  • 是的,有。获取当前部署版本的命令是“kubectl get deployment egress-operator-controller-manager -n egress-operator-system -o yaml”

标签: kubernetes makefile kubernetes-pod azure-container-registry kubernetes-deployment


【解决方案1】:

删除一次部署并尝试再次应用 YAML。

可能是因为K8s服务不允许滚动更新,一旦部署K8s服务标签选择器无法更新直到您决定删除现有的部署

Changing selectors leads to undefined behaviors - users are not expected to change the selectors

https://github.com/kubernetes/kubernetes/issues/50808

【讨论】:

    猜你喜欢
    • 2019-11-11
    • 1970-01-01
    • 2020-07-20
    • 2020-07-02
    • 2020-07-27
    • 1970-01-01
    • 2019-06-28
    • 2020-12-02
    • 2018-02-01
    相关资源
    最近更新 更多