-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f884409
commit 5fef3ae
Showing
13 changed files
with
349 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
config/samples-on-k8s-with-gcp-secretmanager/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Append samples you want in your CSV to this file as resources ## | ||
resources: | ||
- mysql_v1alpha1_mysqluser.yaml | ||
- mysql_v1alpha1_mysql.yaml | ||
- mysql_v1alpha1_mysqldb.yaml | ||
#+kubebuilder:scaffold:manifestskustomizesamples |
12 changes: 12 additions & 0 deletions
12
config/samples-on-k8s-with-gcp-secretmanager/mysql_v1alpha1_mysql.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: mysql.nakamasato.com/v1alpha1 | ||
kind: MySQL | ||
metadata: | ||
name: mysql-sample | ||
spec: | ||
host: mysql.default # need to include namespace if you use Kubernetes Service as an endpoint. | ||
admin_user: | ||
name: root | ||
type: raw | ||
admin_password: # echo -n "password" | gcloud secrets create mysql-password --data-file=- | ||
name: mysql-password | ||
type: gcp |
7 changes: 7 additions & 0 deletions
7
config/samples-on-k8s-with-gcp-secretmanager/mysql_v1alpha1_mysqldb.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: mysql.nakamasato.com/v1alpha1 | ||
kind: MySQLDB | ||
metadata: | ||
name: sample-db # this is not a name for MySQL database but just a Kubernetes object name | ||
spec: | ||
dbName: sample_db # this is MySQL database name | ||
mysqlName: mysql-sample |
6 changes: 6 additions & 0 deletions
6
config/samples-on-k8s-with-gcp-secretmanager/mysql_v1alpha1_mysqluser.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: mysql.nakamasato.com/v1alpha1 | ||
kind: MySQLUser | ||
metadata: | ||
name: nakamasato | ||
spec: | ||
mysqlName: mysql-sample |
6 changes: 0 additions & 6 deletions
6
config/samples-wtih-gcp-secretmanager/mysql_v1alpha1_mysqldb.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# helm | ||
|
||
## Create Helm chart | ||
|
||
With [helmify](https://github.com/arttor/helmify), you can create a helm chart | ||
|
||
1. 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) | ||
``` | ||
1. Run | ||
``` | ||
make helm | ||
``` | ||
1. 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 | ||
``` | ||
1. Update name in `chart/Chart.yaml` | ||
```yaml | ||
name: mysql-operator | ||
``` | ||
1. Update `chart/templates/deployment.yaml` for your purpose | ||
What we do here is basically to enable to change `Deployment` from `Values`. (ref: [#199](https://github.com/nakamasato/mysql-operator/pull/199/commits/cc245343a9a24eee35425ef7d665c9d17996c7a8)) | ||
1. Package | ||
``` | ||
helm package chart --app-version v0.2.0 | ||
``` | ||
The command will generate `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](https://github.com/nakamasato/helm-charts/tree/main/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) | ||
1. Install mysql-operator with helm | ||
``` | ||
helm install mysql-operator-0.1.0.tgz --generate-name | ||
``` | ||
Optionally, you can add `--set cloudSecretManagerType=gcp --set gcpProjectId=$PROJECT_ID` to use GCP SecretManager to get AdminUser and/or AdminPassword. | ||
<details> | ||
``` | ||
NAME: mysql-operator-0-1680907162 | ||
LAST DEPLOYED: Sat Apr 8 07:13:58 2023 | ||
NAMESPACE: default | ||
STATUS: deployed | ||
REVISION: 1 | ||
TEST SUITE: None | ||
``` | ||
</details> | ||
1. List | ||
``` | ||
helm list | ||
``` | ||
``` | ||
NAME 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. Check operator is running | ||
``` | ||
kubectl get po | ||
NAME READY STATUS RESTARTS AGE | ||
mysql-operator-0-1680907162-controller-manager-f9d855dc9-d4psm 0/1 Running 0 13s | ||
``` | ||
1. (Optional) upgrade an existing release | ||
``` | ||
helm upgrade mysql-operator-0-1680913123 $HELM_PATH --set cloudSecretManagerType=gcp --set gcpProjectId=$PROJECT_ID | ||
``` | ||
1. Uninstall | ||
``` | ||
helm uninstall mysql-operator-0-1680907162 | ||
``` | ||
## Usage | ||
[Install with Helm](../usage/install-with-helm.md) | ||
## Development Tips | ||
1. Check resulting yaml file | ||
``` | ||
helm template chart | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.