- Create Kind Cluster
kind create cluster --name=test-bpfd
- Deploy Cert manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
- Deploy bpfd Crds
kubectl apply -f https://github.com/bpfd-dev/bpfd/releases/download/v0.2.1/bpfd-crds-install-v0.2.1.yaml
- Deploy bpfd-operator
kubectl apply -f https://github.com/bpfd-dev/bpfd/releases/download/v0.2.1/bpfd-operator-install-v0.2.1.yaml
- Configure Xdp Pass program to drop on proceed-on, Specifically add the following to the
xdpProgram
's Spec
proceedon:
- drop
- Deploy Xdp Pass program
kubectl apply -f - <<EOF
apiVersion: bpfd.io/v1alpha1
kind: XdpProgram
metadata:
labels:
app.kubernetes.io/name: xdpprogram
name: xdp-pass-all-nodes
spec:
sectionname: pass
# Select all nodes
nodeselector: {}
interfaceselector:
primarynodeinterface: true
priority: 0
proceedon:
- drop
bytecode:
image:
url: quay.io/bpfd-bytecode/xdp_pass:latest
EOF
- Deploy the xdp counter program and userspace application
kubectl apply -f https://github.com/bpfd-dev/bpfd/releases/download/v0.2.1/go-xdp-counter-install-v0.2.1.yaml
- Ensure Programs are deployed
kubectl get xdpprogram -o wide
NAME SECTIONNAME NODESELECTOR PRIORITY INTERFACESELECTOR PROCEEDON
go-xdp-counter-example stats {} 55 {"primarynodeinterface":true} ["pass","dispatcher_return"]
xdp-pass-all-nodes pass {} 0 {"primarynodeinterface":true} ["drop"]
- Verify no packets are being counted by the counter program
kubectl logs go-xdp-counter-ds-czlvx -n go-xdp-counter
2023/05/10 03:41:50 0 packets received
2023/05/10 03:41:50 0 bytes received
2023/05/10 03:41:53 0 packets received
2023/05/10 03:41:53 0 bytes received
...
- Edit the Xdp Pass program to have a higher priority then the counter program, Specifically edit the
priority
field of the Spec to 60
priority: 60
- Verify that packets are now being counted by the counter program
kubectl logs go-xdp-counter-ds-czlvx -n go-xdp-counter
2023/05/10 03:42:23 0 packets received
2023/05/10 03:42:23 0 bytes received
2023/05/10 03:42:26 6 packets received
2023/05/10 03:42:26 1386 bytes received
2023/05/10 03:42:29 70 packets received
2023/05/10 03:42:29 30654 bytes received
2023/05/10 03:42:32 203 packets received
2023/05/10 03:42:32 40111 bytes received
...
- Clean everything up
kubectl delete xdpprogram xdp-pass-all-nodes
kubectl delete -f https://github.com/bpfd-dev/bpfd/releases/download/v0.2.0/go-xdp-counter-install-v0.2.0.yaml