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

adding deployment file #178

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,40 @@ IMAGE_BUILDER?=docker
IMAGE_NAME?=$(IMAGE_REGISTRY)userspacecni:$(IMAGE_VERSION)

default: build
all: build deploy

local: build copy
all: build push deploy

help:
@echo "Make Targets:"
@echo "make build - Build UserSpace CNI container."
@echo "make deploy - Copy binary from container to host: /opt/cni/bin."
@echo "make all - build and deploy"
@echo "make copy - Copy binary from container to host:/opt/cni/bin."
@echo "make local - build and copy"
@echo "make deploy - kubectl apply daemonset"
@echo "make undeploy - kubectl delete daemonset"
@echo "make all - build push and deploy to kubernetes"

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

deploy:
push:
@$(IMAGE_BUILDER) push $(IMAGE_NAME)

copy:
# Copying the ovs binary to host /opt/cni/bin/
@mkdir -p /opt/cni/bin/
@$(IMAGE_BUILDER) run -it --rm -v /opt/cni/bin/:/opt/cni/bin/ $(IMAGE_NAME)

generate-bin: generate
# Used in dockerfile
@cd userspace && go build -v

generate:
for package in cnivpp/api/* ; do cd $$package ; pwd ; go generate ; cd - ; done
# Used in dockerfile
@for package in cnivpp/api/* ; do cd $$package ; pwd ; go generate ; cd - ; done

deploy:
# Use sed to replace image name and then apply deployment file
@sed "s|\(image:\).*\(#registory\)|\1 $(IMAGE_NAME) \2|g" ./kubernetes/userspace-daemonset.yml |kubectl apply -f -

undeploy:
kubectl delete -f ./kubernetes/userspace-daemonset.yml
28 changes: 28 additions & 0 deletions kubernetes/userspace-daemonset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: userspace-cni
namespace: kube-system
spec:
selector:
matchLabels:
app: userspace-cni
template:
metadata:
labels:
app: userspace-cni
spec:
containers:
- name: userspace-cni-plugin
image: localhost:5000/userspacecni #registory:imagename
imagePullPolicy: IfNotPresent
volumeMounts:
- name: cnibin
mountPath: /opt/cni/bin
command: ["/bin/sh","-c"]
args: ["cp -rf /root/userspace-cni-network-plugin/userspace/userspace /opt/cni/bin; sleep inf"]
volumes:
- name: cnibin
hostPath:
path: /opt/cni/bin