Skip to content

Commit eccde82

Browse files
committed
Various improvements
- ugprade CSI components - separate Helm job into its own workflow that only runs if necessary - pull the Go modules directly from the Dockerfile - add missing tools in container image
1 parent fd62d40 commit eccde82

8 files changed

Lines changed: 133 additions & 167 deletions

File tree

.github/kiln-values.yaml

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

.github/workflows/ci.yaml

Lines changed: 36 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ on:
55
pull_request:
66
branches:
77
- main
8+
paths-ignore:
9+
- 'charts/**'
810
push:
911
branches:
1012
- main
13+
paths-ignore:
14+
- 'charts/**'
1115

1216
permissions:
1317
contents: read
@@ -22,39 +26,38 @@ jobs:
2226
with:
2327
# needed for git describe --tags
2428
fetch-depth: 0
25-
- uses: actions/setup-go@v6
26-
with:
27-
go-version-file: 'go.mod'
2829
- uses: docker/setup-buildx-action@v4
2930
- uses: docker/login-action@v4
3031
with:
3132
registry: ghcr.io
3233
username: ${{ github.actor }}
3334
password: ${{ secrets.GITHUB_TOKEN }}
34-
- name: Build images
35-
run: |
36-
set -x
37-
tag="$(git describe --tags)"
38-
39-
echo "Building controller image"
40-
go mod vendor
41-
docker build \
42-
--cache-from type=gha \
43-
--cache-to type=gha,mode=max \
44-
-t "ghcr.io/kilnfi/carina:controller-${tag}" .
45-
46-
echo "Building scheduler image"
47-
cd scheduler
48-
go mod vendor
49-
docker build \
50-
--cache-from type=gha \
51-
--cache-to type=gha,mode=max \
52-
-t "ghcr.io/kilnfi/carina:scheduler-${tag}" .
53-
# # Interactive debug
54-
# - name: Setup tmate session
55-
# uses: mxschmitt/action-tmate@v3
56-
# with:
57-
# detached: true
35+
- name: Compute tag
36+
id: tag
37+
run: echo "value=$(git describe --tags)" >> "$GITHUB_OUTPUT"
38+
- name: Build and push controller image
39+
uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
load: true
43+
push: ${{ github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
44+
tags: ghcr.io/kilnfi/carina:controller-${{ steps.tag.outputs.value }}
45+
cache-from: type=gha,scope=controller
46+
cache-to: type=gha,mode=max,scope=controller
47+
- name: Build and push scheduler image
48+
uses: docker/build-push-action@v6
49+
with:
50+
context: ./scheduler
51+
load: true
52+
push: ${{ github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
53+
tags: ghcr.io/kilnfi/carina:scheduler-${{ steps.tag.outputs.value }}
54+
cache-from: type=gha,scope=scheduler
55+
cache-to: type=gha,mode=max,scope=scheduler
56+
# Interactive debug
57+
- name: Setup tmate session
58+
uses: mxschmitt/action-tmate@v3
59+
with:
60+
detached: true
5861
- name: Create KinD cluster
5962
if: github.ref_name != 'main'
6063
uses: helm/kind-action@v1
@@ -63,57 +66,16 @@ jobs:
6366
- name: Test Kubernetes
6467
if: github.ref_name != 'main'
6568
run: |
66-
set -x
67-
tag="$(git describe --tags)"
69+
set -eu -o pipefail -x
70+
tag="${{ steps.tag.outputs.value }}"
6871
kind load docker-image "ghcr.io/kilnfi/carina:controller-${tag}" "ghcr.io/kilnfi/carina:scheduler-${tag}"
6972
70-
# Install carina without a device first — we need the carina-node
71-
# daemonset running to create a fake block device inside it.
72-
sed -i -e "s/__TAG__/${tag}/" .github/kiln-values.yaml
73-
helm upgrade --install --create-namespace -n carina -f .github/kiln-values.yaml --wait carina-csi-driver charts/
73+
helm install --create-namespace -n carina --set carina-scheduler.tag="${tag}" --set image.carina.tag="${tag}" --hide-notes --wait carina-csi-driver charts/
7474
75-
# Create a 50G loopback device inside carina-node to simulate a disk,
76-
# then re-install with the device configured and initialize LVM on it.
75+
# Create a 50G loopback device inside carina-node to simulate a disk
7776
kubectl wait pod -n carina -l app=csi-carina-node --for=condition=ready --timeout=120s
78-
device="$(kubectl exec -t -n carina ds/csi-carina-node -c csi-carina-node -- \
79-
sh -c 'truncate -s 50G /tmp/disk.device; losetup --show -f /tmp/disk.device')"
80-
sed -i -e "s/__DEVICE__/${device#/dev/}/" .github/kiln-values.yaml
81-
kubectl exec -t -n carina ds/csi-carina-node -c csi-carina-node -- \
82-
sh -c "pvcreate ${device}"
83-
helm upgrade --install -n carina --hide-notes -f .github/kiln-values.yaml --wait carina-csi-driver charts/
77+
kubectl exec -t -n carina -c csi-carina-node ds/csi-carina-node -- sh -c "truncate -s 50G /tmp/disk.device && losetup /dev/loop2 /tmp/disk.device && pvcreate /dev/loop2"
78+
sleep 30s
8479
8580
# Run the helm test — creates a PVC and a pod that uses carina storage.
8681
helm test -n carina --hide-notes carina-csi-driver
87-
- name: Push image
88-
if: github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
89-
run: |
90-
set -x
91-
tag="$(git describe --tags)"
92-
93-
docker push "ghcr.io/kilnfi/carina:controller-${tag}"
94-
docker push "ghcr.io/kilnfi/carina:scheduler-${tag}"
95-
96-
helm:
97-
name: Helm chart
98-
runs-on: ubuntu-latest
99-
steps:
100-
- name: Checkout
101-
uses: actions/checkout@v6
102-
with:
103-
# needed for git describe --tags
104-
fetch-depth: 0
105-
- name: Login to GitHub Container Registry
106-
uses: docker/login-action@v4
107-
with:
108-
registry: ghcr.io
109-
username: ${{ github.actor }}
110-
password: ${{ secrets.GITHUB_TOKEN }}
111-
- name: Push chart
112-
if: github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
113-
run: |
114-
set -x
115-
tag="$(git describe --tags)"
116-
117-
sed -i -r "s/^(appV|v)ersion *:.*$/\1ersion: $tag/" charts/Chart.yaml
118-
helm package charts --version "${tag}"
119-
HELM_EXPERIMENTAL_OCI=1 helm push "carina-csi-driver-${tag}.tgz" "oci://ghcr.io/kilnfi/helm-charts"

.github/workflows/helm.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Helm chart
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
paths:
9+
- 'charts/**'
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- 'charts/**'
15+
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
jobs:
21+
helm:
22+
name: Push Helm chart
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v6
26+
with:
27+
fetch-depth: 0
28+
- uses: docker/login-action@v4
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Push chart
34+
if: github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
35+
run: |
36+
set -eu -o pipefail -x
37+
tag="$(git describe --tags)"
38+
sed -i -r "s/^(appV|v)ersion *:.*$/\1ersion: $tag/" charts/Chart.yaml
39+
helm package charts
40+
helm push "carina-csi-driver-${tag}.tgz" "oci://ghcr.io/kilnfi/helm-charts"

Dockerfile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
# Build the manager binary
22
FROM golang:1.26 AS builder
33

4-
ENV WORKSPACE=/workspace/github.com/carina-io/carina
5-
ENV GOMODCACHE=$WORKSPACE/vendor
4+
WORKDIR /workspace
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
COPY . .
68

7-
WORKDIR $WORKSPACE
8-
ADD . .
9-
10-
# Build
11-
RUN echo Commit: `git log --pretty='%s%b%B' -n 1`
12-
RUN cd $WORKSPACE/cmd/carina-node && CGO_ENABLED=0 go build -ldflags="-X main.gitCommitID=`git rev-parse HEAD`" -gcflags '-N -l' -o /tmp/carina-node .
13-
RUN cd $WORKSPACE/cmd/carina-controller && CGO_ENABLED=0 go build -ldflags="-X main.gitCommitID=`git rev-parse HEAD`" -gcflags '-N -l' -o /tmp/carina-controller .
9+
RUN cd cmd/carina-node && CGO_ENABLED=0 go build -o /tmp/carina-node .
10+
RUN cd cmd/carina-controller && CGO_ENABLED=0 go build -o /tmp/carina-controller .
1411

1512
FROM alpine:3.20
1613

17-
RUN apk add --no-cache lvm2 device-mapper e2fsprogs xfsprogs util-linux parted
14+
RUN apk add --no-cache bash bcache-tools device-mapper e2fsprogs eudev lvm2 parted thin-provisioning-tools util-linux xfsprogs
1815

1916
COPY --from=builder /tmp/carina-node /usr/bin/
2017
COPY --from=builder /tmp/carina-controller /usr/bin/
21-
COPY --from=builder /workspace/github.com/carina-io/carina/debug/hack/config.json /etc/carina/
18+
COPY --from=builder /workspace/debug/hack/config.json /etc/carina/
2219

23-
CMD ["echo", "carina-node", "carina-controller"]
20+
CMD ["carina-controller"]

charts/values.yaml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
carina-scheduler:
22
enabled: true
33
image:
4-
repository: registry.cn-hangzhou.aliyuncs.com/carina/carina-scheduler
5-
pullPolicy: IfNotPresent
4+
repository: ghcr.io/kilnfi/carina
65
# Overrides the image tag whose default is the chart appVersion.
7-
tag: "v0.11.0"
6+
tag: ""
7+
pullPolicy: IfNotPresent
88
# Default values for carina-csi-driver.
99
# This is a YAML-formatted file.
1010
# Declare variables to be passed into your templates.
1111
image:
12-
baseRepo: registry.cn-hangzhou.aliyuncs.com/carina
1312
carina:
14-
repository: /carina
15-
tag: v0.11.0
13+
repository: ghcr.io/kilnfi/carina
14+
tag: ""
1615
pullPolicy: IfNotPresent
1716
livenessProbe:
18-
repository: /livenessprobe
19-
tag: v2.7.0
17+
repository: registry.k8s.io/sig-storage/livenessprobe
18+
tag: v2.18.0
2019
pullPolicy: IfNotPresent
2120
csiProvisioner:
22-
repository: /csi-provisioner
23-
tag: v2.2.2
21+
repository: registry.k8s.io/sig-storage/csi-provisioner
22+
tag: v6.2.0
2423
pullPolicy: IfNotPresent
2524
csiResizer:
26-
repository: /csi-resizer
27-
tag: v1.5.0
25+
repository: registry.k8s.io/sig-storage/csi-resizer
26+
tag: v2.1.0
2827
pullPolicy: IfNotPresent
2928
nodeDriverRegistrar:
30-
repository: /csi-node-driver-registrar
31-
tag: v2.5.1
29+
repository: registry.k8s.io/sig-storage/csi-node-driver-registrar
30+
tag: v2.16.0
3231
pullPolicy: IfNotPresent
3332
nodeInitImage:
34-
repository: /busybox
35-
tag: "1.28"
33+
repository: busybox
34+
tag: stable
3635
pullPolicy: IfNotPresent
3736

3837
serviceAccount:

cmd/carina-controller/main.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,27 @@
1616
package main
1717

1818
import (
19+
"runtime/debug"
20+
1921
"github.com/carina-io/carina/cmd/carina-controller/run"
2022
"github.com/carina-io/carina/utils/log"
2123
)
2224

23-
var gitCommitID = "dev"
24-
2525
func main() {
26-
printWelcome()
26+
printBuildInfo()
2727
run.Execute()
2828
}
2929

30-
func printWelcome() {
31-
if gitCommitID == "" {
32-
gitCommitID = "dev"
30+
func printBuildInfo() {
31+
commit := "unknown"
32+
if info, ok := debug.ReadBuildInfo(); ok {
33+
for _, s := range info.Settings {
34+
if s.Key == "vcs.revision" {
35+
commit = s.Value
36+
}
37+
}
3338
}
3439
log.Info("-------- Welcome to use Carina Controller Server --------")
35-
log.Infof("Git Commit ID : %s", gitCommitID)
40+
log.Infof("Git Commit : %s", commit)
3641
log.Info("------------------------------------")
3742
}

cmd/carina-node/main.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,29 @@
1616
package main
1717

1818
import (
19+
"os"
20+
"runtime/debug"
21+
1922
"github.com/carina-io/carina/cmd/carina-node/run"
2023
"github.com/carina-io/carina/utils/log"
21-
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
22-
"os"
2324
)
2425

25-
var gitCommitID = "dev"
26-
2726
func main() {
28-
printWelcome()
27+
printBuildInfo()
2928
run.Execute()
3029
}
3130

32-
func printWelcome() {
33-
if gitCommitID == "" {
34-
gitCommitID = "dev"
31+
func printBuildInfo() {
32+
commit := "unknown"
33+
if info, ok := debug.ReadBuildInfo(); ok {
34+
for _, s := range info.Settings {
35+
if s.Key == "vcs.revision" {
36+
commit = s.Value
37+
}
38+
}
3539
}
3640
log.Info("-------- Welcome to use Carina Node Server --------")
37-
log.Infof("Git Commit ID : %s", gitCommitID)
41+
log.Infof("Git Commit : %s", commit)
3842
log.Infof("node name : %s", os.Getenv("NODE_NAME"))
3943
log.Info("------------------------------------")
4044
}

0 commit comments

Comments
 (0)