Skip to content

Commit 6de3c14

Browse files
authored
Merge pull request #1 from miscord-dev/impl-ctrl
Impl ctrl
2 parents fddb578 + 42edda5 commit 6de3c14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2714
-183
lines changed

.github/workflows/build.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags:
7+
- "v*.*.*"
8+
pull_request:
9+
10+
jobs:
11+
docker:
12+
runs-on: ubuntu-latest
13+
steps:
14+
-
15+
name: Checkout
16+
uses: actions/checkout@v3
17+
-
18+
name: Set up QEMU
19+
uses: docker/setup-qemu-action@v2
20+
-
21+
name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v2
23+
with:
24+
platforms: linux/amd64,linux/arm64
25+
-
26+
name: Login to Docker Hub
27+
uses: docker/login-action@v2
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.repository_owner }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
-
33+
name: Docker meta
34+
id: meta
35+
uses: docker/metadata-action@v4
36+
with:
37+
images: ghcr.io/${{ github.repository_owner }}/cluster-api-byoh-both
38+
tags: |
39+
type=schedule
40+
type=ref,event=branch
41+
type=ref,event=tag
42+
type=ref,event=pr
43+
type=sha
44+
-
45+
name: Cache Docker layers
46+
uses: actions/cache@v2
47+
with:
48+
path: /tmp/.buildx-cache
49+
key: ${{ runner.os }}-buildx-${{ github.sha }}
50+
restore-keys: |
51+
${{ runner.os }}-buildx-
52+
-
53+
name: Build and push
54+
uses: docker/build-push-action@v3
55+
with:
56+
context: .
57+
file: Dockerfile
58+
push: true
59+
platforms: linux/amd64,linux/arm64
60+
tags: ${{ steps.meta.outputs.tags }}
61+
cache-from: type=local,src=/tmp/.buildx-cache
62+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
63+
-
64+
# Temp fix
65+
# https://github.com/docker/build-push-action/issues/252
66+
# https://github.com/moby/buildkit/issues/1896
67+
name: Move cache
68+
run: |
69+
rm -rf /tmp/.buildx-cache
70+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

.github/workflows/bundle.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Bundle artifacts
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
imgpkg:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
versions:
14+
- k8s-version: 1.24.2
15+
containerd-version: 1.6.8
16+
cni-version: 1.2.0
17+
cri-version: 1.26.0
18+
oss:
19+
- tag: $KUBERNETES_VERSION-ubuntu-$ARCH
20+
arch: amd64
21+
dir: ubuntu/common
22+
- tag: $KUBERNETES_VERSION-ubuntu-$ARCH
23+
arch: arm64
24+
dir: ubuntu/common
25+
steps:
26+
-
27+
name: Checkout
28+
uses: actions/checkout@v3
29+
-
30+
name: Set up QEMU
31+
uses: docker/setup-qemu-action@v2
32+
-
33+
name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v2
35+
with:
36+
platforms: linux/${{ matrix.oss.arch }}
37+
- env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: |
40+
export IMGPKG_ACTIVE_KEYCHAINS=github
41+
curl -L https://carvel.dev/install.sh | K14SIO_INSTALL_BIN_DIR=/usr/local/bin bash
42+
43+
cd bundler
44+
export KUBERNETES_VERSION=${{ matrix.versions.k8s-version }}
45+
export CONTAINERD_VERSION=${{ matrix.versions.containerd-version }}
46+
export KUBERNETES_CNI_VERSION=${{ matrix.versions.cni-version }}
47+
export KUBERNETES_CRI_VERSION=${{ matrix.versions.cri-version }}
48+
export ARCH=${{ matrix.oss.arch }}
49+
50+
TAG=${{ matrix.oss.tag }}
51+
echo $TAG
52+
53+
if ${{ github.event_name == 'pull_request' }}; then
54+
TAG+="-pr-${{ github.event.pull_request.number }}"
55+
fi
56+
57+
./bundler.sh "${{ matrix.oss.dir }}" "$TAG"

.github/workflows/release.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const getVersion = () => {
2+
const byohVersion =
3+
(`${process.env.GITHUB_REF}`.match(/(v\d+\.\d+\.\d+)/) ?? [])[0];
4+
5+
return byohVersion;
6+
}
7+
8+
exports.release = async () => {
9+
await $`make release IMG=ghcr.io/miscord-dev/cluster-api-byoh-both:${getVersion()}`
10+
}

.github/workflows/release.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build images
2+
3+
on:
4+
pull_request:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
jobs:
10+
docker:
11+
runs-on: ubuntu-latest
12+
steps:
13+
-
14+
name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Release
17+
env:
18+
FORCE_COLOR: 3
19+
run: |
20+
npx zx <<'EOF'
21+
const script = require('./.github/workflows/release.js').release
22+
script().then(result => {
23+
console.log(result)
24+
}).catch(err => {
25+
throw err
26+
})
27+
EOF
28+
-
29+
name: Publish Release
30+
uses: softprops/action-gh-release@v1
31+
if: startsWith(github.ref, 'refs/tags/')
32+
with:
33+
draft: true
34+
generate_release_notes: true
35+
files: |
36+
dist/components.yaml
37+
templates/clusterclass-quickstart.yaml

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ Dockerfile.cross
2424
*.swp
2525
*.swo
2626
*~
27+
28+
tmp/
29+
dist/

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.19 as builder
3-
ARG TARGETOS
2+
FROM --platform=$BUILDPLATFORM golang:1.19 as builder
43
ARG TARGETARCH
54

65
WORKDIR /workspace
@@ -14,14 +13,15 @@ RUN go mod download
1413
# Copy the go source
1514
COPY main.go main.go
1615
COPY api/ api/
16+
COPY pkg/ pkg/
1717
COPY controllers/ controllers/
1818

1919
# Build
2020
# the GOARCH has not a default value to allow the binary be built according to the host where the command
2121
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
2222
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2323
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
24-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
24+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -a -o manager main.go
2525

2626
# Use distroless as minimal base image to package the manager binary
2727
# Refer to https://github.com/GoogleContainerTools/distroless for more details

0 commit comments

Comments
 (0)