Skip to content

Commit e2a645d

Browse files
committed
k8s: adding a helm chart
1 parent 52b0c29 commit e2a645d

24 files changed

+595
-97
lines changed

.envrc.example

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
22

3+
export LOCAL_REGISTRY="kuberift:5432"
4+
35
export GHCR_USER="me"
46
export GHCR_TOKEN="token"

.github/workflows/build.yml

+33-74
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
name: build
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
7-
84
workflow_call:
95

106
env:
117
CARGO_TERM_COLOR: always
128
RUST_BACKTRACE: 1
139
CARGO_INCREMENTAL: 0
1410
RUSTFLAGS: -D warnings
15-
IMAGE: ghcr.io/grampelberg/kuberift
16-
17-
concurrency:
18-
group: |-
19-
build-${{ github.event.pull_request.number || github.ref }}
20-
cancel-in-progress: true
2111

2212
jobs:
2313
binary:
@@ -67,26 +57,30 @@ jobs:
6757
path: kuberift*
6858
retention-days: 1
6959

70-
docker:
71-
runs-on: ${{ matrix.runner }}
72-
60+
# The state of include/exclude in matrices is tough because we want to add the
61+
# runner to the matrix based on arch. Calling a sub-workflow allows for
62+
# code-reuse without having to deal with that added complexity.
63+
docker-linux-amd64:
64+
uses: ./.github/workflows/docker.yml
7365
permissions:
7466
packages: write
67+
with:
68+
os: linux
69+
arch: amd64
70+
runner: ubuntu-latest
71+
72+
docker-linux-arm64:
73+
if: ${{ github.event_name != 'pull_request' }}
74+
uses: ./.github/workflows/docker.yml
75+
permissions:
76+
packages: write
77+
with:
78+
os: linux
79+
arch: arm64
80+
runner: buildjet-4vcpu-ubuntu-2204-arm
7581

76-
strategy:
77-
matrix:
78-
os: [linux]
79-
arch:
80-
- amd64
81-
# The emulated arm64 builds are painfully slow (90m last time). Skip them until we have dedicated linux-arm64 hardware.
82-
- arm64
83-
84-
include:
85-
- arch: amd64
86-
runner: ubuntu-latest
87-
88-
- arch: arm64
89-
runner: buildjet-4vcpu-ubuntu-2204-arm
82+
helm:
83+
runs-on: ubuntu-latest
9084

9185
steps:
9286
- uses: actions/checkout@v4
@@ -95,56 +89,21 @@ jobs:
9589

9690
- uses: taiki-e/install-action@v2
9791
with:
98-
tool: just,git-cliff
99-
- name: set version
100-
run: just set-version
101-
102-
- name: meta
103-
id: meta
104-
uses: docker/metadata-action@v5
105-
with:
106-
images: |
107-
${{ env.IMAGE }}
108-
tags: |
109-
type=ref,event=tag
110-
type=raw,value=unstable,enable={{is_default_branch}}
111-
type=sha
112-
113-
- name: buildx
114-
uses: docker/setup-buildx-action@v3
115-
116-
- name: login
117-
uses: docker/login-action@v3
92+
tool: git-cliff
93+
- uses: jdx/mise-action@v2
11894
with:
119-
registry: ghcr.io
120-
username: ${{ github.actor }}
121-
password: ${{ secrets.GITHUB_TOKEN }}
95+
experimental: true
96+
mise_toml: |
97+
[tools]
98+
helm = "latest"
99+
just = "latest"
122100
123-
- name: Build and push
124-
id: build
125-
uses: docker/build-push-action@v6
126-
with:
127-
context: .
128-
platforms: ${{ matrix.os }}/${{ matrix.arch }}
129-
cache-from: type=registry,ref=${{ env.IMAGE }}-cache
130-
cache-to: type=registry,ref=${{ env.IMAGE }}-cache,mode=max
131-
file: docker/kuberift.dockerfile
132-
labels: ${{ steps.meta.outputs.labels }}
133-
annotations: ${{ steps.meta.outputs.annotations }}
134-
push: ${{ github.event_name != 'pull_request' }}
135-
outputs: |-
136-
type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true
137-
138-
- name: create digest
101+
- name: helm
139102
run: |
140-
mkdir -p /tmp/digests
141-
digest="${{ steps.build.outputs.digest }}"
142-
touch "/tmp/digests/${digest#sha256:}"
103+
just set-version helm-build
143104
144-
- name: upload digest
145-
uses: actions/upload-artifact@v4
105+
- uses: actions/upload-artifact@v4
146106
with:
147-
name: digests-${{ matrix.os }}-${{ matrix.arch }}
148-
path: /tmp/digests/*
149-
if-no-files-found: error
107+
name: helm
108+
path: /tmp/chart/*
150109
retention-days: 1

.github/workflows/check.yml

-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: check
22

33
on:
4-
pull_request:
5-
branches: ['main']
6-
74
workflow_call:
85

96
env:
@@ -12,11 +9,6 @@ env:
129
CARGO_INCREMENTAL: 0
1310
RUSTFLAGS: -D warnings
1411

15-
concurrency:
16-
group: |-
17-
check-${{ github.event.pull_request.number || github.ref }}
18-
cancel-in-progress: true
19-
2012
jobs:
2113
lint:
2214
runs-on: ubuntu-latest

.github/workflows/docker.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: docker
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
description: 'Operating system to build for'
9+
default: 'linux'
10+
type: string
11+
arch:
12+
required: true
13+
description: 'Architecture to build for'
14+
default: 'amd64'
15+
type: string
16+
runner:
17+
required: true
18+
description: 'Runner to use'
19+
default: 'ubuntu-latest'
20+
type: string
21+
22+
env:
23+
CARGO_TERM_COLOR: always
24+
RUST_BACKTRACE: 1
25+
CARGO_INCREMENTAL: 0
26+
RUSTFLAGS: -D warnings
27+
IMAGE: ghcr.io/grampelberg/kuberift
28+
CACHE: ghcr.io/grampelberg/cache/kuberift
29+
30+
jobs:
31+
build:
32+
runs-on: ${{ inputs.runner }}
33+
34+
permissions:
35+
packages: write
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: tags
40+
run: git fetch --prune --unshallow --tags
41+
42+
- uses: taiki-e/install-action@v2
43+
with:
44+
tool: just,git-cliff
45+
- name: set version
46+
run: just set-version
47+
48+
- name: meta
49+
id: meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: |
53+
${{ env.IMAGE }}
54+
tags: |
55+
type=ref,event=tag
56+
type=raw,value=unstable,enable={{is_default_branch}}
57+
type=sha
58+
59+
- name: buildx
60+
uses: docker/setup-buildx-action@v3
61+
62+
- name: login
63+
uses: docker/login-action@v3
64+
with:
65+
registry: ghcr.io
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Build and push
70+
id: build
71+
uses: docker/build-push-action@v6
72+
with:
73+
context: .
74+
platforms: ${{ inputs.os }}/${{ inputs.arch }}
75+
cache-from: type=registry,ref=${{ env.CACHE }}
76+
cache-to: type=registry,ref=${{ env.CACHE }},mode=max
77+
file: docker/kuberift.dockerfile
78+
labels: ${{ steps.meta.outputs.labels }}
79+
annotations: ${{ steps.meta.outputs.annotations }}
80+
push: ${{ github.event_name != 'pull_request' }}
81+
outputs: |-
82+
type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true
83+
84+
- name: create digest
85+
run: |
86+
mkdir -p /tmp/digests
87+
digest="${{ steps.build.outputs.digest }}"
88+
touch "/tmp/digests/${digest#sha256:}"
89+
90+
- name: upload digest
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: digests-${{ inputs.os }}-${{ inputs.arch }}
94+
path: /tmp/digests/*
95+
if-no-files-found: error
96+
retention-days: 1

.github/workflows/pr.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: pr
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: |-
10+
build-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
check:
15+
uses: ./.github/workflows/check.yml
16+
17+
build:
18+
permissions:
19+
packages: write
20+
21+
uses: ./.github/workflows/build.yml

.github/workflows/release.yml

+35-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
merge:
2929
runs-on: ubuntu-latest
3030

31-
if: ${{ github.event_name != 'pull_request' }}
32-
3331
permissions:
3432
packages: write
3533

@@ -93,6 +91,35 @@ jobs:
9391
run: |
9492
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }}
9593
94+
helm:
95+
runs-on: ubuntu-latest
96+
needs:
97+
- build
98+
99+
permissions:
100+
packages: write
101+
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- uses: jdx/mise-action@v2
106+
with:
107+
experimental: true
108+
mise_toml: |
109+
[tools]
110+
helm = "latest"
111+
just = "latest"
112+
113+
- uses: actions/download-artifact@v4
114+
with:
115+
path: /tmp/chart
116+
name: helm
117+
118+
- name: upload
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
run: just helm-upload
122+
96123
release:
97124
runs-on: ubuntu-latest
98125
needs:
@@ -112,6 +139,11 @@ jobs:
112139
pattern: kuberift-*
113140
merge-multiple: true
114141

142+
- uses: actions/download-artifact@v4
143+
with:
144+
path: /tmp/chart
145+
name: helm
146+
115147
- uses: taiki-e/install-action@v2
116148
with:
117149
tool: git-cliff
@@ -137,3 +169,4 @@ jobs:
137169
tag_name: unstable
138170
files: |-
139171
/tmp/binaries/*
172+
/tmp/chart/*

.mise.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[tools]
2-
"cargo:cargo-audit" = "latest"
2+
"cargo:cargo-audit" = "0.20.0"
33
"cargo:cargo-binstall" = "1.7.4"
44
"cargo:cargo-outdated" = "0.15.0"
55
"npm:prettier" = "3.3.2"
66
"npm:prettier-plugin-toml" = "2.0.1"
77
just = "1.34.0"
8+
helm = "3.15.4"

DEVELOPMENT.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Development
2+
3+
## CI
4+
5+
On PR, CI produces a darwin-arm64 binary and helm chart. Click on any step from
6+
the PR and then `Summary` on the left sidebar to see the uploaded artifacts.
7+
Docker images are not currently build/uploaded on PR runs.
8+
9+
## Environment
10+
11+
Copy `.envrc.example` to `.envrc`. The `GHCR_TOKEN` is a [personal access
12+
token][pat] with permissions to `write:packages`. This is only required if you
13+
want to upload directly to github.
14+
15+
[pat]:
16+
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
17+
18+
## Cluster
19+
20+
We recommend using [k3d][k3d] to run a local cluster. To setup:
21+
22+
```bash
23+
k3d cluster create kuberift --registry-create kuberift:5432
24+
```
25+
26+
Next, you'll want to add the registry to your `/etc/hosts`:
27+
28+
```bash
29+
echo "127.0.0.1 kuberift" | sudo tee -a /etc/hosts
30+
```
31+
32+
When you run `just dev-push`, an image at `kuberift:5432/kuberift:latest` will
33+
be available to run inside the cluster.
34+
35+
[k3d]: https://k3d.io/v5.6.3/#releases

0 commit comments

Comments
 (0)