Skip to content

Commit 39916da

Browse files
Add helmchart generation and release (#29)
1 parent bb5aa0a commit 39916da

File tree

78 files changed

+10282
-453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+10282
-453
lines changed

.github/workflows/ci.yaml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Lint with golangci-lint
3232
uses: golangci/golangci-lint-action@v7
3333
with:
34-
version: v2.3.1
34+
version: v2.4.0
3535
bundle:
3636
runs-on: ubuntu-latest
3737
steps:
@@ -88,6 +88,48 @@ jobs:
8888
go list ./... | grep -v /e2e
8989
make test-ci
9090
91+
helm:
92+
runs-on: ubuntu-latest
93+
steps:
94+
- name: Checkout code
95+
uses: actions/checkout@v4
96+
- name: Set up Go
97+
uses: actions/setup-go@v5
98+
with:
99+
go-version-file: 'go.mod'
100+
- name: Check helmchart generated
101+
run: make generate-helmchart && git diff --exit-code
102+
- name: Install Helm
103+
run: |
104+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
105+
- name: Verify Helm installation
106+
run: helm version
107+
- name: Lint Helm Chart
108+
run: |
109+
helm lint ./dist/chart
110+
- name: Create k8s Kind Cluster
111+
uses: helm/kind-action@v1
112+
with:
113+
cluster_name: helm-test
114+
version: ${{ env.kind-version }}
115+
config: ci/kind-cluster.config
116+
- name: Install cert-manager via Helm
117+
run: |
118+
helm repo add jetstack https://charts.jetstack.io
119+
helm repo update
120+
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set crds.enabled=true
121+
- name: Wait for cert-manager to be ready
122+
run: |
123+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
124+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
125+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
126+
- name: Install Helm chart for project
127+
run: |
128+
helm install my-release ./dist/chart --create-namespace --namespace clickhouse-operator-system
129+
- name: Check Helm release status
130+
run: |
131+
helm status my-release --namespace clickhouse-operator-system
132+
91133
e2e-test:
92134
strategy:
93135
matrix:

.github/workflows/release.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,38 @@ jobs:
3838
- name: Build operator bundle image
3939
run: make bundle bundle-buildx
4040

41-
- name: 'Kustomize Build'
41+
- name: Kustomize Build
4242
uses: karancode/kustomize-github-action@master
4343
with:
4444
token: ${{ github.token }}
4545
kustomize_version: 5.7.1
4646
kustomize_build_dir: "config/default"
47-
kustomize_output_file: "release/clickhouse-operator.yaml"
47+
kustomize_output_file: "dist/clickhouse-operator.yaml"
48+
- name: Run chart-releaser
49+
uses: helm/chart-releaser-action@v1.7.0
50+
env:
51+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
52+
with:
53+
charts_dir: dist/chart
54+
packages_with_index: true
55+
mark_as_latest: true
56+
pages_branch: helm-releases
4857
- name: Create GitHub Release
4958
uses: softprops/action-gh-release@v1
5059
with:
5160
draft: true
5261
tag_name: ${{ github.ref_name }}
53-
name: release-${{github.ref_name }}
62+
name: ${{github.ref_name }}
5463
body: |
55-
Release ${{github.ref_name }}
64+
Pull latest operator images:
5665
```
5766
docker pull ghcr.io/clickhouse/clickhouse-operator/clickhouse-operator:${{ github.ref_name }}
5867
docker pull ghcr.io/clickhouse/clickhouse-operator/clickhouse-operator-bundle:${{ github.ref_name }}
5968
```
6069
To deploy this release use
6170
```
62-
kubectl apply -f https://raw.githubusercontent.com/clickhouse/clickhouse-operator/releases/releases/${{github.ref_name }}/clickhouse-operator.yaml
71+
kubectl apply -f https://github.com/ClickHouse/clickhouse-operator/releases/download/${{github.ref_name}}/clickhouse-operator.yaml
6372
```
6473
generate_release_notes: true
6574
append_body: true
66-
files: release/clickhouse-operator.yaml
75+
files: dist/clickhouse-operator.yaml

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.24.2 AS builder
2+
FROM golang:1.25 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

Makefile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ test-ci: manifests generate fmt vet envtest ## Run tests.
128128
test-e2e:
129129
go test ./test/e2e/ -v -ginkgo.v -test.timeout 30m
130130

131-
.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
131+
.PHONY: test-keeper-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
132132
test-keeper-e2e:
133133
go test ./test/e2e/ -v -ginkgo.v --ginkgo.label-filter keeper -test.timeout 30m
134134

135-
.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
135+
.PHONY: test-clickhouse-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
136136
test-clickhouse-e2e:
137137
go test ./test/e2e/ -v -ginkgo.v --ginkgo.label-filter clickhouse -test.timeout 30m
138138

@@ -148,6 +148,11 @@ golangci-fmt: golangci-lint ## Run golangci-lint fmt
148148
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
149149
$(GOLANGCI_LINT) run --fix
150150

151+
.PHONY: generate-helmchart
152+
generate-helmchart: kubebuilder ## Generate helm charts
153+
$(KUBEBUILDER) edit --plugins=helm/v1-alpha
154+
rm .github/workflows/test-chart.yml
155+
151156
##@ Build
152157

153158
.PHONY: build
@@ -232,12 +237,13 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
232237
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
233238
ENVTEST ?= $(LOCALBIN)/setup-envtest
234239
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
240+
KUBEBUILDER ?= $(LOCALBIN)/kubebuilder
235241

236242
## Tool Versions
237-
KUSTOMIZE_VERSION ?= v5.4.3
238-
CONTROLLER_TOOLS_VERSION ?= v0.16.1
239-
ENVTEST_VERSION ?= release-0.19
240-
GOLANGCI_LINT_VERSION ?= v2.3.1
243+
KUSTOMIZE_VERSION ?= v5.7.1
244+
CONTROLLER_TOOLS_VERSION ?= v0.19.0
245+
ENVTEST_VERSION ?= release-0.22
246+
GOLANGCI_LINT_VERSION ?= v2.4.0
241247

242248
.PHONY: kustomize
243249
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -259,6 +265,12 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
259265
$(GOLANGCI_LINT): $(LOCALBIN)
260266
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
261267

268+
.PHONY: kubebuilder
269+
kubebuilder: $(KUBEBUILDER) ## Download kubebuilder locally if necessary.
270+
$(KUBEBUILDER): $(LOCALBIN)
271+
curl -L -o $(KUBEBUILDER) "https://go.kubebuilder.io/dl/latest/$(shell go env GOOS)/$(shell rgo env GOARCH)"
272+
chmod +x $(KUBEBUILDER)
273+
262274
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
263275
# $1 - target path with name of binary
264276
# $2 - package url which can be installed

PROJECT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ domain: clickhouse.com
66
layout:
77
- go.kubebuilder.io/v4
88
plugins:
9+
helm.kubebuilder.io/v1-alpha: {}
910
manifests.sdk.operatorframework.io/v2: {}
1011
scorecard.sdk.operatorframework.io/v2: {}
1112
projectName: clickhouse-operator

api/v1alpha1/clickhousecluster_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ type ClickHouseClusterStatus struct {
172172
// ClickHouseCluster is the Schema for the clickhouseclusters API.
173173
// +kubebuilder:object:root=true
174174
// +kubebuilder:subresource:status
175+
// +kubebuilder:resource:shortName=chc;clickhouse
175176
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status"
176177
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message"
177178
// +kubebuilder:printcolumn:name="ReadyReplicas",type="number",JSONPath=".status.readyReplicas"

api/v1alpha1/keepercluster_types.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,10 @@ type KeeperClusterStatus struct {
144144
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
145145
}
146146

147-
// +genclient
147+
// KeeperCluster is the Schema for the keeperclusters API.
148148
// +kubebuilder:object:root=true
149149
// +kubebuilder:subresource:status
150-
151-
// KeeperCluster is the Schema for the keeperclusters API.
150+
// +kubebuilder:resource:shortName=chk;keeper
152151
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status"
153152
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message"
154153
// +kubebuilder:printcolumn:name="ReadyReplicas",type="number",JSONPath=".status.readyReplicas"

bundle/manifests/clickhouse-operator-controller-manager-metrics-service_v1_service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ spec:
1414
protocol: TCP
1515
targetPort: 8443
1616
selector:
17+
app.kubernetes.io/name: clickhouse-operator
1718
control-plane: controller-manager
1819
status:
1920
loadBalancer: {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
app.kubernetes.io/managed-by: kustomize
7+
app.kubernetes.io/name: clickhouse-operator
8+
name: clickhouse-operator-keepercluster-admin-role
9+
rules:
10+
- apiGroups:
11+
- clickhouse.com
12+
resources:
13+
- keeperclusters
14+
verbs:
15+
- '*'
16+
- apiGroups:
17+
- clickhouse.com
18+
resources:
19+
- keeperclusters/status
20+
verbs:
21+
- get

bundle/manifests/clickhouse-operator-webhook-service_v1_service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ spec:
1212
protocol: TCP
1313
targetPort: 9443
1414
selector:
15+
app.kubernetes.io/name: clickhouse-operator
1516
control-plane: controller-manager
1617
status:
1718
loadBalancer: {}

0 commit comments

Comments
 (0)