---
apiVersion: resource.k8s.io/v1beta1
kind: ResourceSlice
metadata:
name: kind-worker-network-interfaces
spec:
devices:
- name: eth0
basic:
attributes:
name:
string: "eth0"
capabilities:
string: ["macvlan", "vlan"]
capacities:
- name: "vlan"
slice: []
nodeName: kind-worker
driver: cni.dra.networking.x-k8s.io
---
apiVersion: resource.k8s.io/v1beta1
kind: ResourceSlice
metadata:
name: kind-worker-whereabouts-subnets
spec:
devices:
- name: "10.10.1.0/24"
basic:
attributes:
subnet:
string: "10.10.1.0/24"
capacities:
- name: "ips"
count: 250
- name: "10.10.2.0/24"
basic:
attributes:
subnet:
string: "10.10.2.0/24"
capacities:
- name: "ips"
count: 250
nodeName: kind-worker
driver: cni.dra.networking.x-k8s.io # Used by the driver but not created nor maintained by the driver (created and maintained by whereabouts).
---
apiVersion: resource.k8s.io/v1beta1
kind: ResourceClaim
metadata:
name: vlan-eth0-300-attachment
spec:
devices:
requests:
- name: vlan-eth0-300
deviceClassName: cni.networking.x-k8s.io
consumption:
- selector: # This will select and consume in the device "eth0" of the resourceSlice called kind-worker-network-interfaces
- cel:
expression: | # Selects the resource with an interface named eth0 with vlan capability (for it to be selected, the capacity must be available)
device.attributes["cni.dra.networking.x-k8s.io"].name == "eth0" &&
device.attributes["cni.dra.networking.x-k8s.io"].capabilities.has("vlan")
capacity:
'vlan': "300" # consume its vlan 300
- selector: # This will select and consume in the device "10.10.1.0/24" of the resourceSlice called kind-worker-whereabouts-subnets
- cel:
expression: | # Selects the resource that offers the subnet 10.10.1.0/24
device.attributes["whereabouts.k8s.cni.cncf.io"].subnet == "10.10.1.0/24"
capacity:
'ips': 2 # consume 2 IPs on the subnet 10.10.1.0/24
- selector: # This will select and consume in the device "10.10.2.0/24" of the resourceSlice called kind-worker-whereabouts-subnets
- cel:
expression: | # Selects the resource that offers the subnet 10.10.2.0/24
device.attributes["whereabouts.k8s.cni.cncf.io"].subnet == "10.10.2.0/24"
capacity:
'ips': 1 # consume 2 IPs on the subnet 10.10.2.0/24
config:
- requests:
- vlan-eth0-300
opaque:
driver: cni.dra.networking.x-k8s.io
parameters:
apiVersion: cni.networking.x-k8s.io/v1alpha1
kind: CNI
ifName: "net1"
config: # CNI Config requesting a VLAN interface with the VLAN ID 300 and IPAM using Whereabouts for 3 IPs in 2 different subnets.
cniVersion: 1.0.0
type: vlan
name: vlan-eth0-300
master: eth0
vlanId: 300
linkInContainer: false
ipam:
type: whereabouts
ipRanges:
- range: 10.10.1.0/24
- range: 10.10.1.0/24
- range: 10.10.2.0/24
---
apiVersion: v1
kind: Pod
metadata:
name: demo-a
spec:
containers:
- name: alpine
image: alpine:latest
imagePullPolicy: IfNotPresent
command:
- sleep
- infinity
resourceClaims:
- name: vlan-eth0-300-attachment
resourceClaimName: vlan-eth0-300-attachment
Last active
January 15, 2025 14:05
-
-
Save LionelJouin/c0dd18d8a39b15a6aaa418f95725938d to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment