无法更新 Kubernetes 中的节点注释
Unable to update node annotation in Kubernetes
我在我的 k8s 集群中使用 flannel
网络插件。并且有一个特殊节点,它有一个内部 IP 地址和一个 public IP 地址,这使得通过 ssh 进入它成为可能。
在我使用 kubeadm
添加节点后,我发现 k get node xx -o yaml
returns flannel.alpha.coreos.com/public-ip
注释带有 public IP 地址和 这使得其他节点无法访问内部 Kubernetes pod。
apiVersion: v1
kind: Node
metadata:
annotations:
flannel.alpha.coreos.com/backend-data: '{"VtepMAC":"xxxxxx"}'
flannel.alpha.coreos.com/backend-type: vxlan
flannel.alpha.coreos.com/kube-subnet-manager: "true"
flannel.alpha.coreos.com/public-ip: <the-public-ip, not the internal one>
kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
node.alpha.kubernetes.io/ttl: "0"
volumes.kubernetes.io/controller-managed-attach-detach: "true"
我尝试用k edit node xxx
改注释中的public-ip
,一分钟就可以了,然后又变回原来的。
所以...我的问题就像标题一样:如何在不修改的情况下更改 Kubernetes 节点注释 flannel.alpha.coreos.com/public-ip
?
使用kubectl
进行修改,您将有两种方式:
kubectl 注释:
kubectl annotate node xx --overwrite flannel.alpha.coreos.com/public-ip=new-value
或kubectl 补丁:
kubectl patch node xx -p '{"metadata":{"annotations":{"flannel.alpha.coreos.com/public-ip":"new-value"}}}'
更新注解 flannel.alpha.coreos.com/public-ip-overwrite
然后重新部署 pod 使其工作。
我在我的 k8s 集群中使用 flannel
网络插件。并且有一个特殊节点,它有一个内部 IP 地址和一个 public IP 地址,这使得通过 ssh 进入它成为可能。
在我使用 kubeadm
添加节点后,我发现 k get node xx -o yaml
returns flannel.alpha.coreos.com/public-ip
注释带有 public IP 地址和 这使得其他节点无法访问内部 Kubernetes pod。
apiVersion: v1
kind: Node
metadata:
annotations:
flannel.alpha.coreos.com/backend-data: '{"VtepMAC":"xxxxxx"}'
flannel.alpha.coreos.com/backend-type: vxlan
flannel.alpha.coreos.com/kube-subnet-manager: "true"
flannel.alpha.coreos.com/public-ip: <the-public-ip, not the internal one>
kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
node.alpha.kubernetes.io/ttl: "0"
volumes.kubernetes.io/controller-managed-attach-detach: "true"
我尝试用k edit node xxx
改注释中的public-ip
,一分钟就可以了,然后又变回原来的。
所以...我的问题就像标题一样:如何在不修改的情况下更改 Kubernetes 节点注释 flannel.alpha.coreos.com/public-ip
?
使用kubectl
进行修改,您将有两种方式:
kubectl 注释:
kubectl annotate node xx --overwrite flannel.alpha.coreos.com/public-ip=new-value
或kubectl 补丁:
kubectl patch node xx -p '{"metadata":{"annotations":{"flannel.alpha.coreos.com/public-ip":"new-value"}}}'
更新注解 flannel.alpha.coreos.com/public-ip-overwrite
然后重新部署 pod 使其工作。