Skip to content

Commit 662c8e6

Browse files
2 parents f862385 + b4b231f commit 662c8e6

23 files changed

+1441
-805
lines changed

.dockerignore

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 112 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@ on:
1212
- master
1313
- v[1-9].*
1414

15+
env:
16+
BUILDTIME_BASE: "golang:1.16.7-alpine3.14"
17+
RUNTIME_BASE: "alpine:3.14"
18+
GO_VERSION: "~1.16.7"
19+
1520
jobs:
21+
# Runs Golangci-lint on the source code
1622
ci-go-lint:
1723
name: ci-go-lint
1824
runs-on: ubuntu-latest
1925
steps:
2026
- name: Set up Go 1.x
2127
uses: actions/setup-go@v2
2228
with:
23-
go-version: ~1.16.4
29+
go-version: ${{ env.GO_VERSION }}
2430
id: go
2531

2632
- name: Check out code into the Go module directory
@@ -30,14 +36,15 @@ jobs:
3036
run: |
3137
make lint
3238
39+
# Executes Unit Tests
3340
ci-unit-tests:
3441
name: ci-unit-tests
3542
runs-on: ubuntu-latest
3643
steps:
3744
- name: Set up Go 1.x
3845
uses: actions/setup-go@v2
3946
with:
40-
go-version: ~1.16.4
47+
go-version: ${{ env.GO_VERSION }}
4148
id: go
4249

4350
- name: Check out code into the Go module directory
@@ -46,15 +53,18 @@ jobs:
4653
- name: Run unit tests for kube-router
4754
run: |
4855
make test
56+
env:
57+
DOCKER_BUILD_IMAGE: ${{ env.BUILDTIME_BASE }}
4958

59+
# Builds Kube-Router binary
5060
ci-build-kube-router:
5161
name: ci-build-kube-router
5262
runs-on: ubuntu-latest
5363
steps:
5464
- name: Set up Go 1.x
5565
uses: actions/setup-go@v2
5666
with:
57-
go-version: ~1.16.4
67+
go-version: ${{ env.GO_VERSION }}
5868
id: go
5969

6070
- name: Check out code into the Go module directory
@@ -63,3 +73,102 @@ jobs:
6373
- name: Build kube-router
6474
run: |
6575
make kube-router
76+
77+
# Builds Container only if a new push to main branch, a tag or a pull request from a source branch within the repository
78+
ci-build-container:
79+
runs-on: ubuntu-latest
80+
if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@v2
84+
85+
- name: Set up QEMU
86+
uses: docker/setup-qemu-action@v1
87+
88+
- name: Set up Docker Buildx
89+
uses: docker/setup-buildx-action@v1
90+
91+
- name: Login to DockerHub
92+
uses: docker/login-action@v1
93+
with:
94+
username: ${{ secrets.DOCKERHUB_USERNAME }}
95+
password: ${{ secrets.DOCKERHUB_TOKEN }}
96+
97+
- name: Extract branch from github ref - New Push
98+
if: ${{ startsWith(github.ref, 'refs/tags/v') != true && github.event_name != 'pull_request' }}
99+
shell: bash
100+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
101+
id: extract_branch
102+
103+
- name: Extract tag from github ref - New Release
104+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
105+
shell: bash
106+
run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/})"
107+
id: extract_tag
108+
109+
- name: Build and push - New Push
110+
uses: docker/build-push-action@v2
111+
if: ${{ startsWith(github.ref, 'refs/tags/v') != true && github.event_name != 'pull_request' }}
112+
with:
113+
context: .
114+
platforms: |
115+
linux/amd64
116+
linux/arm64
117+
linux/arm/v7
118+
push: true
119+
build-args: |
120+
BUILDTIME_BASE=${{ env.BUILDTIME_BASE }}
121+
RUNTIME_BASE=${{ env.RUNTIME_BASE }}
122+
tags: cloudnativelabs/kube-router-git:${{ steps.extract_branch.outputs.branch }}
123+
124+
- name: Build and push - New PR
125+
uses: docker/build-push-action@v2
126+
if: github.event_name == 'pull_request'
127+
with:
128+
context: .
129+
# Don't build multi arch images for PR as they take more than 30 min to build
130+
platforms: linux/amd64
131+
push: true
132+
build-args: |
133+
BUILDTIME_BASE=${{ env.BUILDTIME_BASE }}
134+
RUNTIME_BASE=${{ env.RUNTIME_BASE }}
135+
tags: cloudnativelabs/kube-router-git:PR-${{ github.event.pull_request.number }}
136+
137+
- name: Build and push - New Tag
138+
uses: docker/build-push-action@v2
139+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
140+
with:
141+
context: .
142+
platforms: |
143+
linux/amd64
144+
linux/arm64
145+
linux/arm/v7
146+
push: true
147+
build-args: |
148+
BUILDTIME_BASE=${{ env.BUILDTIME_BASE }}
149+
RUNTIME_BASE=${{ env.RUNTIME_BASE }}
150+
tags: |
151+
cloudnativelabs/kube-router:${{ steps.extract_tag.outputs.tag }}
152+
cloudnativelabs/kube-router:latest
153+
154+
# Runs Go Releaser on Tag Event
155+
ci-goreleaser-tag:
156+
runs-on: ubuntu-latest
157+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
158+
steps:
159+
- name: Set up Go 1.x
160+
uses: actions/setup-go@v2
161+
with:
162+
go-version: ${{ env.GO_VERSION }}
163+
id: go
164+
165+
- name: Check out code into the Go module directory
166+
uses: actions/checkout@v2
167+
168+
- name: Run GoReleaser
169+
uses: goreleaser/goreleaser-action@v2
170+
with:
171+
version: latest
172+
args: release --rm-dist
173+
env:
174+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

Dockerfile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
ARG ARCH=
2-
FROM ${ARCH}alpine:3.12
1+
ARG BUILDTIME_BASE=golang:1-alpine
2+
ARG RUNTIME_BASE=alpine:latest
3+
FROM ${BUILDTIME_BASE} as builder
4+
ENV BUILD_IN_DOCKER=false
5+
6+
WORKDIR /build
7+
COPY . /build
8+
RUN apk add --no-cache make git \
9+
&& make kube-router \
10+
&& make gobgp
11+
12+
FROM ${RUNTIME_BASE}
313

414
RUN apk add --no-cache \
515
iptables \
@@ -19,7 +29,7 @@ COPY build/image-assets/bashrc /root/.bashrc
1929
COPY build/image-assets/profile /root/.profile
2030
COPY build/image-assets/vimrc /root/.vimrc
2131
COPY build/image-assets/motd-kube-router.sh /etc/motd-kube-router.sh
22-
COPY kube-router gobgp /usr/local/bin/
32+
COPY --from=builder /build/kube-router /build/gobgp /usr/local/bin/
2333

2434
# Use iptables-wrappers so that correct version of iptables-legacy or iptables-nft gets used. Alpine contains both, but
2535
# which version is used should be based on the host system as well as where rules that may have been added before

Makefile

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GIT_COMMIT=$(shell git describe --tags --dirty)
88
GIT_BRANCH?=$(shell git rev-parse --abbrev-ref HEAD)
99
IMG_TAG?=$(if $(IMG_TAG_PREFIX),$(IMG_TAG_PREFIX)-)$(if $(ARCH_TAG_PREFIX),$(ARCH_TAG_PREFIX)-)$(GIT_BRANCH)
1010
MANIFEST_TAG?=$(if $(IMG_TAG_PREFIX),$(IMG_TAG_PREFIX)-)$(GIT_BRANCH)
11-
RELEASE_TAG?=$(GOARCH)-$(shell build/get-git-tag.sh)
11+
RELEASE_TAG?=$(GOARCH)-$(shell git describe --exact-match || echo -n)
1212
REGISTRY?=$(if $(IMG_FQDN),$(IMG_FQDN)/$(IMG_NAMESPACE)/$(NAME),$(IMG_NAMESPACE)/$(NAME))
1313
REGISTRY_DEV?=$(REGISTRY)$(DEV_SUFFIX)
1414
IN_DOCKER_GROUP=$(filter docker,$(shell groups))
@@ -17,9 +17,9 @@ DOCKER=$(if $(or $(IN_DOCKER_GROUP),$(IS_ROOT),$(OSX)),docker,sudo docker)
1717
MAKEFILE_DIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
1818
UPSTREAM_IMPORT_PATH=$(GOPATH)/src/github.com/cloudnativelabs/kube-router/
1919
BUILD_IN_DOCKER?=true
20-
DOCKER_BUILD_IMAGE?=golang:1.16.4-alpine3.12
20+
DOCKER_BUILD_IMAGE?=golang:1.16.7-alpine3.14
2121
DOCKER_LINT_IMAGE?=golangci/golangci-lint:v1.27.0
22-
GOBGP_VERSION=v0.0.0-20210503121111-d1a8400dc698 # v2.27.0
22+
GOBGP_VERSION= v0.0.0-20210901090119-8ab84f8636ee # v2.31.0
2323
QEMU_IMAGE?=multiarch/qemu-user-static
2424
GORELEASER_VERSION=v0.162.1
2525
MOQ_VERSION=v0.2.1
@@ -180,42 +180,6 @@ else
180180
go generate -v $(*).go
181181
endif
182182

183-
gopath: ## Warns about issues building from a directory that does not match upstream.
184-
@echo 'Checking project path for import issues...'
185-
@echo '- Project dir: $(MAKEFILE_DIR)'
186-
@echo '- Import dir: $(UPSTREAM_IMPORT_PATH)'
187-
@echo
188-
ifeq ($(MAKEFILE_DIR),$(UPSTREAM_IMPORT_PATH))
189-
@echo 'Looks good!'
190-
else
191-
@echo 'The project directory does not match $(UPSTREAM_IMPORT_PATH)'
192-
@echo
193-
@echo 'This could cause build issues. Consider moving this project'
194-
@echo 'directory to $(UPSTREAM_IMPORT_PATH) and work from there.'
195-
@echo 'This could be done for you by running: "make gopath-fix".'
196-
@echo
197-
endif
198-
199-
# This fixes GOPATH issues for contributers using their own Travis-CI account
200-
# with their forked kube-router repo. It's also useful for contributors testing
201-
# code and CI changes with their own Travis account.
202-
gopath-fix: ## Copies this project directory to the upstream import path.
203-
ifneq ($(wildcard $(UPSTREAM_IMPORT_PATH)/.*),)
204-
@echo
205-
@echo '$(UPSTREAM_IMPORT_PATH) already exists.'
206-
@echo 'Aborting gopath-fix.'
207-
@echo
208-
else
209-
@echo
210-
@echo 'Copying $(MAKEFILE_DIR) to $(UPSTREAM_IMPORT_PATH)'
211-
@echo
212-
mkdir -p "$(UPSTREAM_IMPORT_PATH)"
213-
cp -ar $(MAKEFILE_DIR)/. "$(UPSTREAM_IMPORT_PATH)"
214-
@echo
215-
@echo 'Success! Please use $(UPSTREAM_IMPORT_PATH)'
216-
@echo
217-
endif
218-
219183
gobgp:
220184
@echo Building gobgp
221185
ifeq "$(BUILD_IN_DOCKER)" "true"
@@ -238,6 +202,6 @@ help:
238202

239203
.PHONY: clean container run release goreleaser push gofmt gofmt-fix gomoqs
240204
.PHONY: test lint docker-login push-manifest push-manifest-release
241-
.PHONY: push-release github-release help gopath gopath-fix multiarch-binverify
205+
.PHONY: push-release github-release help multiarch-binverify
242206

243207
.DEFAULT: all

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![logo](https://cdn.rawgit.com/cloudnativelabs/kube-router/64f7700e/Documentation/img/logo-full.svg)
22

3-
[![Build Status](https://travis-ci.org/cloudnativelabs/kube-router.svg?branch=master)](https://travis-ci.org/cloudnativelabs/kube-router)
3+
[![Build Status](https://github.com/cloudnativelabs/kube-router/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/cloudnativelabs/kube-router/actions/workflows/ci.yml?query=branch%3Amaster)
44
[![Slack](https://img.shields.io/badge/slack-join%20chat%20%E2%86%92-e01563.svg)](https://kubernetes.slack.com/messages/C8DCQGTSB/)
55
[![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/)
66
[![](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")

RELEASE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Process for creating a Kube-Router release
2+
3+
## Preparing for the release
4+
* Ensure that the Golang release used is still supported. Definition happens currently in [Github Workflow](.github/workflow/ci.yml).
5+
* Ensure that the Alpine version used in container builds is still supported. Definition happens currently in [Github Workflow](.github/workflow/ci.yml).
6+
* Ensure that Golang dependencies are updated. `go list -mod=mod -u -m -f '{{.}}{{if .Indirect}} IAMINDIRECT{{end}}' all | grep -v IAMINDIRECT` lists possible updates.
7+
* Ensure that the GoBGP version is updated. See [upstream](https://github.com/osrg/gobgp/releases) and GoBGP definition in [Makefile](Makefile) and [go.mod](go.mod).
8+
* Ensure that the Kubernetes object definitions do not contain deprecated object types. Definition currently is in kube-router's [Daemonset](daemonset) folder.
9+
10+
## New major/minor release
11+
* Create a branch named v$MAJOR.$MINOR from the default branch (currently: master)
12+
* Create a new prerelease on Github with the release tag v$MAJOR.$MINOR.0
13+
14+
## New patch release
15+
* Create a new prerelease on Github from the v$MAJOR.$MINOR release branch with the release tag v$MAJOR.$MINOR.$PATCH
16+
17+
A goreleaser command will be executed via Github Actions and it will add binaries to the release.
18+
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).
19+
20+
## After the release
21+
* Mark the draft release as a proper release.
22+
* Announce the release in [#kube-router](https://app.slack.com/client/T09NY5SBT/C8DCQGTSB) on Kubernetes Slack.

build/get-git-tag.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)