Skip to content

Commit

Permalink
passt: Build and publish Passt binding CNI image
Browse files Browse the repository at this point in the history
Include DaemonSet manifest to deploy the binary on the cluster nodes.

Signed-off-by: Or Shoval <oshoval@redhat.com>
  • Loading branch information
oshoval committed Jul 23, 2024
1 parent 16f9e13 commit 23eed84
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/publish-img.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: kubevirt/ipam-controller
PASST_BINDING_CNI_IMAGE_NAME: kubevirt/passt-binding-cni

jobs:
push-amd64:
Expand Down Expand Up @@ -39,6 +40,11 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Fetch KubeVirt Release
run: |
KUBEVIRT_VERSION=$(curl -sSL https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt)
echo "KUBEVIRT_VERSION=${KUBEVIRT_VERSION}" >> $GITHUB_ENV
- name: Push latest container image
if: github.repository_owner == 'kubevirt'
uses: docker/build-push-action@v5.3.0
Expand All @@ -48,6 +54,17 @@ jobs:
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
file: Dockerfile

- name: Push latest passt binding cni container image
if: github.repository_owner == 'kubevirt'
uses: docker/build-push-action@v5.3.0
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.PASST_BINDING_CNI_IMAGE_NAME }}:latest
file: passt/Dockerfile
build-args: |
KUBEVIRT_VERSION=${{ env.KUBEVIRT_VERSION }}
- name: Push stable container image
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5.3.0
Expand All @@ -57,6 +74,17 @@ jobs:
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
file: Dockerfile

- name: Push stable passt binding cni container image
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5.3.0
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.PASST_BINDING_CNI_IMAGE_NAME }}:${{ github.ref_name }}
file: passt/Dockerfile
build-args: |
KUBEVIRT_VERSION=${{ env.KUBEVIRT_VERSION }}
- name: Template release manifests
if: startsWith(github.ref, 'refs/tags/')
run: IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} make build-installer
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# Image URL to use all building/pushing image targets
IMG ?= kubevirt-ipam-controller:latest
PASST_IMG ?= kubevirt/passt-binding-cni:latest

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29.0

Expand Down Expand Up @@ -100,10 +102,13 @@ run: manifests generate fmt vet ## Run a controller from your host.
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .
export KUBEVIRT_VERSION=$$(curl -sSL https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt) && \
$(CONTAINER_TOOL) build --build-arg KUBEVIRT_VERSION=$${KUBEVIRT_VERSION} -f passt/Dockerfile -t ${PASST_IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}
$(CONTAINER_TOOL) push ${PASST_IMG}

# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
Expand Down
3 changes: 2 additions & 1 deletion hack/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ function down() {

function sync() {
local img=localhost:5000/kubevirt-ipam-controller
local passt_img=localhost:5000/passt-binding-cni
local tag=latest
IMG=$img:$tag make \
IMG=$img:$tag PASST_IMG=$passt_img:$tag make \
build \
docker-build \
docker-push
Expand Down
9 changes: 9 additions & 0 deletions passt/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM registry.access.redhat.com/ubi9/ubi-minimal

ARG KUBEVIRT_VERSION

ENV CNI_PATH="/cni"

RUN mkdir -p ${CNI_PATH}
ADD https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-passt-binding ${CNI_PATH}/network-passt-binding
RUN chmod +x ${CNI_PATH}/network-passt-binding
49 changes: 49 additions & 0 deletions passt/passt-binding-cni-ds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: passt-binding-cni
namespace: kube-system
labels:
tier: node
app: passt-binding-cni
spec:
selector:
matchLabels:
name: passt-binding-cni
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 10%
template:
metadata:
labels:
name: passt-binding-cni
tier: node
app: passt-binding-cni
annotations:
description: passt-binding-cni installs 'passt binding' CNI on cluster nodes
spec:
priorityClassName: system-cluster-critical
containers:
- name: installer
image: ghcr.io/kubevirt/passt-binding-cni:latest
command: [ "/bin/sh", "-ce" ]
args:
- |
ls -la "/cni/network-passt-binding"
cp -f "/cni/network-passt-binding" "/opt/cni/bin"
echo "passt binding CNI plugin installation complete..sleep inf"
sleep infinity
resources:
requests:
cpu: "10m"
memory: "15Mi"
securityContext:
privileged: true
volumeMounts:
- name: cnibin
mountPath: /opt/cni/bin
volumes:
- name: cnibin
hostPath:
path: /opt/cni/bin

0 comments on commit 23eed84

Please sign in to comment.