helm
Create Helm chart
With helmify, you can create a helm chart
- Update Makefile
HELMIFY ?= $(LOCALBIN)/helmify .PHONY: helmify helmify: $(HELMIFY) ## Download helmify locally if necessary. $(HELMIFY): $(LOCALBIN) test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@latest helm: manifests kustomize helmify $(KUSTOMIZE) build config/install | $(HELMIFY)
- Run
make helm
- Check generated files
chart ├── Chart.yaml ├── templates │ ├── _helpers.tpl │ ├── deployment.yaml │ ├── leader-election-rbac.yaml │ ├── manager-config.yaml │ ├── manager-rbac.yaml │ ├── metrics-reader-rbac.yaml │ ├── metrics-service.yaml │ ├── mysql-crd.yaml │ ├── mysqldb-crd.yaml │ ├── mysqluser-crd.yaml │ └── proxy-rbac.yaml └── values.yaml 1 directory, 13 files
- Update name in
chart/Chart.yaml
name: mysql-operator
- Update
chart/templates/deployment.yaml
for your purpose What we do here is basically to enable to changeDeployment
fromValues
. (ref: #199) - Package
The command will generate
helm package chart --app-version v0.2.0
mysql-operator-0.1.0.tgz
Publish package to Helm chart repo.
https://github.com/nakamasato/helm-charts is used for repo. All we need to do is to update the chart source file under charts/mysql-operator in the repo.
We use GitHub Actions to update the repo.
Install mysql-operator with the Helm chart (from local source file)
-
Install mysql-operator with helm
helm install mysql-operator-0.1.0.tgz --generate-name
Optionally, you can add
--set adminUserSecretType=gcp --set gcpProjectId=$PROJECT_ID
to use GCP SecretManager to get AdminUser and/or AdminPassword.NAME: mysql-operator-0-1680907162 LAST DEPLOYED: Sat Apr 8 07:13:58 2023 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None
-
List
helm list
1. Check operator is runningNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION mysql-operator-0-1680907162 default 1 2023-04-08 07:39:22.416055 +0900 JST deployed mysql-operator-0.1.0 v0.2.0
1. (Optional) upgrade an existing releasekubectl get po NAME READY STATUS RESTARTS AGE mysql-operator-0-1680907162-controller-manager-f9d855dc9-d4psm 0/1 Running 0 13s
1. Uninstallhelm upgrade mysql-operator-0-1680913123 $HELM_PATH --set adminUserSecretType=gcp --set gcpProjectId=$PROJECT_ID
helm uninstall mysql-operator-0-1680907162
Usage
Development Tips
- Check resulting yaml file
helm template chart