Third-party workloads use IP pools¶
This page focuses on configuring IP pools for custom workloads (taking the workload CloneSet created by the OpenKruise controller as an example here) and using Spiderpool to assign and fix the IPs in the Underlay network.
Prerequisites¶
- SpiderPool has been successfully deployed.
- Multus with Macvlan/SR-IOV has been successfully deployed.
- If you choose manual selection of IP pool, please complete Create IP subnet and IP pool in advance. To use a fixed IP pool in this example, please complete Create a fixed IP pool in advance.
Steps¶
Using created fixed IP pools¶
-
Deploy the CR
CloneSet
and specify the default network type, VLAN ID, subnet interface, and IP pool information inAnnotation
.v1.multus-cni.io/default-network: kube-system/calico k8s.v1.cni.cncf.io/networks: kube-system/vlan6 ipam.spidernet.io/ippools: '[{"interface":"net1","ipv4":["ippool01"]}]'
apiVersion: apps.kruise.io/v1alpha1 kind: CloneSet metadata: name: custom-kruise-cloneset spec: replicas: 1 selector: matchLabels: app: custom-kruise-cloneset template: metadata: annotations: v1.multus-cni.io/default-network: "kube-system/calico" k8s.v1.cni.cncf.io/networks: "kube-system/vlan6" ipam.spidernet.io/ippool: |- { "interface":"net1", "ipv4":["ippool01"] } labels: app: custom-kruise-cloneset spec: containers: - name: custom-kruise-cloneset image: busybox imagePullPolicy: IfNotPresent command: ["/bin/sh", "-c", "trap : TERM INT; sleep infinity & wait"]
-
Check the status of CloneSet after
CloneSet
is deployed. -
Go to
Container Platform
-> Select the corresponding cluster -> ClickContainer Network
, then find the corresponding subnet -> Go to the subnet details and check the IP usage.
Automatic creation of fixed IP pools¶
-
To automatically create a fixed IP pool using a subnet, add the following Annotation when creating a custom workload.
apiVersion: apps.kruise.io/v1alpha1 kind: CloneSet metadata: name: custom-kruise-cloneset03 spec: replicas: 3 selector: matchLabels: app: custom-kruise-cloneset03 template: metadata: annotations: v1.multus-cni.io/default-network: "kube-system/calico" # Specify the default container NIC k8s.v1.cni.cncf.io/networks: "kube-system/vlan6" #Specify the Multus CRD instance(NetworkAttachmentDefinition) ipam.spidernet.io/subnet: |- # Specify the NIC and the subnet to be used with the fixed IP pool {"interface":"net1","ipv4": ["subnet124"]} ipam.spidernet.io/ippool-ip-number: "1" # Specify the number of resilient IPs, the number of available IPs = the number of resilient IPs + the number of Replicas labels: app: custom-kruise-cloneset03 spec: containers: - name: custom-kruise-cloneset03 image: busybox imagePullPolicy: IfNotPresent command: ["/bin/sh", "-c", "trap : TERM INT; sleep infinity & wait"]
-
Check the status of Clonset:
-
Check the status of the IP Pool IP:
kubectl get sp -oyaml | grep kruise ipam.spidernet.io/application: apps.kruise.io/v1alpha1:CloneSet:default:custom-kruise-cloneset03 name: auto-custom-kruise-cloneset03-v4-net1-f3114156804d allocatedIPs: '{"10.6.124.200":{"interface":"net1","pod":"default/custom-kruise-cloneset-r7xjd","podUid":"43942169-3c43-4a81-aaae-60ba1dc9d07e"},"10.6.124.201":{"interface":"net1","pod":"default/custom-kruise-cloneset-sp5t6","podUid":"4980a045-7ee9-467a-a6a3-b259411963cb"},"10.6.124.202":{"interface":"net1","pod":"default/custom-kruise-cloneset-j94tl","podUid":"72b13a85-5275-44b1-8491-323f9fff3571"}}'