PoCs for calling CNI using DRA
Example of a DRA integration with an NRI Plugin for calling CNIs on pod creation.
This is a PoC (Proof Of Concept) about resource configuration. A Kubernetes fork implementing KEP-4817 is used (github.com/LionelJouin/kubernetes/tree/KEP-4817).
PoCs:
Other PoCs:
Generate Code (Proto, API, ...)
make generate
build/push (default registry: localhost:5000/network-dra)
make REGISTRY=localhost:5000/network-dra
Clone Kubernetes
git clone [email protected]:kubernetes/kubernetes.git
cd kubernetes
git remote add LionelJouin [email protected]:LionelJouin/kubernetes.git
git fetch LionelJouin
git checkout LionelJouin/KEP-4817
Build Kubernetes
kind build node-image . --image kindest/node:kep-4817
Create Kind Cluster
kind create cluster --config examples/kind.yaml
Load Images in Kind
kind load docker-image localhost:5000/network-dra/network-nri-plugin:latest
Install CNI Plugins
kubectl apply -f https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/master/e2e/templates/cni-install.yml.j2
Install DRA Plugin
helm install network-dra deployments/network-DRA --set registry=localhost:5000/network-dra
Demo
kubectl apply -f examples/demo-a.yaml
macvlan-eth0-attachment
resource claim parameter.Object applied: ./examples/demo-a.yaml
Final ResourceClaim object:
apiVersion: resource.k8s.io/v1alpha3
kind: ResourceClaim
metadata:
name: macvlan-eth0-attachment
spec:
devices:
config:
- opaque:
driver: poc.dra.networking
parameters:
config:
cniVersion: 1.0.0
name: macvlan-eth0
plugins:
- ipam:
ranges:
- - subnet: 10.10.1.0/24
type: host-local
master: eth0
mode: bridge
type: macvlan
interface: net1
requests:
- macvlan-eth0
requests:
- allocationMode: ExactCount
count: 1
deviceClassName: network-interface
name: macvlan-eth0
status:
allocation:
devices:
config:
- opaque:
driver: poc.dra.networking
parameters:
config:
cniVersion: 1.0.0
name: macvlan-eth0
plugins:
- ipam:
ranges:
- - subnet: 10.10.1.0/24
type: host-local
master: eth0
mode: bridge
type: macvlan
interface: net1
requests:
- macvlan-eth0
source: FromClaim
results:
- device: cni
driver: poc.dra.networking
pool: kind-worker
request: macvlan-eth0
nodeSelector:
nodeSelectorTerms:
- matchFields:
- key: metadata.name
operator: In
values:
- kind-worker
devices:
- conditions: null
data:
- cniVersion: 1.0.0
interfaces:
- mac: b2:af:6a:f9:12:3b
name: net1
sandbox: /var/run/netns/cni-d36910c7-c9a4-78f6-abad-26e9a8142a04
ips:
- address: 10.10.1.2/24
gateway: 10.10.1.1
interface: 0
device: cni
driver: poc.dra.networking
networkData:
addresses:
- cidr: 10.10.1.2/24
hwAddress: b2:af:6a:f9:12:3b
interfaceName: net1
pool: kind-worker
reservedFor:
- name: demo-a
resource: pods
uid: 680f0a77-8d0b-4e21-8599-62581e335ed6