aboutsummaryrefslogtreecommitdiffstats
path: root/tools/k8s
diff options
context:
space:
mode:
authorSridhar K. N. Rao <sridhar.rao@spirent.com>2021-08-04 17:57:09 +0530
committerSridhar K. N. Rao <sridhar.rao@spirent.com>2021-08-10 13:12:59 +0530
commitf1737f24bcc72b08bc13728b56f8b3f50edcff03 (patch)
tree8c31f5e51a309597650c9f0f44e5349bbbeabd0c /tools/k8s
parent220aed1de03317d1ad6f3ebbec9f6b93e44522c7 (diff)
Add Userspace CNI build-and-run support files.
remove unnecessary spaces Signed-off-by: Sridhar K. N. Rao <sridhar.rao@spirent.com> Change-Id: Icfc1dda8a29e896802f8030c5848cc00b4c99389
Diffstat (limited to 'tools/k8s')
-rw-r--r--tools/k8s/cluster-deployment/uscni/Dockerfile25
-rwxr-xr-xtools/k8s/cluster-deployment/uscni/entrypoint.sh18
-rw-r--r--tools/k8s/cluster-deployment/uscni/userspace-cni-daemonset.yml45
3 files changed, 88 insertions, 0 deletions
diff --git a/tools/k8s/cluster-deployment/uscni/Dockerfile b/tools/k8s/cluster-deployment/uscni/Dockerfile
new file mode 100644
index 00000000..ddfa3674
--- /dev/null
+++ b/tools/k8s/cluster-deployment/uscni/Dockerfile
@@ -0,0 +1,25 @@
+# docker build --rm -t uscni
+FROM centos:7
+SHELL ["/bin/bash", "-o", "pipefail", "-c"]
+RUN yum install -y epel-release wget; yum clean all
+RUN wget --no-check-certificate https://golang.org/dl/go1.16.6.linux-amd64.tar.gz
+RUN tar -C /usr/local -xzf go1.16.6.linux-amd64.tar.gz
+ENV PATH /usr/local/go/bin:$PATH
+RUN yum install -y git make sudo; yum clean all
+ENV GOPATH /root/go
+RUN mkdir -p "/root/go" "$GOPATH/bin" "$GOPATH/src" "$GOPATH/src" && chmod -R 777 "$GOPATH"
+WORKDIR /root/go/src/
+ENV GO111MODULE off
+RUN go get github.com/intel/userspace-cni-network-plugin > /tmp/UserspaceDockerBuild.log 2>&1 || echo "Can ignore no GO files."
+WORKDIR /root/go/src/github.com/intel/userspace-cni-network-plugin
+ENV GO111MODULE on
+ENV GOROOT /usr/local/go
+ENV GOPATH /root/go
+RUN make clean && make install-dep && make install && make
+RUN cp userspace/userspace /usr/bin/userspace
+
+FROM alpine:latest
+COPY --from=0 /usr/bin/userspace /userspace
+
+ADD entrypoint.sh /
+ENTRYPOINT ["/entrypoint.sh"]
diff --git a/tools/k8s/cluster-deployment/uscni/entrypoint.sh b/tools/k8s/cluster-deployment/uscni/entrypoint.sh
new file mode 100755
index 00000000..0658f150
--- /dev/null
+++ b/tools/k8s/cluster-deployment/uscni/entrypoint.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Always exit on errors.
+set -e
+
+# Check if /opt/cni/bin directory exists
+if [ ! -d "/host/opt/cni/bin" ]
+then
+ echo "Directory /opt/cni/bin/ does not exists."
+ exit 1;
+fi
+
+# Copy cni-plugin on host machine
+cp -f /userspace /host/opt/cni/bin/
+
+# Sleep for 50 years.
+# sleep infinity is not available in alpine;
+sleep 2147483647
diff --git a/tools/k8s/cluster-deployment/uscni/userspace-cni-daemonset.yml b/tools/k8s/cluster-deployment/uscni/userspace-cni-daemonset.yml
new file mode 100644
index 00000000..d598fc6d
--- /dev/null
+++ b/tools/k8s/cluster-deployment/uscni/userspace-cni-daemonset.yml
@@ -0,0 +1,45 @@
+apiVersion: apps/v1
+kind: DaemonSet
+metadata:
+ name: userspace-cni-amd64
+ namespace: kube-system
+ labels:
+ tier: node
+ app: userspace-cni
+spec:
+ selector:
+ matchLabels:
+ app: userspace-cni
+ template:
+ metadata:
+ labels:
+ tier: node
+ app: userspace-cni
+ spec:
+ hostNetwork: true
+ nodeSelector:
+ beta.kubernetes.io/arch: amd64
+ tolerations:
+ - key: node-role.kubernetes.io/master
+ operator: Exists
+ effect: NoSchedule
+ containers:
+ - name: userspace-cni-plugin
+ image: uscni:latest
+ imagePullPolicy: Never
+ resources:
+ requests:
+ cpu: "100m"
+ memory: "50Mi"
+ limits:
+ cpu: "100m"
+ memory: "50Mi"
+ securityContext:
+ privileged: true
+ volumeMounts:
+ - name: cnibin
+ mountPath: /host/opt/cni/bin
+ volumes:
+ - name: cnibin
+ hostPath:
+ path: /opt/cni/bin