我通过命令 egress-operator-controller-manager
从 makefile 创建了一个 pod make deploy IMG=my_azure_repo/egress-operator:v0.1
。
此 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 吗?
答案 0 :(得分:2)
删除一次部署并尝试再次应用 YAML。
可能是因为K8s服务不允许滚动更新,一旦部署,K8s服务的标签选择器就无法更新直到您决定删除现有的部署
Changing selectors leads to undefined behaviors - users are not expected to change the selectors