Unable to update node annotation in Kubernetes

10/20/2018

I am using the flannel network plugin in my k8s cluster. And there is one special node which has one internal IP address and one public ip address which make it possible to ssh into it.

After I add the node using kubeadm I found out that the k get node xx -o yaml returns the flannel.alpha.coreos.com/public-ip annotation with the public IP address and which makes the internal Kubernetes pod unaccessible from other nodes.

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"

I try to use k edit node xxx to change the public-ip in the annotation it works in just one minute and then it will change back to the original one.

So...my question is just like the title: How can I change the Kubernetes node annotation flannel.alpha.coreos.com/public-ip without modifying back?

-- aisensiy
docker
flannel
kubeadm
kubernetes

2 Answers

10/20/2018

Do the modification using kubectl and you will have two ways:

  • kubectl annotate:

    kubectl annotate node xx --overwrite flannel.alpha.coreos.com/public-ip=new-value
  • or kubectl patch :

    kubectl patch node xx -p '{"metadata":{"annotations":{"flannel.alpha.coreos.com/public-ip":"new-value"}}}'
-- Abdennour TOUMI
Source: StackOverflow

10/22/2018

Update annotation flannel.alpha.coreos.com/public-ip-overwrite and then redeploy the pod make this work.

-- aisensiy
Source: StackOverflow