Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 70ea136

Browse files
adding deployment file (#178)
Signed-off-by: John O'Loughlin <[email protected]>
1 parent a18d283 commit 70ea136

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

Diff for: Makefile

+20-6
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,40 @@ IMAGE_BUILDER?=docker
55
IMAGE_NAME?=$(IMAGE_REGISTRY)userspacecni:$(IMAGE_VERSION)
66

77
default: build
8-
all: build deploy
9-
8+
local: build copy
9+
all: build push deploy
1010

1111
help:
1212
@echo "Make Targets:"
1313
@echo "make build - Build UserSpace CNI container."
14-
@echo "make deploy - Copy binary from container to host: /opt/cni/bin."
15-
@echo "make all - build and deploy"
14+
@echo "make copy - Copy binary from container to host:/opt/cni/bin."
15+
@echo "make local - build and copy"
16+
@echo "make deploy - kubectl apply daemonset"
17+
@echo "make undeploy - kubectl delete daemonset"
18+
@echo "make all - build push and deploy to kubernetes"
1619

1720
build:
1821
@$(IMAGE_BUILDER) build . -f ./docker/userspacecni/Dockerfile -t $(IMAGE_NAME)
1922

20-
deploy:
23+
push:
24+
@$(IMAGE_BUILDER) push $(IMAGE_NAME)
25+
26+
copy:
2127
# Copying the ovs binary to host /opt/cni/bin/
2228
@mkdir -p /opt/cni/bin/
2329
@$(IMAGE_BUILDER) run -it --rm -v /opt/cni/bin/:/opt/cni/bin/ $(IMAGE_NAME)
2430

2531
generate-bin: generate
32+
# Used in dockerfile
2633
@cd userspace && go build -v
2734

2835
generate:
29-
for package in cnivpp/api/* ; do cd $$package ; pwd ; go generate ; cd - ; done
36+
# Used in dockerfile
37+
@for package in cnivpp/api/* ; do cd $$package ; pwd ; go generate ; cd - ; done
38+
39+
deploy:
40+
# Use sed to replace image name and then apply deployment file
41+
@sed "s|\(image:\).*\(#registory\)|\1 $(IMAGE_NAME) \2|g" ./kubernetes/userspace-daemonset.yml |kubectl apply -f -
3042

43+
undeploy:
44+
kubectl delete -f ./kubernetes/userspace-daemonset.yml

Diff for: kubernetes/userspace-daemonset.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: DaemonSet
4+
metadata:
5+
name: userspace-cni
6+
namespace: kube-system
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: userspace-cni
11+
template:
12+
metadata:
13+
labels:
14+
app: userspace-cni
15+
spec:
16+
containers:
17+
- name: userspace-cni-plugin
18+
image: localhost:5000/userspacecni #registory:imagename
19+
imagePullPolicy: IfNotPresent
20+
volumeMounts:
21+
- name: cnibin
22+
mountPath: /opt/cni/bin
23+
command: ["/bin/sh","-c"]
24+
args: ["cp -rf /root/userspace-cni-network-plugin/userspace/userspace /opt/cni/bin; sleep inf"]
25+
volumes:
26+
- name: cnibin
27+
hostPath:
28+
path: /opt/cni/bin

0 commit comments

Comments
 (0)