Skip to content

Commit 26b6cd5

Browse files
authored
Merge pull request #9 from kilnfi/k1.35
Support Kubernetes 1.35
2 parents e0a0301 + d110c45 commit 26b6cd5

File tree

27 files changed

+858
-1103
lines changed

27 files changed

+858
-1103
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.git/
2+
.github/
3+
charts/
4+
docs/
5+
test/
6+
vendor/

.github/kiln-values.yaml

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

.github/workflows/ci.yaml

Lines changed: 0 additions & 176 deletions
This file was deleted.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Container images
2+
3+
on:
4+
release:
5+
types: [published]
6+
pull_request:
7+
branches:
8+
- main
9+
paths-ignore:
10+
- 'charts/**'
11+
push:
12+
branches:
13+
- main
14+
paths-ignore:
15+
- 'charts/**'
16+
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v6
30+
- uses: docker/setup-buildx-action@v4
31+
- uses: docker/login-action@v4
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Controller image metadata
37+
id: controller-meta
38+
uses: docker/metadata-action@v6
39+
with:
40+
images: ghcr.io/kilnfi/carina
41+
tags: |
42+
type=semver,pattern=controller-{{version}}
43+
type=ref,event=pr,prefix=controller-pr-
44+
- name: Build and push controller image
45+
uses: docker/build-push-action@v6
46+
with:
47+
context: .
48+
load: true
49+
push: ${{ github.event_name == 'release' }}
50+
tags: ${{ steps.controller-meta.outputs.tags }}
51+
labels: ${{ steps.controller-meta.outputs.labels }}
52+
cache-from: type=gha,scope=controller
53+
cache-to: type=gha,mode=max,scope=controller
54+
- name: Scheduler image metadata
55+
id: scheduler-meta
56+
uses: docker/metadata-action@v6
57+
with:
58+
images: ghcr.io/kilnfi/carina
59+
tags: |
60+
type=semver,pattern=scheduler-{{version}}
61+
type=ref,event=pr,prefix=scheduler-pr-
62+
- name: Build and push scheduler image
63+
uses: docker/build-push-action@v6
64+
with:
65+
context: ./scheduler
66+
load: true
67+
push: ${{ github.event_name == 'release' }}
68+
tags: ${{ steps.scheduler-meta.outputs.tags }}
69+
labels: ${{ steps.scheduler-meta.outputs.labels }}
70+
cache-from: type=gha,scope=scheduler
71+
cache-to: type=gha,mode=max,scope=scheduler
72+
- name: Create KinD cluster
73+
if: ${{ github.event_name == 'pull_request' }}
74+
uses: helm/kind-action@v1
75+
with:
76+
cluster_name: kind
77+
# Interactive debug
78+
# - name: Setup tmate session
79+
# uses: mxschmitt/action-tmate@v3
80+
# with:
81+
# detached: true
82+
- name: Test Kubernetes
83+
if: ${{ github.event_name == 'pull_request' }}
84+
run: |
85+
set -x
86+
controller_tag="${{ steps.controller-meta.outputs.version }}"
87+
scheduler_tag="${{ steps.scheduler-meta.outputs.version }}"
88+
kind load docker-image "ghcr.io/kilnfi/carina:${controller_tag}" "ghcr.io/kilnfi/carina:${scheduler_tag}"
89+
90+
helm install --create-namespace -n carina --set carina-scheduler.image.tag="${scheduler_tag}" --set image.carina.tag="${controller_tag}" --hide-notes --wait carina-csi-driver charts/
91+
92+
# Create a 50G loopback device inside carina-node to simulate a disk
93+
kubectl wait pod -n carina -l app=csi-carina-node --for=condition=ready --timeout=120s
94+
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"
95+
96+
# Run the helm test — creates a PVC and a pod that uses carina storage.
97+
helm test -n carina --hide-notes carina-csi-driver

.github/workflows/helm.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Helm chart
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'charts/Chart.yaml'
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
jobs:
19+
helm:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v6
23+
- uses: docker/login-action@v4
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
- name: Push chart
29+
run: |
30+
helm package charts
31+
helm push carina-csi-driver-*.tgz "oci://ghcr.io/kilnfi/helm-charts"

Dockerfile

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
# Build the manager binary
2-
FROM registry.cn-hangzhou.aliyuncs.com/carina/golang:1.19.13 AS builder
2+
FROM golang:1.26 AS builder
33

4-
ENV GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOPROXY=https://goproxy.cn,direct
5-
ENV WORKSPACE=/workspace/github.com/carina-io/carina
6-
ENV GOMODCACHE=$WORKSPACE/vendor
4+
WORKDIR /workspace
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
COPY . .
78

8-
WORKDIR $WORKSPACE
9-
ADD . .
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 .
1011

11-
# Build
12-
RUN echo Commit: `git log --pretty='%s%b%B' -n 1`
13-
RUN cd $WORKSPACE/cmd/carina-node && go build -ldflags="-X main.gitCommitID=`git rev-parse HEAD`" -gcflags '-N -l' -o /tmp/carina-node .
14-
RUN cd $WORKSPACE/cmd/carina-controller && go build -ldflags="-X main.gitCommitID=`git rev-parse HEAD`" -gcflags '-N -l' -o /tmp/carina-controller .
12+
FROM alpine:3.20
1513

16-
FROM registry.cn-hangzhou.aliyuncs.com/carina/centos-lvm2:runtime-20220108
14+
RUN apk add --no-cache bash bcache-tools device-mapper e2fsprogs eudev lvm2 parted thin-provisioning-tools util-linux xfsprogs
1715

18-
# copy binary file
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/
22-
RUN chmod +x /usr/bin/carina-node && chmod +x /usr/bin/carina-controller
18+
COPY --from=builder /workspace/debug/hack/config.json /etc/carina/
2319

24-
# Update time zone to Asia-Shanghai
25-
COPY --from=builder /workspace/github.com/carina-io/carina/Shanghai /etc/localtime
26-
RUN echo 'Asia/Shanghai' > /etc/timezone
27-
28-
CMD ["echo carina-node carina-controller"]
20+
CMD ["carina-controller"]

0 commit comments

Comments
 (0)