Como corrigir "Falha ao aplicar o recurso 'Nó': [conflito de atualização: Nó (...)]" ao tentar aplicar a configuração do nó Calico?

Como corrigir "Falha ao aplicar o recurso 'Nó': [conflito de atualização: Nó (...)]" ao tentar aplicar a configuração do nó Calico?

Estou brincando com Kubernetes e tenho duas máquinas VirtualBox – master e trabalhador. Cada um possui duas interfaces de rede - uma para Internet e outra para comunicação entre a VM e a máquina host. E tive problemas com a configuração do Calico porque ele detecta automaticamente a interface de rede errada. Fiz algumas configurações para consertar, mas um problema permanece: o trabalhador usa o IP errado. E descobri como consertar - mas não funciona. Detalhes abaixo.

A configuração atual do trabalhador é ( 10.0.3.15é aquele IP "errado"):

[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: {}

Eu tento aplicar um fixo:

[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: {}

e obtive erro:

[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)]

É estranho porque consegui consertar o nó mestre Calico da mesma maneira, sem conflito com a configuração:

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

Responder1

Resolvido com ajuda do canal Calico Slack por comando kubectl set env daemonset/calico-node -n kube-system IP_AUTODETECTION_METHOD=interface=enp0s3dehttps://docs.projectcalico.org/networking/ip-autodetection

informação relacionada