💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
[TOC] ### **简介** whereabouts是一个cluster-wide(集群级别)的IPAM插件。它非常适合用在NetworkAttachment的场景。 本文 cilium(或其他) + multus + ipvlan给容器设置双网卡,ipvlan使用whereabouts来分配置IP ### **准备条件** 安装好K8S集群,以及master-plugin网络插件(可以是calico、flannel等) 安装好multus ### **安装Whereabouts** ``` $ git clone https://github.com/k8snetworkplumbingwg/whereabouts && cd whereabouts $ kubectl apply \ -f doc/crds/daemonset-install.yaml \ -f doc/crds/whereabouts.cni.cncf.io_ippools.yaml \ -f doc/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml \ -f doc/crds/ip-reconciler-job.yaml ``` ### **创建NetworkAttachmentDefinition** ``` apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: ipvlan spec: config: '{ "cniVersion": "0.3.0", "type": "ipvlan", "master": "ens37", "ipam": { "type": "whereabouts", "range": "10.10.0.0/16" } }' ``` ### **创建Pod** ``` apiVersion: apps/v1 kind: Deployment metadata: name: apline spec: replicas: 2 selector: matchLabels: k8s-app: apline template: metadata: annotations: k8s.v1.cni.cncf.io/networks: ipvlan labels: k8s-app: apline spec: containers: - name: alpine command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"] image: alpine imagePullPolicy: IfNotPresent affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: labelSelector: matchLabels: k8s-app: apline topologyKey: topology.kubernetes.io/hostname ``` ### **查看** 查看Pod ``` $ kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES apline-66b6bcc945-mmtdg 1/1 Running 0 3m42s 172.26.0.16 192.168.92.108 <none> <none> apline-66b6bcc945-mvx79 1/1 Running 0 6m7s 172.26.1.28 192.168.92.109 <none> <none> ``` 查看crd ``` $ kubectl get crd | grep whereabouts ippools.whereabouts.cni.cncf.io 2022-04-12T03:46:35Z overlappingrangeipreservations.whereabouts.cni.cncf.io 2022-04-12T03:46:35Z ``` 查看`ippools.whereabouts.cni.cncf.io` ``` $ kubectl get ippools.whereabouts.cni.cncf.io --all-namespaces NAMESPACE NAME AGE kube-system 10.10.0.0-16 8m8s $ kubectl get ippools.whereabouts.cni.cncf.io 10.10.0.0-16 -n kube-system -o yaml apiVersion: whereabouts.cni.cncf.io/v1alpha1 kind: IPPool metadata: creationTimestamp: "2022-04-12T03:48:42Z" generation: 3 name: 10.10.0.0-16 namespace: kube-system resourceVersion: "7915" uid: 06232e5a-cd53-4f78-86a9-c45b3f5f7128 spec: allocations: "1": id: 1f3284446437c013e2ca20f6a6b6fefcca7dfd5637c3f16b80a3826296a05722 podref: default/apline-66b6bcc945-mvx79 "2": id: e458b21602f47e42b60e53fa58e4863b15d3c46bee280fa65060c780f8cce5f0 podref: default/apline-66b6bcc945-mmtdg range: 10.10.0.0/16 ``` 查看`overlappingrangeipreservations.whereabouts.cni.cncf.io` ``` $ kubectl get overlappingrangeipreservations.whereabouts.cni.cncf.io --all-namespaces NAMESPACE NAME AGE kube-system 10.10.0.1 8m40s kube-system 10.10.0.2 6m14s $ kubectl get overlappingrangeipreservations.whereabouts.cni.cncf.io 10.10.0.1 -o yaml -n kube-system apiVersion: whereabouts.cni.cncf.io/v1alpha1 kind: OverlappingRangeIPReservation metadata: creationTimestamp: "2022-04-12T03:48:42Z" generation: 1 name: 10.10.0.1 namespace: kube-system resourceVersion: "7602" uid: 2e5ed8b5-41ee-4a0a-8580-19e7a0bb2649 spec: containerid: 1f3284446437c013e2ca20f6a6b6fefcca7dfd5637c3f16b80a3826296a05722 podref: default/apline-66b6bcc945-mvx79 ```