Skip to content

Commit ec4b733

Browse files
CoderYellowclaude
andcommitted
feat: add Docker image, Helm chart, and release workflows
- Dockerfile (rust:1.97.0-trixie builder, trixie-slim runtime, nonroot) - Helm chart with CRDs, RBAC, deployment (charts/rustfs-operator) - CI workflow: fmt/clippy/unit + container-backed integration/e2e tests - Release workflow on v* tags: image to GHCR, chart to gh-pages via chart-releaser, GitHub release with CRDs and linux binary Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 728c04b commit ec4b733

18 files changed

Lines changed: 652 additions & 23 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
target/
2+
.github/
3+
charts/
4+
deploy/
5+
tests/
6+
.claude/
7+
.idea/
8+
*.md

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
lint-and-unit:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: dtolnay/rust-toolchain@stable
20+
with:
21+
components: rustfmt, clippy
22+
- uses: Swatinem/rust-cache@v2
23+
- name: Format
24+
run: cargo fmt --check
25+
- name: Clippy
26+
run: cargo clippy --all-targets --features integration,e2e -- -D warnings
27+
- name: Unit tests
28+
run: cargo test
29+
- name: Helm lint
30+
run: helm lint charts/rustfs-operator
31+
32+
container-tests:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: dtolnay/rust-toolchain@stable
37+
- uses: Swatinem/rust-cache@v2
38+
- name: Integration tests (RustFS container)
39+
run: cargo test --features integration --test integration_rustfs
40+
- name: E2E tests (k3s + RustFS containers)
41+
run: cargo test --features e2e --test e2e_k3s

.github/workflows/release.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
image:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: docker/setup-buildx-action@v3
19+
- uses: docker/login-action@v3
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
- id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: ghcr.io/${{ github.repository }}
28+
tags: |
29+
type=semver,pattern={{version}}
30+
type=semver,pattern={{major}}.{{minor}}
31+
- uses: docker/build-push-action@v6
32+
with:
33+
context: .
34+
push: true
35+
tags: ${{ steps.meta.outputs.tags }}
36+
labels: ${{ steps.meta.outputs.labels }}
37+
cache-from: type=gha
38+
cache-to: type=gha,mode=max
39+
40+
github-release:
41+
runs-on: ubuntu-latest
42+
needs: image
43+
permissions:
44+
contents: write
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: dtolnay/rust-toolchain@stable
48+
- uses: Swatinem/rust-cache@v2
49+
- name: Build release binary
50+
run: |
51+
cargo build --release --bin rustfs-operator
52+
cp target/release/rustfs-operator rustfs-operator-linux-amd64
53+
- uses: softprops/action-gh-release@v2
54+
with:
55+
generate_release_notes: true
56+
files: |
57+
deploy/crds.yaml
58+
rustfs-operator-linux-amd64
59+
60+
charts:
61+
runs-on: ubuntu-latest
62+
needs: image
63+
permissions:
64+
contents: write
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
- name: Set chart version from tag
70+
run: |
71+
version="${GITHUB_REF_NAME#v}"
72+
sed -i "s/^version:.*/version: ${version}/" charts/rustfs-operator/Chart.yaml
73+
sed -i "s/^appVersion:.*/appVersion: \"${version}\"/" charts/rustfs-operator/Chart.yaml
74+
- name: Configure git
75+
run: |
76+
git config user.name "$GITHUB_ACTOR"
77+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
78+
- name: Release chart to gh-pages
79+
uses: helm/chart-releaser-action@v1
80+
with:
81+
charts_dir: charts
82+
mark_as_latest: false
83+
env:
84+
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM rust:1.97.0-trixie AS builder
2+
WORKDIR /build
3+
COPY Cargo.toml ./
4+
COPY src ./src
5+
RUN cargo build --release --bin rustfs-operator
6+
7+
FROM debian:trixie-slim
8+
RUN apt-get update \
9+
&& apt-get install -y --no-install-recommends ca-certificates \
10+
&& rm -rf /var/lib/apt/lists/* \
11+
&& useradd --system --uid 65532 nonroot
12+
COPY --from=builder /build/target/release/rustfs-operator /usr/local/bin/rustfs-operator
13+
USER 65532
14+
ENTRYPOINT ["/usr/local/bin/rustfs-operator"]
15+
CMD ["run"]

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,31 @@ See `deploy/example.yaml` for a complete example. Each resource supports
2929
`deletionPolicy: Delete` (default; the remote resource is removed via
3030
finalizer when the CR is deleted) or `Retain`.
3131

32-
## Install & run
32+
## Install
33+
34+
Via Helm (chart repo served from GitHub Pages, image from GHCR):
35+
36+
```sh
37+
helm repo add rustfs-operator https://openprojectx.github.io/rustfs-operator
38+
helm install rustfs-operator rustfs-operator/rustfs-operator \
39+
--namespace rustfs-operator --create-namespace
40+
```
41+
42+
Or run from source against the current kubeconfig:
3343

3444
```sh
3545
# CRDs (regenerate with: cargo run -- crd > deploy/crds.yaml)
3646
kubectl apply -f deploy/crds.yaml
37-
kubectl apply -f deploy/rbac.yaml
38-
39-
# run the controllers (in-cluster or with a local kubeconfig)
4047
cargo run --release -- run
4148
```
4249

50+
## Releasing
51+
52+
Push a `v*` tag. The release workflow builds and pushes
53+
`ghcr.io/openprojectx/rustfs-operator:<version>`, packages the Helm chart to
54+
the `gh-pages` chart repository, and creates a GitHub release with the CRD
55+
manifest and a linux-amd64 binary attached.
56+
4357
## Behavior notes
4458

4559
- **Reconcile loop**: finalizer-based; drift is re-checked every 5 minutes,

charts/rustfs-operator/Chart.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v2
2+
name: rustfs-operator
3+
description: Kubernetes operator managing RustFS buckets, IAM users and policies
4+
type: application
5+
home: https://github.com/OpenProjectX/rustfs-operator
6+
sources:
7+
- https://github.com/OpenProjectX/rustfs-operator
8+
keywords:
9+
- rustfs
10+
- s3
11+
- operator
12+
# version and appVersion are overwritten from the git tag by the release workflow
13+
version: 0.1.0
14+
appVersion: "0.1.0"

0 commit comments

Comments
 (0)