Skip to content

Commit

Permalink
Push ovn-k images to ghcr.io
Browse files Browse the repository at this point in the history
Automatically push the built ovn-k images with
fedora, and ubuntu bases(arm64 amd6d) to ghcr.io for
the ovn-org.  New images will be built and push
every time new changes are merged into
the ovn-kubernetes master branch.

Update the ovn-docker-images workflow to only run
when code is merged into master.

Signed-off-by: astoycos <astoycos@redhat.com>
  • Loading branch information
astoycos committed Mar 1, 2022
1 parent 5182205 commit c261990
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 6 deletions.
77 changes: 72 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ name: ovn-docker-images

on:
push:
pull_request:
branches: [ master ]
paths: [ "dist/images/Dockerfile*"]

env:
GO_VERSION: 1.17.6
REGISTRY: ghcr.io
OWNER: ovn-org
REPOSITORY: ovn-kubernetes
FEDORA_IMAGE_NAME: ovn-kube-f
UBUNTU_IMAGE_NAME: ovn-kube-u

jobs:
build:
Expand All @@ -23,12 +26,76 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Log in to the GH Container registry
uses: docker/login-action@v1.12.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up environment
run: |
export GOPATH=$(go env GOPATH)
echo "GOPATH=$GOPATH" >> $GITHUB_ENV
echo "$GOPATH/bin" >> $GITHUB_PATH
- name: Build images
run: |
make -C dist/images all
- name: Build ovnkube-binaries copy to context
run: |
pushd go-controller
make
popd
pushd dist/images
cp -r ../../go-controller/_output/go/bin/* .
popd
- name: Generate git-info to write to image
run: |
BRANCH=$(git rev-parse --short "$GITHUB_SHA")
COMMIT=$(git rev-parse HEAD)
pushd dist/images
echo "ref: ${BRANCH} commit: ${COMMIT}" > git_info
popd
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

- name: Extract metadata (tags, labels) for fedora ovn-k image
id: meta-fedora
uses: docker/metadata-action@v3.6.2
with:
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPOSITORY }}/${{ env.FEDORA_IMAGE_NAME }}

- name: Build and push Fedora based Docker image
uses: docker/build-push-action@v2.9.0
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./dist/images
file: ./dist/images/Dockerfile.fedora
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-fedora.outputs.tags }}
labels: ${{ steps.meta-fedora.outputs.labels }}

- name: Extract metadata (tags, labels) for ubuntu ovn-k image
id: meta-ubuntu
uses: docker/metadata-action@v3.6.2
with:
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPOSITORY }}/${{ env.UBUNTU_IMAGE_NAME }}

- name: Build and push Ubuntu based Docker image
uses: docker/build-push-action@v2.9.0
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./dist/images
file: ./dist/images/Dockerfile.ubuntu
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-ubuntu.outputs.tags }}
labels: ${{ steps.meta-ubuntu.outputs.labels }}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

On Linux, the easiest way to get started is to use OVN DaemonSet and Deployments.

# Master Based Ovn-Kubernetes Images

With every PR that is merged into master, ovn-kubernetes images are automatically
rebuilt and pushed to ghcr.io (i.e [ovn-org's packages](https://github.com/orgs/ovn-org/packages))
for consumption. They are built with fedora, and ubuntu base images both of which
are built for arm64 and amd64 architectures. These are not official releases and are just provided to make
using ovn-kubernetes easier for other projects.

## Install Open vSwitch kernel modules on all hosts.

Most Linux distributions come with Open vSwitch kernel module by default. You
Expand Down
9 changes: 8 additions & 1 deletion dist/images/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ USER root
ENV PYTHONDONTWRITEBYTECODE yes

ARG ovnver=ovn-21.12.0-3.fc35
# Automatically populated when using docker buildx
ARG TARGETPLATFORM
ARG BUILDPLATFORM

RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM"

# install needed rpms - openvswitch must be 2.10.4 or higher
RUN INSTALL_PKGS=" \
Expand All @@ -29,7 +34,9 @@ RUN INSTALL_PKGS=" \

RUN mkdir -p /var/run/openvswitch

RUN koji download-build $ovnver --arch=x86_64
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ] || [ -z "$TARGETPLATFORM"] ; then koji download-build $ovnver --arch=x86_64 ; \
else koji download-build $ovnver --arch=aarch64 ; fi

RUN rpm -Uhv --nodeps --force *.rpm

# Built in ../../go_controller, then the binaries are copied here.
Expand Down

0 comments on commit c261990

Please sign in to comment.