kubernetes pod部署不更新

kubernetes pod deployment not updating

我有一个 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 吗?

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

这可能是因为一旦部署了标签选择器,K8s 服务将不允许滚动更新在您决定删除现有 部署

之前,无法更新 K8s 服务
Changing selectors leads to undefined behaviors - users are not expected to change the selectors

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