diff --git a/.github/workflows/kind-e2e.yml b/.github/workflows/kind-e2e.yml index ac004b706..841b3ee6e 100644 --- a/.github/workflows/kind-e2e.yml +++ b/.github/workflows/kind-e2e.yml @@ -35,6 +35,10 @@ jobs: working-directory: ./e2e run: ./test-simple-macvlan1.sh + - name: Test static pod + working-directory: ./e2e + run: ./test-static-pod.sh + - name: Test default route1 working-directory: ./e2e run: ./test-default-route1.sh diff --git a/e2e/setup_cluster.sh b/e2e/setup_cluster.sh index f296e29b6..1ee1bf3b1 100755 --- a/e2e/setup_cluster.sh +++ b/e2e/setup_cluster.sh @@ -39,6 +39,12 @@ containerdConfigPatches: nodes: - role: control-plane - role: worker + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + pod-manifest-path: "/etc/kubernetes/manifests/" - role: worker EOF diff --git a/e2e/simple-static-pod.yml b/e2e/simple-static-pod.yml new file mode 100644 index 000000000..b63efbbf7 --- /dev/null +++ b/e2e/simple-static-pod.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Pod +metadata: + name: static-web + annotations: + k8s.v1.cni.cncf.io/networks: "bridge-nad" +spec: + containers: + - name: web + image: centos:8 + command: ["/bin/bash", "-c", "trap : TERM INT; sleep infinity & wait"] diff --git a/e2e/static-pod-nad.yml b/e2e/static-pod-nad.yml new file mode 100644 index 000000000..5f817378a --- /dev/null +++ b/e2e/static-pod-nad.yml @@ -0,0 +1,15 @@ +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: bridge-nad +spec: + config: '{ + "cniVersion": "0.3.1", + "name": "testnet", + "type": "bridge", + "bridge": "testnet0", + "ipam": { + "type": "host-local", + "subnet": "10.10.0.0/16" + } +}' diff --git a/e2e/test-static-pod.sh b/e2e/test-static-pod.sh new file mode 100755 index 000000000..9f34bc215 --- /dev/null +++ b/e2e/test-static-pod.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -o errexit + +echo "Creating network attachment definition" +kubectl create -f static-pod-nad.yml + +echo "Creating static pod config file" +docker cp simple-static-pod.yml kind-worker:/etc/kubernetes/manifests/static-web.yaml + +echo "Waiting for static pod to start" +kubectl wait --for=condition=Ready --namespace=default pod/static-web-kind-worker + +echo "Checking the pod annotation for net1 interface" +kubectl exec static-web-kind-worker --namespace=default -- ip a show dev net1 + +echo "Deleting static pod" +docker exec kind-worker /bin/bash -c "rm /etc/kubernetes/manifests/static-web.yaml" + +echo "Deleting network attachment definition" +kubectl delete -f static-pod-nad.yml + +echo "Test complete"