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

Commit b901360

Browse files
committed
adding deployment file
Signed-off-by: John O'Loughlin <[email protected]>
1 parent 8110381 commit b901360

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

Diff for: Makefile

+17-6
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,37 @@ 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 all - build push and deploy to kubernetes"
1618

1719
build:
1820
@$(IMAGE_BUILDER) build . -f ./docker/userspacecni/Dockerfile -t $(IMAGE_NAME)
1921

20-
deploy:
22+
push:
23+
@$(IMAGE_BUILDER) push $(IMAGE_NAME)
24+
25+
copy:
2126
# Copying the ovs binary to host /opt/cni/bin/
2227
@mkdir -p /opt/cni/bin/
2328
@$(IMAGE_BUILDER) run -it --rm -v /opt/cni/bin/:/opt/cni/bin/ $(IMAGE_NAME)
2429

2530
generate-bin: generate
31+
# Used in dockerfile
2632
@cd userspace && go build -v
2733

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

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)