Last active
June 2, 2025 09:47
-
-
Save LionelJouin/2259bebf710406be4a9a88eadc59af4d to your computer and use it in GitHub Desktop.
Kubecon Japan 2025 - Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prerequisites: | |
# https://github.com/LionelJouin/cni-dra-driver/tree/kubecon-jp-demo | |
# make build | |
# MY_REGISTRY=localhost:5000/cni-dra-driver | |
# make push-image REGISTRY=$MY_REGISTRY VERSION=latest | |
# (cd ./deployments/cni-dra-driver/ && kustomize edit set image cni-dra-driver=$MY_REGISTRY/cni-dra-driver:latest) | |
# kind create cluster --config docs/demo/kind-config.yaml | |
# kubectl apply -f https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/master/e2e/templates/cni-install.yml.j2 | |
# docker exec -it kind-worker ip link add enp0s10 link eth0 type macvlan mode bridge | |
# docker exec -it kind-worker2 ip link add enp0s10 link eth0 type macvlan mode bridge | |
# kubectl apply -k ./deployments/cni-dra-driver/ | |
# asciinema rec demo.cast --overwrite -c ./demo.sh | |
# asciinema upload demo.cast | |
print_prompt() { | |
local text="$1" | |
echo -e "\e[32m~#\e[0m $text" | |
} | |
slow_echo() { | |
text="$1" | |
delay=${2:-0.01} | |
echo -en "\e[32m~#\e[0m " | |
for (( i=0; i<${#text}; i++ )); do | |
echo -n "${text:$i:1}" | |
sleep "$delay" | |
done | |
echo | |
} | |
clear | |
slow_echo "# CNI-DRA-Driver, demo for KEP-4817 and KEP-5075" | |
slow_echo "# The goal of this demo is to show how CNI-DRA-Driver works with a simple scenario:" | |
cat <<EOF | |
+--------------------------------+ | |
| +----------------+ | | |
| | Pod-A | enp0s10 | | |
| | +---+ +---+ | |
| | | ---10gbps-- --10gbps-- | |
| | net1 +---+ +---+ | |
| | 10.10.1.x/24| | | |
| x1--------Running+ +---+ | |
| eth0| | | |
| Kind-Worker +---+ | |
+--------------------------------+ | |
+--------------------------------+ | |
| +----------------+ | | |
| | Pod-B | enp0s10 | | |
| | +---+ +---+ | |
| | | ---5gbps--- --10gbps-- | |
| | net1 +---+ +---+ | |
| | 10.10.1.x/24| | | |
| x2--------Running+ +---+ | |
| eth0| | | |
| Kind-Worker2 +---+ | |
+--------------------------------+ | |
+--------------------------------+ | |
| +---+ | |
| eth0| | | |
| Kind-Worker3 +---+ | |
+--------------------------------+ | |
+----------------+ | |
| Pod-B | | |
| | | |
x1--------Pending+ | |
EOF | |
slow_echo "# We have 2 workers, each with a 10Gbps enp0s10 NIC + an eth0 NIC, and one worker with only the eth0 NIC." | |
slow_echo "# We will first create a Pod-A which will request a MACVLAN on top of a enp0s10 NIC with 10 gbps dedicated." | |
slow_echo "# Then we will create 3 Pod-B which will request MACVLANs on top of a enp0s10 NIC with 5 gbps dedicated for each pod." | |
slow_echo "# This demo will show that Pod-A will be scheduled on a worker and get its requested MACVLAN." | |
slow_echo "# This demo will also show that only 2 Pod-B will be scheduled on a worker and get their requested MACVLAN sharing the same enp0s10 NIC." | |
slow_echo "# The third Pod-B will be pending because there is no more resources available to fulfill its request." | |
sleep 1 | |
slow_echo "# Here is the current pods running in the cluster:" | |
slow_echo "kubectl get pods --all-namespaces -o wide" | |
kubectl get pods --all-namespaces -o wide | |
sleep 5 | |
clear | |
slow_echo "# Here is the current state of the nodes in the cluster:" | |
cat <<EOF | |
+--------------------------------+ | |
| | | |
| +---+ | |
| enp0s10 | --10gbps-- | |
| +---+ | |
| | | |
| +---+ | |
| eth0| | | |
| Kind-Worker +---+ | |
+--------------------------------+ | |
+--------------------------------+ | |
| | | |
| +---+ | |
| enp0s10 | --10gbps-- | |
| +---+ | |
| | | |
| +---+ | |
| eth0| | | |
| Kind-Worker2 +---+ | |
+--------------------------------+ | |
+--------------------------------+ | |
| +---+ | |
| eth0| | | |
| Kind-Worker3 +---+ | |
+--------------------------------+ | |
EOF | |
slow_echo "kubectl get nodes" | |
kubectl get nodes | |
sleep 1 | |
slow_echo "docker exec -it kind-worker ip -br link show" | |
docker exec -it kind-worker ip -br link show | |
slow_echo "docker exec -it kind-worker2 ip -br link show" | |
docker exec -it kind-worker2 ip -br link show | |
slow_echo "docker exec -it kind-worker3 ip -br link show" | |
docker exec -it kind-worker3 ip -br link show | |
sleep 5 | |
clear # -------------------- | |
sleep 1 | |
slow_echo "# Here are the resource slices from the CNI-DRA-Driver representing the NICs in the cluster:" | |
slow_echo "kubectl get resourceslice" | |
kubectl get resourceslice | |
sleep 1 | |
slow_echo "kubectl get resourceslice kind-worker-cni-dra-driver -o yaml | tail -n +12" | |
kubectl get resourceslice kind-worker-cni-dra-driver -o yaml | tail -n +12 | |
sleep 1 | |
slow_echo "kubectl get resourceslice kind-worker2-cni-dra-driver -o yaml | tail -n +12" | |
kubectl get resourceslice kind-worker2-cni-dra-driver -o yaml | tail -n +12 | |
sleep 1 | |
slow_echo "kubectl get resourceslice kind-worker3-cni-dra-driver -o yaml | tail -n +12" | |
kubectl get resourceslice kind-worker3-cni-dra-driver -o yaml | tail -n +12 | |
sleep 5 | |
clear # -------------------- | |
sleep 1 | |
slow_echo "# We now create a Pod-A which will request a MACVLAN on top of a enp0s10 NIC with 10 gbps dedicated." | |
slow_echo "kubectl apply -f docs/demo/pod-A.yaml" | |
kubectl apply -f docs/demo/pod-A.yaml | |
sleep 1 | |
slow_echo "# We now create 3 Pod-B which will request MACVLANs on top of a enp0s10 NIC with 5 gbps dedicated for each pod." | |
slow_echo "kubectl apply -f docs/demo/deployment-B.yaml" | |
kubectl apply -f docs/demo/deployment-B.yaml | |
sleep 5 | |
clear # -------------------- | |
sleep 1 | |
slow_echo "# Here is Pod-A and its ResourceClaim:" | |
slow_echo "cat docs/demo/pod-A.yaml" | |
cat docs/demo/pod-A.yaml | |
sleep 5 | |
clear # -------------------- | |
sleep 1 | |
slow_echo "# Here is the deployment B and its ResourceClaimTemplate:" | |
slow_echo "cat docs/demo/deployment-B.yaml" | |
cat docs/demo/deployment-B.yaml | |
sleep 5 | |
clear # -------------------- | |
sleep 1 | |
slow_echo "kubectl get pods -o wide" | |
kubectl get pods -o wide | |
sleep 2 | |
slow_echo "kubectl get resourceclaim" | |
kubectl get resourceclaim | |
sleep 2 | |
cat <<EOF | |
+--------------------------------+ | |
| +----------------+ | | |
| | Pod-A | enp0s10 | | |
| | +---+ +---+ | |
| | | ---10gbps-- --10gbps-- | |
| | net1 +---+ +---+ | |
| | 10.10.1.x/24| | | |
| x1--------Running+ +---+ | |
| eth0| | | |
| Kind-Worker +---+ | |
+--------------------------------+ | |
+--------------------------------+ | |
| +----------------+ | | |
| | Pod-B | enp0s10 | | |
| | +---+ +---+ | |
| | | ---5gbps--- --10gbps-- | |
| | net1 +---+ +---+ | |
| | 10.10.1.x/24| | | |
| x2--------Running+ +---+ | |
| eth0| | | |
| Kind-Worker2 +---+ | |
+--------------------------------+ | |
+--------------------------------+ | |
| +---+ | |
| eth0| | | |
| Kind-Worker3 +---+ | |
+--------------------------------+ | |
+----------------+ | |
| Pod-B | | |
| | | |
x1--------Pending+ | |
EOF | |
slow_echo "# The demo has been successfully deployed. One of the Pod-B is pending because there is no more resources available to fulfill its request, its resourceclaim is in pending state." | |
sleep 5 | |
clear # -------------------- | |
sleep 1 | |
slow_echo "kubectl get resourceclaim -o yaml macvlan-enp0s10-attachment-a | tail -n 64" | |
kubectl get resourceclaim -o yaml macvlan-enp0s10-attachment-a | tail -n 64 | |
sleep 1 | |
slow_echo "# We can now check the resourceclaim status of Pod-A. A new virtual device (sharing enp0s10) has been created and an IP address had been assigned." | |
sleep 3 | |
slow_echo "# The MACVLAN interface is created in Pod-A with the assigned IP address." | |
slow_echo "kubectl exec -it demo-a -- ip a" | |
kubectl exec -it demo-a -- ip a | |
sleep 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment