From 16c81577e0c46aee0301f6644ec3a793f6778bad Mon Sep 17 00:00:00 2001 From: Maryam Tahhan Date: Thu, 2 Nov 2023 15:36:53 +0000 Subject: [PATCH] debug: bpfd deployment map access issues Signed-off-by: Maryam Tahhan --- Makefile | 10 +++++----- deployments/daemonset-kind-bpfd.yaml | 5 +++++ examples/cndp-0-0.yaml | 15 ++++++--------- examples/nad_with_syncer.yaml | 18 +++++++++--------- internal/bpfd/client.go | 6 ++++-- setup-bpfd-afxdp.sh | 11 +++++++++++ 6 files changed, 40 insertions(+), 25 deletions(-) create mode 100755 setup-bpfd-afxdp.sh diff --git a/Makefile b/Makefile index f0f900e..a50c16c 100644 --- a/Makefile +++ b/Makefile @@ -85,12 +85,12 @@ podman: ## Build podman image @echo image: - # if $(MAKE) podman; then \ - # echo "Podman build succeeded"; \ - # else \ - # echo "Podman build failed, trying docker.."; \ + if $(MAKE) podman; then \ + echo "Podman build succeeded"; \ + else \ + echo "Podman build failed, trying docker.."; \ $(MAKE) docker; \ - # fi + fi undeploy: ## Undeploy the Deamonset @echo "****** Stop Daemonset ******" diff --git a/deployments/daemonset-kind-bpfd.yaml b/deployments/daemonset-kind-bpfd.yaml index cc1aa4c..efc4947 100644 --- a/deployments/daemonset-kind-bpfd.yaml +++ b/deployments/daemonset-kind-bpfd.yaml @@ -88,6 +88,8 @@ spec: mountPath: /var/log/afxdp-k8s-plugins/ - name: cnibin mountPath: /opt/cni/bin/ + - name: bpfd-maps + mountPath: /var/run/bpfd/fs/maps/ volumes: - name: unixsock hostPath: @@ -113,6 +115,9 @@ spec: - name: cnibin hostPath: path: /opt/cni/bin/ + - name: bpfd-maps + hostPath: + path: /var/run/bpfd/fs/maps/ --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole diff --git a/examples/cndp-0-0.yaml b/examples/cndp-0-0.yaml index 8080306..44ea2b0 100644 --- a/examples/cndp-0-0.yaml +++ b/examples/cndp-0-0.yaml @@ -1,4 +1,3 @@ -# A working example of BPF MAP PINNING apiVersion: v1 kind: Pod metadata: @@ -8,17 +7,15 @@ metadata: spec: containers: - name: cndp-0 - command: ["/bin/bash"] - args: ["-c", "./jsonc_gen.sh -kp ; cndpfwd -c config.jsonc lb;"] + command: ["tail", "-f", "/dev/null"] image: quay.io/mtahhan/cndp-map-pinning:latest imagePullPolicy: IfNotPresent securityContext: - privileged: true - #capabilities: - #add: - # - NET_RAW - # - IPC_LOCK - # - BPF + capabilities: + add: + - NET_RAW + - IPC_LOCK + - BPF resources: requests: afxdp/myPool: '1' diff --git a/examples/nad_with_syncer.yaml b/examples/nad_with_syncer.yaml index 37490c0..75bed20 100644 --- a/examples/nad_with_syncer.yaml +++ b/examples/nad_with_syncer.yaml @@ -3,19 +3,19 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: afxdp-network # Name of this network, pods will request this network by name + name: afxdp-network annotations: - k8s.v1.cni.cncf.io/resourceName: afxdp/myPool # Needs to match the device plugin pool name / resource type + k8s.v1.cni.cncf.io/resourceName: afxdp/myPool spec: config: '{ "cniVersion": "0.3.0", - "type": "afxdp", # CNI binary, leave as afxdp - "mode": "primary", # CNI mode setting (required) - "logFile": "afxdp-cni.log", # CNI log file location (optional) - "logLevel": "debug", # CNI logging level (optional) - "dpSyncer": true, # Sync with Device Plugin over gRPC MUST BE SET for bpf map pinning - "skipUnloadBpf": true, # Skip unloading BPF locally - "ipam": { # CNI IPAM plugin and associated config (optional) + "type": "afxdp", + "mode": "primary", + "logFile": "afxdp-cni.log", + "logLevel": "debug", + "dpSyncer": true, + "skipUnloadBpf": true, + "ipam": { "type": "host-local", "subnet": "192.168.1.0/24", "rangeStart": "192.168.1.200", diff --git a/internal/bpfd/client.go b/internal/bpfd/client.go index 3c23319..9f56247 100644 --- a/internal/bpfd/client.go +++ b/internal/bpfd/client.go @@ -155,9 +155,11 @@ func (b *BpfdClient) SubmitXdpProg(iface, node, pm, image, sec string) (string, bpfProgName := node + "-" + pm + "-" + iface + "-" + node + "-" + iface for _, bpfProgram := range bpfProgramList.Items { if bpfProgram.ObjectMeta.Name == bpfProgName { - logging.Infof("FOUND bpfProgram %v", bpfProgram) + time.Sleep(1 * time.Second) + logging.Infof("FOUND bpfProgram %s", bpfProgram.ObjectMeta.Name) + logging.Infof("bpfProgram.Spec.Maps %v", bpfProgram.Spec.Maps) if len(bpfProgram.Spec.Maps) == 0 { - logging.Errorf("NO MAPS FOUND for %s", bpfProgName) + logging.Errorf("NO MAPS FOUND for %s", bpfProgram.ObjectMeta.Name) return "", errors.New("Failed to find a map for the loaded bpf program") } for m, path := range bpfProgram.Spec.Maps { diff --git a/setup-bpfd-afxdp.sh b/setup-bpfd-afxdp.sh new file mode 100755 index 0000000..7277c5e --- /dev/null +++ b/setup-bpfd-afxdp.sh @@ -0,0 +1,11 @@ +#!/bin/bash +make image +docker pull quay.io/mtahhan/cndp-map-pinning +docker pull quay.io/mtahhan/xsk_def_xdp_prog +make setup-multus +make KIND_CLUSTER_NAME=bpfd-deployment kind-label-cp +make KIND_CLUSTER_NAME=bpfd-deployment IMAGE=quay.io/mtahhan/cndp-map-pinning kind-load-custom-image +make KIND_CLUSTER_NAME=bpfd-deployment IMAGE=quay.io/mtahhan/xsk_def_xdp_prog kind-load-custom-image +make KIND_CLUSTER_NAME=bpfd-deployment kind-deploy-bpfd +kubectl create -f examples/nad_with_syncer.yaml +kubectl create -f examples/cndp-0-0.yaml