Commit 0914305d authored by Manuel Rüger's avatar Manuel Rüger
Browse files

Build binaries via Dockerfile, migrate to Github Actions

* Removes Travis Integration and migrates to Github Actions
* Builds binaries in Dockerfile via MultiArch
* Adds a Release Process
* Drops support for ppc64le, s390x container builds (as golang-alpine3.14 does not
  contain builds for them)
parent 366b95f2
base dependabot/go_modules/github.com/aws/aws-sdk-go-1.44.211 dependabot/go_modules/github.com/osrg/gobgp/v3-3.11.0 dependabot/go_modules/k8s.io/api-0.26.2 dependabot/go_modules/k8s.io/apimachinery-0.26.2 dependabot/go_modules/k8s.io/cri-api-0.26.2 disable-policy-routing master rel-v0.0.1 release-test/22.02.3 release/21.08-BETA.1 release/21.08-BETA.2 release/22.02 release/22.02-RC.1 release/22.02-RC.2 release/22.02-test release/22.02.1 release/22.02.2 release/22.02.3 release/22.02.4 release/22.12 release/22.12-BETA.1 release/22.12-BETA.2 release/22.12-RC.1 release/22.12.1 release/22.12.2 release/22.12.3 release/22.12.4 release/22.2-RC.1 release/23.10-BETA.1 release/23.10-RC.1 release/23.10.0 release/23.10.1 release/23.10.1.2 release/23.10.1.3 release/23.10.2 release/24.04-BETA.1 release/24.04-RC.1 release/24.04.0 stable/angelfish stable/angelfish-backup-06-04-22 stable/angelfish-backup-28-05-22 stable/bluefin stable/cobia stable/dragonfish testing-refine-branchout-process testing-refine-branchout-process2 tmprelease/test-21.08 tmprelease/test-21.09 tmprelease/test2-21.09 tmprelease/test3-21.09 tmprelease/test4-21.09 truenas/master truenas/master-backup-03-4-22 truenas/master-backup-2-7-23 truenas/master-backup-21-08-22 truenas/master-backup-28-7-21 truenas/master-backup-29-05-22 TS-24.04-RC.1 TS-24.04-BETA.1 TS-23.10.2 TS-23.10.1.3 TS-23.10.1.2 TS-23.10.1.1 TS-23.10.1 TS-23.10.0.1 TS-23.10.0 TS-23.10-RC.1 TS-23.10-BETA.1 TS-22.12.4.2 TS-22.12.4.1 TS-22.12.4 TS-22.12.3.3 TS-22.12.3.2 TS-22.12.3.1 TS-22.12.3 TS-22.12.2 TS-22.12.1 TS-22.12.0 TS-22.12-RC.1 TS-22.12-BETA.2 TS-22.12-BETA.1 TS-22.12-ALPHA.1 TS-22.02.4 TS-22.02.3 TS-22.02.2.1 TS-22.02.2 TS-22.02.1 TS-22.02.0.1 TS-22.02.0 TS-22.2.0 TS-22.02.RELEASE.1 TS-22.02-RC.2 TS-22.02-RC.1 TS-22.02-RC.1-2 TS-22.02-RC.1-1 TS-21.08-BETA.2 TS-21.08-BETA.1 TS-12.12.3 DN110M-CS-v2.0
No related merge requests found
Showing with 113 additions and 171 deletions
+113 -171
.git
**/_cache
app
build-image
cni
contrib
daemonset
dashboard
Documentation
hack
utils
vendor
......@@ -13,6 +13,7 @@ on:
- v[1-9].*
jobs:
# Runs Golangci-lint on the source code
ci-go-lint:
name: ci-go-lint
runs-on: ubuntu-latest
......@@ -30,6 +31,7 @@ jobs:
run: |
make lint
# Executes Unit Tests
ci-unit-tests:
name: ci-unit-tests
runs-on: ubuntu-latest
......@@ -47,6 +49,7 @@ jobs:
run: |
make test
# Builds Kube-Router binary
ci-build-kube-router:
name: ci-build-kube-router
runs-on: ubuntu-latest
......@@ -63,3 +66,78 @@ jobs:
- name: Build kube-router
run: |
make kube-router
# Builds Container on Push Event, not run if there's a Tag Event
ci-build-container:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract branch from github ref - New Push
if: ${{ startsWith('refs/tags/v', github.ref) != true && github.event_name != 'pull_request' }}
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Build and push - New Push
uses: docker/build-push-action@v2
if: ${{ startsWith('refs/tags/v', github.ref) != true && github.event_name != 'pull_request' }}
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: cloudnativelabs/kube-router-git:${ steps.extract_branch.outputs.branch}
- name: Build and push - New PR
uses: docker/build-push-action@v2
if: github.event_name == 'pull_request'
with:
context: .
# Don't build multi arch images for PR as they take more than 30 min to build
platforms: linux/amd64
push: true
tags: cloudnativelabs/kube-router-git:PR-${{ github.event.pull_request.number }}
- name: Build and push - New Tag
uses: docker/build-push-action@v2
if: ${{ startsWith('refs/tags/v', github.ref) }}
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: cloudnativelabs/kube-router:${{ github.event.release.tag_name }},cloudnativelabs/kube-router:latest
# Runs Go Releaser on Tag Event
ci-goreleaser-tag:
runs-on: ubuntu-latest
if: ${{ startsWith('refs/tags/v', github.ref) }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ~1.16.4
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: release
on:
push:
tags:
- v[1-9].*
jobs:
ci-goreleaser:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ~1.16.4
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
services:
- docker
language: go
go:
- 1.16.x
branches:
only:
- master
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
- /^PR\d*$/
- /.*/
env:
global:
- REPO=cloudnativelabs/kube-router
- REPO_PATH=$HOME/gopath/src/github.com/$REPO
- GIT_BRANCH=$TRAVIS_BRANCH
script:
# All built commits get an image placed in the kube-router-git
# image repo and tagged with the commit hash.
- wget https://github.com/estesp/manifest-tool/releases/download/v1.0.2/manifest-tool-linux-amd64 -O manifest-tool && chmod +x manifest-tool
- build/travis-deploy.sh
# This fixes issues when a contributor uses their own Travis CI account to test
# code/CI changes.
before_install:
- mkdir -p $REPO_PATH
- rsync -az ${TRAVIS_BUILD_DIR}/ $REPO_PATH
- export TRAVIS_BUILD_DIR=$REPO_PATH
- cd $REPO_PATH
FROM golang:1.16.5-alpine3.14 as builder
ENV BUILD_IN_DOCKER=false
WORKDIR /build
COPY . /build
RUN apk add --no-cache make git \
&& make kube-router \
&& make gobgp
ARG ARCH=
FROM ${ARCH}alpine:3.14
......@@ -19,7 +28,7 @@ COPY build/image-assets/bashrc /root/.bashrc
COPY build/image-assets/profile /root/.profile
COPY build/image-assets/vimrc /root/.vimrc
COPY build/image-assets/motd-kube-router.sh /etc/motd-kube-router.sh
COPY kube-router gobgp /usr/local/bin/
COPY --from=builder /build/kube-router /build/gobgp /usr/local/bin/
# Use iptables-wrappers so that correct version of iptables-legacy or iptables-nft gets used. Alpine contains both, but
# which version is used should be based on the host system as well as where rules that may have been added before
......
......@@ -8,7 +8,7 @@ GIT_COMMIT=$(shell git describe --tags --dirty)
GIT_BRANCH?=$(shell git rev-parse --abbrev-ref HEAD)
IMG_TAG?=$(if $(IMG_TAG_PREFIX),$(IMG_TAG_PREFIX)-)$(if $(ARCH_TAG_PREFIX),$(ARCH_TAG_PREFIX)-)$(GIT_BRANCH)
MANIFEST_TAG?=$(if $(IMG_TAG_PREFIX),$(IMG_TAG_PREFIX)-)$(GIT_BRANCH)
RELEASE_TAG?=$(GOARCH)-$(shell build/get-git-tag.sh)
RELEASE_TAG?=$(GOARCH)-$(shell git describe --exact-match || echo -n)
REGISTRY?=$(if $(IMG_FQDN),$(IMG_FQDN)/$(IMG_NAMESPACE)/$(NAME),$(IMG_NAMESPACE)/$(NAME))
REGISTRY_DEV?=$(REGISTRY)$(DEV_SUFFIX)
IN_DOCKER_GROUP=$(filter docker,$(shell groups))
......@@ -17,7 +17,7 @@ DOCKER=$(if $(or $(IN_DOCKER_GROUP),$(IS_ROOT),$(OSX)),docker,sudo docker)
MAKEFILE_DIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
UPSTREAM_IMPORT_PATH=$(GOPATH)/src/github.com/cloudnativelabs/kube-router/
BUILD_IN_DOCKER?=true
DOCKER_BUILD_IMAGE?=golang:1.16.4-alpine3.12
DOCKER_BUILD_IMAGE?=golang:1.16.5-alpine3.14
DOCKER_LINT_IMAGE?=golangci/golangci-lint:v1.27.0
GOBGP_VERSION=v0.0.0-20210701110518-b284a8082ab4 # v2.29.0
QEMU_IMAGE?=multiarch/qemu-user-static
......@@ -180,42 +180,6 @@ else
go generate -v $(*).go
endif
gopath: ## Warns about issues building from a directory that does not match upstream.
@echo 'Checking project path for import issues...'
@echo '- Project dir: $(MAKEFILE_DIR)'
@echo '- Import dir: $(UPSTREAM_IMPORT_PATH)'
@echo
ifeq ($(MAKEFILE_DIR),$(UPSTREAM_IMPORT_PATH))
@echo 'Looks good!'
else
@echo 'The project directory does not match $(UPSTREAM_IMPORT_PATH)'
@echo
@echo 'This could cause build issues. Consider moving this project'
@echo 'directory to $(UPSTREAM_IMPORT_PATH) and work from there.'
@echo 'This could be done for you by running: "make gopath-fix".'
@echo
endif
# This fixes GOPATH issues for contributers using their own Travis-CI account
# with their forked kube-router repo. It's also useful for contributors testing
# code and CI changes with their own Travis account.
gopath-fix: ## Copies this project directory to the upstream import path.
ifneq ($(wildcard $(UPSTREAM_IMPORT_PATH)/.*),)
@echo
@echo '$(UPSTREAM_IMPORT_PATH) already exists.'
@echo 'Aborting gopath-fix.'
@echo
else
@echo
@echo 'Copying $(MAKEFILE_DIR) to $(UPSTREAM_IMPORT_PATH)'
@echo
mkdir -p "$(UPSTREAM_IMPORT_PATH)"
cp -ar $(MAKEFILE_DIR)/. "$(UPSTREAM_IMPORT_PATH)"
@echo
@echo 'Success! Please use $(UPSTREAM_IMPORT_PATH)'
@echo
endif
gobgp:
@echo Building gobgp
ifeq "$(BUILD_IN_DOCKER)" "true"
......@@ -238,6 +202,6 @@ help:
.PHONY: clean container run release goreleaser push gofmt gofmt-fix gomoqs
.PHONY: test lint docker-login push-manifest push-manifest-release
.PHONY: push-release github-release help gopath gopath-fix multiarch-binverify
.PHONY: push-release github-release help multiarch-binverify
.DEFAULT: all
![logo](https://cdn.rawgit.com/cloudnativelabs/kube-router/64f7700e/Documentation/img/logo-full.svg)
[![Build Status](https://travis-ci.org/cloudnativelabs/kube-router.svg?branch=master)](https://travis-ci.org/cloudnativelabs/kube-router)
[![Build Status](https://github.com/cloudnativelabs/kube-router/actions/workflows/ci.yml/badge.svg?branch=master)](https://travis-ci.org/cloudnativelabs/kube-router)
[![Slack](https://img.shields.io/badge/slack-join%20chat%20%E2%86%92-e01563.svg)](https://kubernetes.slack.com/messages/C8DCQGTSB/)
[![Docker Pulls kube-router](https://img.shields.io/docker/pulls/cloudnativelabs/kube-router.svg?label=docker+pulls)](https://hub.docker.com/r/cloudnativelabs/kube-router/)
[![](https://images.microbadger.com/badges/image/cloudnativelabs/kube-router.svg)](https://microbadger.com/images/cloudnativelabs/kube-router "Get your own image badge on microbadger.com")
......
# Process for creating a Kube-Router release
## Preparing for the release
* Ensure that the Golang release used is still supported.
* Ensure that the Alpine version used for containers is still supported
* Ensure that Golang dependencies are updated.
* Ensure that the GoBGP version is updated.
* Ensure that the Kubernetes object definitions do not contain deprecated object types.
## New major/minor release
* Create a new release on Github from the default branch (currently: master) with the release tag v$MAJOR.$MINOR.0
* Create a branch named v$MAJOR.$MINOR
## New patch release
* Create a new release on Github from the v$MAJOR.$MINOR release with the release tag v$MAJOR.$MINOR.$PATCH
A goreleaser command will be executed via Github Actions and it will add binaries to the release.
A docker buildx command will be executed via Github Actions and it will push new container builds to [DockerHub](https://hub.docker.com/repository/docker/cloudnativelabs/kube-router).
## After the release
* Announce the release in [#kube-router](https://app.slack.com/client/T09NY5SBT/C8DCQGTSB) on Kubernetes Slack.
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
git describe --exact-match || echo -n
# if [ -z "${RELEASE_TAG}" ]; then
# echo "Commit is not tagged. Release aborted."
# exit 1
# else
# echo "${RELEASE_TAG}"
# fi
#!/usr/bin/env bash
set -o errexit
set -o pipefail
GOARCHES=(amd64 arm64 arm s390x ppc64le)
make docker-login
# Pull Request image tag format: PR00
if [ "${TRAVIS_EVENT_TYPE}" = "pull_request" ]; then
PR_USER=$(echo "${TRAVIS_PULL_REQUEST_SLUG}" | sed -e 's/\/.*//')
if [ "${PR_USER}" != "cloudnativelabs" ]; then
echo "Not building/pushing PR ${TRAVIS_PULL_REQUEST} since only the cloudnativelabs user can access docker hub credentials"
exit 0
fi
echo "Building/pushing PR${TRAVIS_PULL_REQUEST} from ${PR_USER}"
for GOARCH in "${GOARCHES[@]}"; do
make push IMG_TAG="${GOARCH}-PR${TRAVIS_PULL_REQUEST}" GOARCH="${GOARCH}"
make clean IMG_TAG="${GOARCH}-PR${TRAVIS_PULL_REQUEST}" GOARCH="${GOARCH}"
done
echo "Pushing PR manifest on Travis"
make push-manifest MANIFEST_TAG="PR${TRAVIS_PULL_REQUEST}"
exit 0
fi
# Release image tag format: v0.0.0 and latest
if [ -n "${TRAVIS_TAG}" ]; then
echo "Running Release build on Travis"
for GOARCH in "${GOARCHES[@]}"; do
make push-release RELEASE_TAG="${GOARCH}-${TRAVIS_TAG}" GOARCH="${GOARCH}"
make clean RELEASE_TAG="${GOARCH}-${TRAVIS_TAG}" GOARCH="${GOARCH}"
done
echo "Pushing release manifest on Travis"
make push-manifest-release RELEASE_TAG="${TRAVIS_TAG}"
exit 0
fi
# Push image tag format: COMMIT
echo "Running push build on Travis"
for GOARCH in "${GOARCHES[@]}"; do
make push GOARCH="${GOARCH}"
make clean GOARCH="${GOARCH}"
done
echo "Pushing manifest on Travis"
make push-manifest
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment