![嘗試應用 Calico 節點配置時如何修復「無法套用「節點」資源:[更新衝突:節點(...)]」?](https://rvso.com/image/770849/%E5%98%97%E8%A9%A6%E6%87%89%E7%94%A8%20Calico%20%E7%AF%80%E9%BB%9E%E9%85%8D%E7%BD%AE%E6%99%82%E5%A6%82%E4%BD%95%E4%BF%AE%E5%BE%A9%E3%80%8C%E7%84%A1%E6%B3%95%E5%A5%97%E7%94%A8%E3%80%8C%E7%AF%80%E9%BB%9E%E3%80%8D%E8%B3%87%E6%BA%90%EF%BC%9A%5B%E6%9B%B4%E6%96%B0%E8%A1%9D%E7%AA%81%EF%BC%9A%E7%AF%80%E9%BB%9E%EF%BC%88...%EF%BC%89%5D%E3%80%8D%EF%BC%9F.png)
我正在使用 Kubernetes,並獲得了兩台 VirtualBox 機器——主機器和工作機器。每個都有兩個網路介面 - 一個用於互聯網,另一個用於虛擬機器和主機之間的通訊。我在設定 Calico 時遇到了麻煩,因為它會自動偵測到錯誤的網路介面。我做了一些設定來修復它,但仍然存在一個問題 - 工作人員獲取了錯誤的 IP。我找到了修復它的方法 - 但它不起作用。詳細資訊如下。
目前的工作配置是(10.0.3.15
那些「錯誤」的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: {}
我嘗試應用固定的一個:
[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: {}
並得到錯誤:
[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)]
這很奇怪,因為我成功地以相同的方式修復了 Calico 主節點,並且沒有與配置衝突:
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
答案1
在 Calico Slack 頻道的幫助下透過指令kubectl set env daemonset/calico-node -n kube-system IP_AUTODETECTION_METHOD=interface=enp0s3
解決https://docs.projectcalico.org/networking/ip-autodetection