@@ -13,162 +13,105 @@ on:
1313jobs :
1414 build :
1515 name : Build
16- runs-on : ubuntu-22.04
16+ runs-on : ubuntu-latest
1717 steps :
18- - name : Checkout
19- uses : actions/checkout@v3
18+ - uses : actions/checkout@v6
2019 with :
20+ # needed for git describe --tags
2121 fetch-depth : 0
22- - name : Set up Go 1.20
23- id : go
24- uses : actions/setup-go@v2
25- with :
26- go-version : 1.20.4
27- - name : Set up Docker Buildx
28- id : buildx
29- uses : crazy-max/ghaction-docker-buildx@v1
22+ - uses : actions/setup-go@v6
3023 with :
31- buildx-version : latest
32- qemu-version : latest
33- - name : Login to GitHub Container Registry
34- uses : docker/login-action@v2
24+ go-version-file : ' go.mod'
25+ - uses : docker/setup-buildx-action@v3
26+ - uses : docker/login-action@v4
3527 with :
3628 registry : ghcr.io
3729 username : ${{ github.actor }}
3830 password : ${{ secrets.GITHUB_TOKEN }}
39- - name : Available platforms
40- run : echo ${{ steps.buildx.outputs.platforms }}
4131 - name : Build images
4232 run : |
4333 set -x
44- git fetch origin
4534 tag="$(git describe --tags)"
46- echo "building images..."
35+
36+ echo "Build controller image"
4737 go mod vendor
48- echo "docker build -t ghcr.io/kilnfi/carina:controller-${tag} . "
49- docker build -t "ghcr.io/kilnfi/carina:controller-${tag}" .
38+ docker build \
39+ --cache-from type=gha \
40+ --cache-to type=gha,mode=max \
41+ -t "ghcr.io/kilnfi/carina:controller-${tag}" .
42+
43+ echo "Build scheduler image"
5044 cd scheduler
5145 go mod vendor
52- echo "docker build -t ghcr.io/kilnfi/carina:scheduler-${tag} ."
53- docker build -t "ghcr.io/kilnfi/carina:scheduler-${tag}" .
46+ docker build \
47+ --cache-from type=gha \
48+ --cache-to type=gha,mode=max \
49+ -t "ghcr.io/kilnfi/carina:scheduler-${tag}" .
5450 # Interactive debug
55- # - name: Setup tmate session
56- # uses: mxschmitt/action-tmate@v3
57- # with:
58- # detached: true
51+ - name : Setup tmate session
52+ uses : mxschmitt/action-tmate@v3
53+ with :
54+ detached : true
55+ - name : Create KinD cluster
56+ if : github.ref_name != 'main'
57+ uses : helm/kind-action@v1.14.0
58+ with :
59+ cluster_name : kind
5960 - name : Test Kubernetes
60- if : github.ref != 'refs/heads/ main'
61+ if : github.ref_name != 'main'
6162 run : |
6263 set -x
63- exec 2>&1
64- git fetch origin
6564 tag="$(git describe --tags)"
65+ kind load docker-image "ghcr.io/kilnfi/carina:controller-${tag}" "ghcr.io/kilnfi/carina:scheduler-${tag}"
6666
67- # Cluster
68- curl -s -L -o k3s https://github.com/k3s-io/k3s/releases/download/v1.32.3%2Bk3s1/k3s
69- chmod +x k3s
70- sudo ./k3s server --disable coredns,servicelb,traefik,metrics-server --write-kubeconfig "$(pwd)/kubeconfig" --write-kubeconfig-mode 777 > k3s_log 2>&1 &
71- export KUBECONFIG="$(pwd)/kubeconfig"
72- # Wait init
73- while true; do ./k3s kubectl get deploy -n kube-system local-path-provisioner && break; sleep 5; done
74- docker save "ghcr.io/kilnfi/carina:scheduler-${tag}" "ghcr.io/kilnfi/carina:controller-${tag}" | sudo ./k3s ctr image import -
75-
76- # Debug output
77- debug() {
78- set +e
79- ./k3s kubectl get po -A
80- ./k3s kubectl get pvc -A
81- ./k3s kubectl get nodestorageresource -A -o yaml
82- ./k3s kubectl logs -n carina --tail=200 -l app.kubernetes.io/instance=carina-csi-driver --all-containers=true
83- ./k3s kubectl get po -n carina -o yaml > carina_pods_log 2>&1
84- ./k3s kubectl logs -n carina --tail=10000 -l app.kubernetes.io/instance=carina-csi-driver --all-containers=true > carina_log 2>&1
85- #tail -200 k3s_log
86- }
87- trap debug EXIT
88-
89- # Carina install
90- ./k3s kubectl create ns carina
91- sed -i -e 's/__TAG__/'"${tag}"'/' .github/kiln-values.yaml
92- helm upgrade --install -n carina carina-csi-driver charts/ -f .github/kiln-values.yaml
67+ # Install carina without a device first — we need the carina-node
68+ # daemonset running to create a fake block device inside it.
69+ sed -i -e "s/__TAG__/${tag}/" .github/kiln-values.yaml
70+ helm upgrade --install --create-namespace -n carina carina-csi-driver charts/ -f .github/kiln-values.yaml --wait --timeout=20m
9371
94- # Wait deploy
95- ./k3s kubectl rollout status -n carina --watch --timeout=200s ds/csi-carina-node
96- ./k3s kubectl wait po -n carina -l app=csi-carina-node --for=condition=ready --timeout=200s
72+ # Create a 12G loopback device inside carina-node to simulate a disk,
73+ # then re-install with the device configured and initialize LVM on it.
74+ kubectl wait pod -n carina -l app=csi-carina-node --for=condition=ready --timeout=120s
75+ device="$(kubectl exec -t -n carina ds/csi-carina-node -c csi-carina-node -- \
76+ sh -c 'truncate --size=12G /tmp/disk.device; losetup --show -f /tmp/disk.device')"
77+ sed -i -e "s/__DEVICE__/${device#/dev/}/" .github/kiln-values.yaml
78+ kubectl exec -t -n carina ds/csi-carina-node -c csi-carina-node -- \
79+ sh -c "pvcreate ${device}"
80+ helm upgrade --install -n carina carina-csi-driver charts/ -f .github/kiln-values.yaml --wait --timeout=200s
9781
98- # Update device
99- device=$(./k3s kubectl exec -t -n carina ds/csi-carina-node -c csi-carina-node -- sh -c 'truncate --size=12G /tmp/disk.device; losetup --show -f /tmp/disk.device')
100- sed -i -e 's/__DEVICE__/'"${device#/dev/}"'/' .github/kiln-values.yaml
101- helm upgrade --install -n carina carina-csi-driver charts/ -f .github/kiln-values.yaml
102-
103- # Refresh
104- sleep 60
105- ./k3s kubectl rollout restart -n carina deployment carina-csi-driver-carina-scheduler
106- ./k3s kubectl rollout restart -n carina deployment csi-carina-controller
107- ./k3s kubectl exec -t -n carina ds/csi-carina-node -c csi-carina-node -- sh -c 'pvcreate '"${device}"'; kill 1'
108-
109- # Test
110- helm test -n carina carina-csi-driver
111- ./k3s kubectl wait -n carina --for=jsonpath='{.status.phase}'=Bound pvc/carina-vg-ssd-testpvc --timeout=500s
112- ./k3s kubectl wait -n carina --for=condition=ready po -l storageclass=carina-vg-ssd --timeout=500s
113-
114-
115- # Test filter logging
116- ./k3s kubectl taint nodes -l node-role.kubernetes.io/control-plane=true test=off:NoSchedule
117- ./k3s kubectl delete po -n carina -l storageclass=carina-vg-ssd
118- sleep 30
119- grep "Filter plugin unsuccessfull on node" < <(./k3s kubectl logs -n carina --tail=10000 -l app.kubernetes.io/instance=carina-csi-driver --all-containers=true)
120- - name : ' Upload Artifact'
121- uses : actions/upload-artifact@v4
82+ # Run the helm test — creates a PVC and a pod that uses carina storage.
83+ helm test -n carina carina-csi-driver --timeout=500s
84+ - name : Waot
12285 if : always()
123- with :
124- name : k3s_log
125- path : k3s_log
126- retention-days : 5
127- - name : ' Upload Artifact'
128- uses : actions/upload-artifact@v4
129- if : always()
130- with :
131- name : carina_log
132- path : carina_log
133- retention-days : 5
134- - name : ' Upload Artifact'
135- uses : actions/upload-artifact@v4
136- if : always()
137- with :
138- name : carina_pods_log
139- path : carina_pods_log
140- retention-days : 5
86+ run : sleep 20m
14187 - name : Push image
142- if : github.ref == 'refs/heads/ main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
88+ if : github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
14389 run : |
14490 set -x
145- git fetch origin
14691 tag="$(git describe --tags)"
14792
14893 docker push "ghcr.io/kilnfi/carina:controller-${tag}"
14994 docker push "ghcr.io/kilnfi/carina:scheduler-${tag}"
15095
15196 helm :
15297 name : Helm chart
153- runs-on : ubuntu-22.04
98+ runs-on : ubuntu-latest
15499 steps :
155100 - name : Checkout
156- uses : actions/checkout@v3
101+ uses : actions/checkout@v6
157102 with :
103+ # needed for git describe --tags
158104 fetch-depth : 0
159- - name : Install Helm
160- uses : azure/setup-helm@v3
161105 - name : Login to GitHub Container Registry
162- uses : docker/login-action@v2
106+ uses : docker/login-action@v4
163107 with :
164108 registry : ghcr.io
165109 username : ${{ github.actor }}
166110 password : ${{ secrets.GITHUB_TOKEN }}
167111 - name : Push chart
168- if : github.ref == 'refs/heads/ main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
112+ if : github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
169113 run : |
170114 set -x
171- git fetch origin
172115 tag="$(git describe --tags)"
173116
174117 sed -i -r "s/^(appV|v)ersion *:.*$/\1ersion: $tag/" charts/Chart.yaml
0 commit comments