Skip to content

Commit 1309b96

Browse files
Merge pull request #1 from killianmuldoon/pr-image-build
ci: add image builds for ovn-kubernetes
2 parents e42a9f0 + 286b660 commit 1309b96

File tree

6 files changed

+433
-0
lines changed

6 files changed

+433
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Build Multi-Arch Container Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME_UBUNTU: ${{ github.repository }}-ubuntu
17+
IMAGE_NAME_FEDORA: ${{ github.repository }}-fedora
18+
19+
jobs:
20+
build-ubuntu:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
submodules: recursive
31+
fetch-depth: 0
32+
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v3
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Log in to Container Registry
40+
if: github.event_name != 'pull_request'
41+
uses: docker/login-action@v3
42+
with:
43+
registry: ${{ env.REGISTRY }}
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Extract metadata (tags, labels)
48+
id: meta
49+
uses: docker/metadata-action@v5
50+
with:
51+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_UBUNTU }}
52+
tags: |
53+
type=ref,event=branch
54+
type=ref,event=pr
55+
type=semver,pattern={{version}}
56+
type=semver,pattern={{major}}.{{minor}}
57+
type=sha,prefix={{branch}}-
58+
type=raw,value=latest,enable={{is_default_branch}}
59+
60+
- name: Build and push Ubuntu image
61+
uses: docker/build-push-action@v5
62+
with:
63+
context: .
64+
file: ./Dockerfile.ovn-kubernetes.ubuntu
65+
platforms: linux/amd64,linux/arm64
66+
push: ${{ github.event_name != 'pull_request' }}
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
build-args: |
70+
OVN_KUBERNETES_DIR=ovn-kubernetes
71+
BUILDER_IMAGE=quay.io/projectquay/golang:1.24
72+
cache-from: type=gha
73+
cache-to: type=gha,mode=max
74+
75+
build-fedora:
76+
runs-on: ubuntu-latest
77+
permissions:
78+
contents: read
79+
packages: write
80+
81+
steps:
82+
- name: Checkout repository
83+
uses: actions/checkout@v4
84+
with:
85+
submodules: recursive
86+
fetch-depth: 0
87+
88+
- name: Set up QEMU
89+
uses: docker/setup-qemu-action@v3
90+
91+
- name: Set up Docker Buildx
92+
uses: docker/setup-buildx-action@v3
93+
94+
- name: Log in to Container Registry
95+
if: github.event_name != 'pull_request'
96+
uses: docker/login-action@v3
97+
with:
98+
registry: ${{ env.REGISTRY }}
99+
username: ${{ github.actor }}
100+
password: ${{ secrets.GITHUB_TOKEN }}
101+
102+
- name: Extract metadata (tags, labels)
103+
id: meta
104+
uses: docker/metadata-action@v5
105+
with:
106+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_FEDORA }}
107+
tags: |
108+
type=ref,event=branch
109+
type=ref,event=pr
110+
type=semver,pattern={{version}}
111+
type=semver,pattern={{major}}.{{minor}}
112+
type=sha,prefix={{branch}}-
113+
type=raw,value=latest,enable={{is_default_branch}}
114+
115+
- name: Build and push Fedora image
116+
uses: docker/build-push-action@v5
117+
with:
118+
context: .
119+
file: ./Dockerfile.ovn-kubernetes-fedora
120+
platforms: linux/amd64,linux/arm64
121+
push: ${{ github.event_name != 'pull_request' }}
122+
tags: ${{ steps.meta.outputs.tags }}
123+
labels: ${{ steps.meta.outputs.labels }}
124+
build-args: |
125+
OVN_KUBERNETES_DIR=ovn-kubernetes
126+
BUILDER_IMAGE=quay.io/projectquay/golang:1.24
127+
cache-from: type=gha
128+
cache-to: type=gha,mode=max
129+

.gitignore

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
bin/
8+
_output/
9+
10+
# Go test binary, built with `go test -c`
11+
*.test
12+
13+
# Go coverage files
14+
*.out
15+
*.coverprofile
16+
coverage.html
17+
18+
# Go workspace file
19+
go.work
20+
go.work.sum
21+
22+
# Build artifacts
23+
dist/
24+
build/
25+
out/
26+
27+
# IDE and Editor files
28+
.idea/
29+
.vscode/
30+
*.swp
31+
*.swo
32+
*~
33+
.DS_Store
34+
*.bak
35+
*.sublime-project
36+
*.sublime-workspace
37+
38+
# OS specific files
39+
.DS_Store
40+
.DS_Store?
41+
._*
42+
.Spotlight-V100
43+
.Trashes
44+
ehthumbs.db
45+
Thumbs.db
46+
desktop.ini
47+
48+
# Docker
49+
.dockerignore
50+
51+
# Kubernetes
52+
*.kubeconfig
53+
kubeconfig
54+
.kube/
55+
56+
# Helm
57+
charts/*.tgz
58+
*.tgz
59+
requirements.lock
60+
61+
# Temporary files
62+
tmp/
63+
temp/
64+
*.tmp
65+
*.log
66+
*.pid
67+
*.seed
68+
*.pid.lock
69+
70+
# Environment files
71+
.env
72+
.env.local
73+
.env.*.local
74+
*.env
75+
76+
# Terraform (if used)
77+
.terraform/
78+
*.tfstate
79+
*.tfstate.*
80+
.terraform.lock.hcl
81+
82+
# Configuration overrides
83+
*-override.yaml
84+
*-override.yml
85+
local.yaml
86+
local.yml
87+

Dockerfile.ovn-kubernetes.fedora

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#
2+
# The standard name for this image is ovn-kube-ubuntu
3+
4+
# Notes:
5+
# This is for a development build where the ovn-kubernetes utilities
6+
# are built in this Dockerfile and included in the image (instead of the deb package)
7+
#
8+
#
9+
# So this file will change over time.
10+
11+
ARG BUILDER_IMAGE
12+
13+
#############################################
14+
# Stage to build OVN Kubernetes from Source #
15+
#############################################
16+
17+
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} AS ovnkube-builder
18+
19+
ARG TARGETARCH
20+
ARG TARGETOS=linux
21+
ARG OVN_KUBERNETES_DIR
22+
23+
WORKDIR /workspace
24+
COPY ${OVN_KUBERNETES_DIR} ovn-kubernetes
25+
26+
# Fix the git repository for the submodule so that it points to an actual git repository.
27+
# The ovn-kubernetes build process relies on having access to git information and can not be built as a submodule.
28+
RUN rm -rf ovn-kubernetes/.git
29+
COPY .git/modules/${OVN_KUBERNETES_DIR} ovn-kubernetes/.git
30+
RUN sed -i '/worktree = /d' ovn-kubernetes/.git/config
31+
32+
# Build the OVN Kubernetes binaries using the make target inside its repo.
33+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make -C ovn-kubernetes/dist/images bld
34+
35+
#################################
36+
# Main Ubuntu Image Stage #
37+
#################################
38+
39+
FROM ubuntu:25.04
40+
41+
USER root
42+
43+
RUN apt-get update && apt-get install -y iproute2 curl software-properties-common util-linux nftables
44+
45+
# Install OVS and OVN packages.
46+
RUN apt-get update && apt-get install -y openvswitch-switch openvswitch-common ovn-central ovn-common ovn-host
47+
48+
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl" \
49+
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
50+
51+
RUN mkdir -p /var/run/openvswitch
52+
53+
# Built in ../../go_controller, then the binaries are copied here.
54+
# put things where they are in the pkg
55+
RUN mkdir -p /usr/libexec/cni/
56+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovnkube /workspace/ovn-kubernetes/dist/images/ovn-kube-util /workspace/ovn-kubernetes/dist/images/ovndbchecker /workspace/ovn-kubernetes/dist/images/hybrid-overlay-node /workspace/ovn-kubernetes/dist/images/ovnkube-identity /workspace/ovn-kubernetes/dist/images/ovnkube-observ /usr/bin/
57+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovn-k8s-cni-overlay /usr/libexec/cni/ovn-k8s-cni-overlay
58+
59+
# ovnkube.sh is the entry point. This script examines environment
60+
# variables to direct operation and configure ovn
61+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovnkube.sh /root/
62+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovndb-raft-functions.sh /root/
63+
# override the pkg's ovn_k8s.conf with this local copy
64+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovn_k8s.conf /etc/openvswitch/ovn_k8s.conf
65+
66+
# copy git commit number into image
67+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/git_info /root
68+
69+
# iptables wrappers
70+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/iptables /usr/sbin/
71+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/iptables-save /usr/sbin/
72+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/iptables-restore /usr/sbin/
73+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/ip6tables /usr/sbin/
74+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/ip6tables-save /usr/sbin/
75+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/ip6tables-restore /usr/sbin/
76+
77+
LABEL io.k8s.display-name="ovn-kubernetes" \
78+
io.k8s.description="ovnkube ubuntu image"
79+
80+
WORKDIR /root
81+
ENTRYPOINT /root/ovnkube.sh

Dockerfile.ovn-kubernetes.ubuntu

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# The standard name for this image is ovn-kube-ubuntu
3+
4+
# Notes:
5+
# This is for a development build where the ovn-kubernetes utilities
6+
# are built in this Dockerfile and included in the image (instead of the deb package)
7+
#
8+
#
9+
# So this file will change over time.
10+
11+
ARG BUILDER_IMAGE
12+
#############################################
13+
# Stage to build OVN Kubernetes from Source #
14+
#############################################
15+
16+
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} AS ovnkube-builder
17+
18+
ARG TARGETARCH
19+
ARG TARGETOS=linux
20+
ARG OVN_KUBERNETES_DIR
21+
22+
WORKDIR /workspace
23+
COPY ${OVN_KUBERNETES_DIR} ovn-kubernetes
24+
25+
# Fix the git repository for the submodule so that it points to an actual git repository.
26+
# The ovn-kubernetes build process relies on having access to git information and can not be built as a submodule.
27+
RUN rm -rf ovn-kubernetes/.git
28+
COPY .git/modules/${OVN_KUBERNETES_DIR} ovn-kubernetes/.git
29+
RUN sed -i '/worktree = /d' ovn-kubernetes/.git/config
30+
31+
# Build the OVN Kubernetes binaries using the make target inside its repo.
32+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make -C ovn-kubernetes/dist/images bld
33+
34+
#################################
35+
# Main Ubuntu Image Stage #
36+
#################################
37+
38+
FROM ubuntu:25.04
39+
40+
USER root
41+
42+
RUN apt-get update && apt-get install -y iproute2 curl software-properties-common util-linux nftables
43+
44+
# Install OVS and OVN packages.
45+
RUN apt-get update && apt-get install -y openvswitch-switch openvswitch-common ovn-central ovn-common ovn-host
46+
47+
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl" \
48+
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
49+
50+
RUN mkdir -p /var/run/openvswitch
51+
52+
# Built in ../../go_controller, then the binaries are copied here.
53+
# put things where they are in the pkg
54+
RUN mkdir -p /usr/libexec/cni/
55+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovnkube /workspace/ovn-kubernetes/dist/images/ovn-kube-util /workspace/ovn-kubernetes/dist/images/ovndbchecker /workspace/ovn-kubernetes/dist/images/hybrid-overlay-node /workspace/ovn-kubernetes/dist/images/ovnkube-identity /workspace/ovn-kubernetes/dist/images/ovnkube-observ /usr/bin/
56+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovn-k8s-cni-overlay /usr/libexec/cni/ovn-k8s-cni-overlay
57+
58+
# ovnkube.sh is the entry point. This script examines environment
59+
# variables to direct operation and configure ovn
60+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovnkube.sh /root/
61+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovndb-raft-functions.sh /root/
62+
# override the pkg's ovn_k8s.conf with this local copy
63+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/ovn_k8s.conf /etc/openvswitch/ovn_k8s.conf
64+
65+
# copy git commit number into image
66+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/git_info /root
67+
68+
# iptables wrappers
69+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/iptables /usr/sbin/
70+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/iptables-save /usr/sbin/
71+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/iptables-restore /usr/sbin/
72+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/ip6tables /usr/sbin/
73+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/ip6tables-save /usr/sbin/
74+
COPY --from=ovnkube-builder /workspace/ovn-kubernetes/dist/images/iptables-scripts/ip6tables-restore /usr/sbin/
75+
76+
LABEL io.k8s.display-name="ovn-kubernetes" \
77+
io.k8s.description="ovnkube ubuntu image"
78+
79+
WORKDIR /root
80+
ENTRYPOINT /root/ovnkube.sh

0 commit comments

Comments
 (0)