I'm playing with Kubernetes and got two VirtualBox machines - master and worker. Every one has two network interfaces - one for Internet and other for communication between each other VM and host machine. And I got troubles with Calico setup because it autodetects wrong network interface. I've made few settings to fix it but one trouble remains - worker takes wrong IP. And I found how to fix it - but it does not work. Details below.
Current worker config is (10.0.3.15
is those "wrong" IP):
[12:35]user@ubuntu-vbox-k8s-master[~]$ ./calicoctl get node ubuntu-vbox-k8s-worker -o yaml
apiVersion: projectcalico.org/v3
kind: Node
metadata:
annotations:
projectcalico.org/kube-labels: '{"beta.kubernetes.io/arch":"amd64","beta.kubernetes.io/os":"linux","kubernetes.io/arch":"amd64","kubernetes.io/hostname":"ubuntu-vbox-k8s-worker","kubernetes.io/os":"linux"}'
creationTimestamp: "2021-09-26T10:59:00Z"
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: ubuntu-vbox-k8s-worker
kubernetes.io/os: linux
name: ubuntu-vbox-k8s-worker
resourceVersion: "9219"
uid: 6f5efd41-e06c-4f9d-9b3a-248af88a385e
spec:
addresses:
- address: 10.0.3.15/24
type: CalicoNodeIP
- address: 10.0.3.15
type: InternalIP
bgp:
ipv4Address: 10.0.3.15/24
ipv4IPIPTunnelAddr: 192.168.77.64
orchRefs:
- nodeName: ubuntu-vbox-k8s-worker
orchestrator: k8s
status: {}
I try to apply fixed one:
[12:37]user@ubuntu-vbox-k8s-master[~]$ cat calico-worker.yaml
apiVersion: projectcalico.org/v3
kind: Node
metadata:
annotations:
projectcalico.org/kube-labels: '{"beta.kubernetes.io/arch":"amd64","beta.kubernetes.io/os":"linux","kubernetes.io/arch":"amd64","kubernetes.io/hostname":"ubuntu-vbox-k8s-worker","kubernetes.io/os":"linux"}'
creationTimestamp: "2021-09-26T10:59:00Z"
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: ubuntu-vbox-k8s-worker
kubernetes.io/os: linux
name: ubuntu-vbox-k8s-worker
resourceVersion: "5303"
uid: 6f5efd41-e06c-4f9d-9b3a-248af88a385e
spec:
addresses:
- address: 192.168.56.109
type: InternalIP
orchRefs:
- nodeName: ubuntu-vbox-k8s-worker
orchestrator: k8s
status: {}
and got error:
[12:38]user@ubuntu-vbox-k8s-master[~]$ ./calicoctl apply -f calico-worker.yaml
Failed to apply 'Node' resource: [update conflict: Node(ubuntu-vbox-k8s-worker)]
It is strange because I succeeded to fix Calico master node in same way without conflict with config:
apiVersion: projectcalico.org/v3
kind: Node
metadata:
annotations:
projectcalico.org/kube-labels: '{"beta.kubernetes.io/arch":"amd64","beta.kubernetes.io/os":"linux","kubernetes.io/arch":"amd64","kubernetes.io/hostname":"ubuntu-vbox-k8s-master","kubernetes.io/os":"linux","node-role.kubernetes.io/control-plane":"","node-role.kubernetes.io/master":"","node.kubernetes.io/exclude-from-external-load-balancers":""}'
creationTimestamp: "2021-09-26T10:56:24Z"
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: ubuntu-vbox-k8s-master
kubernetes.io/os: linux
node-role.kubernetes.io/control-plane: ""
node-role.kubernetes.io/master: ""
node.kubernetes.io/exclude-from-external-load-balancers: ""
name: ubuntu-vbox-k8s-master
resourceVersion: "9052"
uid: 9e6d55c6-f449-4ded-ab47-ea9d889d6b43
spec:
addresses:
- address: 192.168.56.108
type: InternalIP
bgp:
ipv4IPIPTunnelAddr: 192.168.77.0
orchRefs:
- nodeName: ubuntu-vbox-k8s-master
orchestrator: k8s
status:
podCIDRs:
- 192.168.77.0/24