diff --git a/Dockerfile b/Dockerfile index 85aa82a..5bbb8fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ FROM alpine:3.18 -COPY --chown=root:root /target/aarch64-unknown-linux-musl/debug/agent /app/ -COPY --chown=root:root /target/aarch64-unknown-linux-musl/debug/sinabro-cni /sinabro-cni +ARG ARCH + +COPY --chown=root:root /target/${ARCH}-unknown-linux-musl/debug/agent /app/ +COPY --chown=root:root /target/${ARCH}-unknown-linux-musl/debug/sinabro-cni /sinabro-cni ENV RUST_LOG=info diff --git a/justfile b/justfile new file mode 100644 index 0000000..436e746 --- /dev/null +++ b/justfile @@ -0,0 +1,16 @@ +setup-kind-cluster: + kind create cluster --config tests/e2e/kind-config.yaml + cargo xtask build-ebpf + cargo build --target $(uname -m)-unknown-linux-musl + docker build --build-arg ARCH=$(uname -m) -t sinabro:test . + kind load docker-image sinabro:test + +clean-kind-cluster: + kind delete cluster + +deploy-agent: setup-kind-cluster + kubectl apply -f tests/e2e/deploy-test/00-install.yaml + +deploy-test-pods: deploy-agent + kubectl taint nodes kind-control-plane node-role.kubernetes.io/control-plane- + kubectl apply -f tests/e2e/deploy-test/01-test-pods.yaml diff --git a/test/README.md b/test/README.md deleted file mode 100644 index 4fa4f1d..0000000 --- a/test/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Bash CNI example - -```shell -kind create cluster --config kind-config.yaml - -docker ps -docker exec -it sh - -# -- inside each node's container -apt update && apt install -y nmap - -# create and configure the bridge with the cni0 name -ip link add cni0 type bridge -ip link set cni0 up -ip addr add 10.244.0.1/24 dev cni0 -# ip addr add 10.244.1.1/24 dev cni0 -ip route | grep cni0 - -# apply additional forwarding rules that will allow -# to freely forward traffic inside the whole pod CIDR range -iptables -t filter -A FORWARD -s 10.244.0.0/16 -j ACCEPT -iptables -t filter -A FORWARD -d 10.244.0.0/16 -j ACCEPT - -# setup a network address translation (NAT) -iptables -t nat -A POSTROUTING -s 10.244.0.0/24 ! -o cni0 -j MASQUERADE -# iptables -t nat -A POSTROUTING -s 10.244.1.0/24 ! -o cni0 -j MASQUERADE - -# setup additional route rule -ip route add 10.244.1.0/24 via dev eth0 -# ip route add 10.244.0.0/24 via dev eth0 - -chmod +x comet-cni && cp comet-cni /opt/cni/bin/comet-cni -# -- inside each node's container - -kubectl taint nodes kind-control-plane node-role.kubernetes.io/control-plane- - -kubectl apply -f test-deploy.yaml - -# -- inside bash-worker -ping -ping -# -- inside bash-worker -``` diff --git a/test/agent.yaml b/tests/e2e/deploy-test/00-install.yaml similarity index 95% rename from test/agent.yaml rename to tests/e2e/deploy-test/00-install.yaml index 25f51ab..5080d84 100644 --- a/test/agent.yaml +++ b/tests/e2e/deploy-test/00-install.yaml @@ -1,4 +1,3 @@ ---- kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: @@ -59,7 +58,7 @@ spec: serviceAccountName: sinabro initContainers: - name: install-cni-bin - image: sinabro:0.0.1 + image: sinabro:test imagePullPolicy: IfNotPresent command: ['sh', '-c', 'chmod +x /sinabro-cni && cp /sinabro-cni /cni/sinabro-cni'] volumeMounts: @@ -67,7 +66,7 @@ spec: mountPath: /cni containers: - name: agent - image: sinabro:0.0.1 + image: sinabro:test imagePullPolicy: IfNotPresent ports: - containerPort: 8080 @@ -98,4 +97,4 @@ spec: - name: cni-cfg hostPath: path: /etc/cni/net.d - type: DirectoryOrCreate \ No newline at end of file + type: DirectoryOrCreate diff --git a/test/test-deploy.yaml b/tests/e2e/deploy-test/01-test-pods.yaml similarity index 100% rename from test/test-deploy.yaml rename to tests/e2e/deploy-test/01-test-pods.yaml diff --git a/test/kind-config.yaml b/tests/e2e/kind-config.yaml similarity index 100% rename from test/kind-config.yaml rename to tests/e2e/kind-config.yaml