Skip to content

Commit 7e79b86

Browse files
committed
add helm charts to the repo
use the new kubebuilder helm plugin to generate the helm charts for the repo Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
1 parent 31a93b4 commit 7e79b86

37 files changed

+15069
-6
lines changed

.github/workflows/test-chart.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Test Chart
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test-e2e:
8+
name: chart
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Clone the code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Go
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version-file: go.mod
18+
19+
- name: set up tmate session for debugging
20+
if: ${{ failure() || runner.debug || contains(github.event.pull_request.labels.*.name, 'debug-ci') }}
21+
uses: mxschmitt/action-tmate@v3
22+
with:
23+
limit-access-to-actor: false
24+
detached: true
25+
26+
- name: Setup Minikube
27+
run: |
28+
test/scripts/github-action-helper.sh install_minikube_with_none_driver
29+
30+
- name: print k8s cluster status
31+
run: |
32+
kubectl get nodes
33+
34+
- name: use local disk
35+
run: test/scripts/github-action-helper.sh use_local_disk
36+
37+
- name: create ceph cluster
38+
run: test/scripts/github-action-helper.sh deploy_rook
39+
40+
- name: Prepare ceph-csi-operator
41+
run: |
42+
make docker-build IMG=ceph-csi-operator:v0.1.0
43+
minikube image load ceph-csi-operator:v0.1.0
44+
45+
- name: Install Helm
46+
run: |
47+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
48+
49+
- name: Verify Helm installation
50+
run: helm version
51+
52+
- name: Lint Helm Chart
53+
run: |
54+
helm lint ./dist/chart
55+
56+
- name: Install Helm chart for project
57+
run: |
58+
helm install my-release ./dist/chart --create-namespace --namespace ceph-csi-operator-system
59+
60+
- name: Check Helm release status
61+
run: |
62+
helm status my-release --namespace ceph-csi-operator-system

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,5 @@ go.work.sum
3131
*.patch
3232
*.rej
3333

34-
# Locally generated install files
35-
dist/
36-
3734
# Locally generated dockerfile for multi-arch
3835
Dockerfile.cross

Makefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ help: ## Display this help.
101101
##@ Development
102102

103103
.PHONY: manifests
104-
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
104+
manifests: controller-gen kubebuilder ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
105105
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
106+
$(KUBEBUILDER) edit --plugins=helm/v1-alpha --force ## regenerate the helm charts
106107

107108
.PHONY: generate
108109
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
@@ -121,7 +122,7 @@ mod.check:#check go module dependencies
121122
@echo 'running "go mod verify"'
122123
@go mod verify
123124
@echo 'checking for modified files.'
124-
# fail in case there are uncommitted changes
125+
# fail in case there are uncommitted changes
125126
@ git diff --quiet || (echo "files were modified: " ; git status --porcelain ; false)
126127

127128
.PHONY: test
@@ -255,12 +256,20 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION)
255256
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
256257
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
257258
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
259+
KUBEBUILDER ?= $(LOCALBIN)/kubebuilder-$(KUBEBUILDER_VERSION)
258260

259261
## Tool Versions
260262
KUSTOMIZE_VERSION ?= v5.3.0
261263
CONTROLLER_TOOLS_VERSION ?= v0.14.0
262264
ENVTEST_VERSION ?= release-0.17
263265
GOLANGCI_LINT_VERSION ?= v1.63.4
266+
KUBEBUILDER_VERSION ?= v4.5.0
267+
268+
.PHONY: kubebuilder
269+
kubebuilder: $(KUBEBUILDER) ## Download kubebuilder locally if necessary.
270+
$(KUBEBUILDER): $(LOCALBIN)
271+
curl -L -o $(KUBEBUILDER) https://github.com/kubernetes-sigs/kubebuilder/releases/download/$(KUBEBUILDER_VERSION)/kubebuilder_$(shell go env GOOS)_$(shell go env GOARCH)
272+
chmod +x $(KUBEBUILDER)
264273

265274
.PHONY: kustomize
266275
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.

PROJECT

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
domain: ceph.io
66
layout:
77
- go.kubebuilder.io/v4
8+
plugins:
9+
helm.kubebuilder.io/v1-alpha: {}
810
projectName: ceph-csi-operator
911
repo: github.com/ceph/ceph-csi-operator
1012
resources:

deploy/all-in-one/install.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15546,7 +15546,7 @@ spec:
1554615546
value: ceph-csi-operator-
1554715547
- name: WATCH_NAMESPACE
1554815548
value: ""
15549-
image: quay.io/cephcsi/ceph-csi-operator:latest
15549+
image: ceph-csi-operator:v0.1.0
1555015550
livenessProbe:
1555115551
httpGet:
1555215552
path: /healthz

dist/chart/.helmignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Patterns to ignore when building Helm packages.
2+
# Operating system files
3+
.DS_Store
4+
5+
# Version control directories
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.hg/
10+
.hgignore
11+
.svn/
12+
13+
# Backup and temporary files
14+
*.swp
15+
*.tmp
16+
*.bak
17+
*.orig
18+
*~
19+
20+
# IDE and editor-related files
21+
.idea/
22+
.vscode/
23+
24+
# Helm chart artifacts
25+
dist/chart/*.tgz

dist/chart/Chart.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: ceph-csi-operator
3+
description: A Helm chart to distribute the project ceph-csi-operator
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"
7+
icon: "https://example.com/icon.png"

dist/chart/templates/_helpers.tpl

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- define "chart.name" -}}
2+
{{- if .Chart }}
3+
{{- if .Chart.Name }}
4+
{{- .Chart.Name | trunc 63 | trimSuffix "-" }}
5+
{{- else if .Values.nameOverride }}
6+
{{ .Values.nameOverride | trunc 63 | trimSuffix "-" }}
7+
{{- else }}
8+
ceph-csi-operator
9+
{{- end }}
10+
{{- else }}
11+
ceph-csi-operator
12+
{{- end }}
13+
{{- end }}
14+
15+
16+
{{- define "chart.labels" -}}
17+
{{- if .Chart.AppVersion -}}
18+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
19+
{{- end }}
20+
{{- if .Chart.Version }}
21+
helm.sh/chart: {{ .Chart.Version | quote }}
22+
{{- end }}
23+
app.kubernetes.io/name: {{ include "chart.name" . }}
24+
app.kubernetes.io/instance: {{ .Release.Name }}
25+
app.kubernetes.io/managed-by: {{ .Release.Service }}
26+
{{- end }}
27+
28+
29+
{{- define "chart.selectorLabels" -}}
30+
app.kubernetes.io/name: {{ include "chart.name" . }}
31+
app.kubernetes.io/instance: {{ .Release.Name }}
32+
{{- end }}
33+
34+
35+
{{- define "chart.hasMutatingWebhooks" -}}
36+
{{- $hasMutating := false }}
37+
{{- range . }}
38+
{{- if eq .type "mutating" }}
39+
$hasMutating = true }}{{- end }}
40+
{{- end }}
41+
{{ $hasMutating }}}}{{- end }}
42+
43+
44+
{{- define "chart.hasValidatingWebhooks" -}}
45+
{{- $hasValidating := false }}
46+
{{- range . }}
47+
{{- if eq .type "validating" }}
48+
$hasValidating = true }}{{- end }}
49+
{{- end }}
50+
{{ $hasValidating }}}}{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{- if .Values.certmanager.enable }}
2+
# Self-signed Issuer
3+
apiVersion: cert-manager.io/v1
4+
kind: Issuer
5+
metadata:
6+
labels:
7+
{{- include "chart.labels" . | nindent 4 }}
8+
name: selfsigned-issuer
9+
namespace: {{ .Release.Namespace }}
10+
spec:
11+
selfSigned: {}
12+
{{- if .Values.webhook.enable }}
13+
---
14+
# Certificate for the webhook
15+
apiVersion: cert-manager.io/v1
16+
kind: Certificate
17+
metadata:
18+
annotations:
19+
{{- if .Values.crd.keep }}
20+
"helm.sh/resource-policy": keep
21+
{{- end }}
22+
name: serving-cert
23+
namespace: {{ .Release.Namespace }}
24+
labels:
25+
{{- include "chart.labels" . | nindent 4 }}
26+
spec:
27+
dnsNames:
28+
- ceph-csi-operator.{{ .Release.Namespace }}.svc
29+
- ceph-csi-operator.{{ .Release.Namespace }}.svc.cluster.local
30+
- ceph-csi-operator-webhook-service.{{ .Release.Namespace }}.svc
31+
issuerRef:
32+
kind: Issuer
33+
name: selfsigned-issuer
34+
secretName: webhook-server-cert
35+
{{- end }}
36+
{{- if .Values.metrics.enable }}
37+
---
38+
# Certificate for the metrics
39+
apiVersion: cert-manager.io/v1
40+
kind: Certificate
41+
metadata:
42+
annotations:
43+
{{- if .Values.crd.keep }}
44+
"helm.sh/resource-policy": keep
45+
{{- end }}
46+
labels:
47+
{{- include "chart.labels" . | nindent 4 }}
48+
name: metrics-certs
49+
namespace: {{ .Release.Namespace }}
50+
spec:
51+
dnsNames:
52+
- ceph-csi-operator.{{ .Release.Namespace }}.svc
53+
- ceph-csi-operator.{{ .Release.Namespace }}.svc.cluster.local
54+
- ceph-csi-operator-metrics-service.{{ .Release.Namespace }}.svc
55+
issuerRef:
56+
kind: Issuer
57+
name: selfsigned-issuer
58+
secretName: metrics-server-cert
59+
{{- end }}
60+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{{- if .Values.crd.enable }}
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
labels:
7+
{{- include "chart.labels" . | nindent 4 }}
8+
annotations:
9+
{{- if .Values.crd.keep }}
10+
"helm.sh/resource-policy": keep
11+
{{- end }}
12+
controller-gen.kubebuilder.io/version: v0.14.0
13+
name: cephconnections.csi.ceph.io
14+
spec:
15+
group: csi.ceph.io
16+
names:
17+
kind: CephConnection
18+
listKind: CephConnectionList
19+
plural: cephconnections
20+
singular: cephconnection
21+
scope: Namespaced
22+
versions:
23+
- name: v1alpha1
24+
schema:
25+
openAPIV3Schema:
26+
description: CephConnection is the Schema for the cephconnections API
27+
properties:
28+
apiVersion:
29+
description: |-
30+
APIVersion defines the versioned schema of this representation of an object.
31+
Servers should convert recognized schemas to the latest internal value, and
32+
may reject unrecognized values.
33+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
34+
type: string
35+
kind:
36+
description: |-
37+
Kind is a string value representing the REST resource this object represents.
38+
Servers may infer this from the endpoint the client submits requests to.
39+
Cannot be updated.
40+
In CamelCase.
41+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
42+
type: string
43+
metadata:
44+
type: object
45+
spec:
46+
description: CephConnectionSpec defines the desired state of CephConnection
47+
properties:
48+
monitors:
49+
items:
50+
type: string
51+
minItems: 1
52+
type: array
53+
rbdMirrorDaemonCount:
54+
minimum: 1
55+
type: integer
56+
readAffinity:
57+
description: ReadAffinitySpec capture Ceph CSI read affinity settings
58+
properties:
59+
crushLocationLabels:
60+
items:
61+
type: string
62+
minItems: 1
63+
type: array
64+
type: object
65+
required:
66+
- monitors
67+
type: object
68+
status:
69+
description: CephConnectionStatus defines the observed state of CephConnection
70+
type: object
71+
type: object
72+
served: true
73+
storage: true
74+
subresources:
75+
status: {}
76+
{{- end -}}

0 commit comments

Comments
 (0)