Skip to content

Commit

Permalink
refactor!(crds): automatic CRD installation
Browse files Browse the repository at this point in the history
  • Loading branch information
zyy17 committed Aug 19, 2024
1 parent 4a869ac commit 7f1a665
Show file tree
Hide file tree
Showing 14 changed files with 16,488 additions and 16,352 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ e2e: ## Run e2e tests
./scripts/deploy-greptimedb-cluster.sh
./scripts/deploy-greptimedb-standalone.sh

.PHONY: crds
crds: ## Run update crd
./scripts/update-crds.sh
.PHONY: update-crds
update-crds: ## Run update crd
./scripts/crds/update-crds.sh

.PHONY: upgrade-crds
upgrade-crds: ## Upgrade the crds in the cluster.
./scripts/upgrade-crds.sh $(CRDS_VERSION)
./scripts/crds/upgrade-crds.sh $(CRDS_VERSION)

.PHONY: check-crds
check-crds: crds ## Check crd
check-crds: update-crds ## Check crd
@git diff --quiet || \
(echo "Need to update crds, please run 'make crds'"; \
exit 1)
Expand Down
2 changes: 1 addition & 1 deletion charts/greptimedb-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kubeVersion: ">=1.18.0-0"
description: The greptimedb-operator Helm chart for Kubernetes.
name: greptimedb-operator
appVersion: 0.1.0-alpha.28
version: 0.2.0
version: 0.2.1
type: application
home: https://github.com/GreptimeTeam/greptimedb-operator
sources:
Expand Down
36 changes: 33 additions & 3 deletions charts/greptimedb-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The greptimedb-operator Helm chart for Kubernetes.

![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0-alpha.28](https://img.shields.io/badge/AppVersion-0.1.0--alpha.28-informational?style=flat-square)
![Version: 0.2.1](https://img.shields.io/badge/Version-0.2.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0-alpha.28](https://img.shields.io/badge/AppVersion-0.1.0--alpha.28-informational?style=flat-square)

## Source Code

Expand Down Expand Up @@ -40,11 +40,25 @@ helm upgrade \
--version <chart-version>
```

## Upgrade CRDs
## Installation and upgrade of CRDs

Helm cannot upgrade custom resource definitions in the `<chart>/crds` folder [by design](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#some-caveats-and-explanations).

You can upgrade the CRDs manually to **ensure the version of operator and CRDs are aligned**:
**We support CRD installation and upgrade automatically using the chart for deployment convenience**. You can disable the CRD installation by using `--set crds.install=false` when installing the chart. When you uninstall the release, **it will not delete the CRDs by default**.

If the previous version of the chart already installs your CRDs, you have to modify some metadata of CRDs before installing the new version of the chart:

```console
# Add the following labels to the CRDs.
kubectl patch crds greptimedbclusters.greptime.io -p '{"metadata":{"labels":{"app.kubernetes.io/managed-by":"Helm"}}}'
kubectl patch crds greptimedbstandalones.greptime.io -p '{"metadata":{"labels":{"app.kubernetes.io/managed-by":"Helm"}}}'

# Add the following annotations to the CRDs. The values of the annotations are the name and namespace of the release.
kubectl patch crds greptimedbclusters.greptime.io -p '{"metadata":{"annotations":{"meta.helm.sh/release-name":<your-release-name>, "meta.helm.sh/release-namespace":<your-namespace>>}}}'
kubectl patch crds greptimedbstandalones.greptime.io -p '{"metadata":{"annotations":{"meta.helm.sh/release-name":<your-release-name>, "meta.helm.sh/release-namespace":<your-namespace>>}}}'
```

If you want to upgrade CRDs manually, you can use the following steps (**ensure the version of the operator and CRDs are aligned**):

- If your `helm-charts` repository is already up-to-date, you can upgrade the CRDs by the following command:

Expand All @@ -64,6 +78,18 @@ You can upgrade the CRDs manually to **ensure the version of operator and CRDs a
helm uninstall greptimedb-operator -n greptimedb-admin
```

## How to Update the CRDs in the Chart

If you want to update the CRDs in the chart, you can use the following steps:

1. Update the `appVersion` in the `Chart.yaml` file.

2. Execute the following command:

```console
make update-crds
```

## Requirements

Kubernetes: `>=1.18.0-0`
Expand All @@ -73,6 +99,10 @@ Kubernetes: `>=1.18.0-0`
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | The pod affinity |
| crds.additionalLabels | object | `{}` | Addtional labels to be added to all CRDs |
| crds.annotations | object | `{}` | Annotations to be added to all CRDs |
| crds.install | bool | `true` | Install and upgrade CRDs |
| crds.keep | bool | `true` | Keep CRDs on chart uninstall |
| fullnameOverride | string | `""` | Provide a name to substitute for the full names of resources |
| image.imagePullPolicy | string | `"IfNotPresent"` | The image pull policy for the controller |
| image.pullSecrets | list | `[]` | The image pull secrets |
Expand Down
30 changes: 28 additions & 2 deletions charts/greptimedb-operator/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,25 @@ helm upgrade \
--version <chart-version>
```

## Upgrade CRDs
## Installation and upgrade of CRDs

Helm cannot upgrade custom resource definitions in the `<chart>/crds` folder [by design](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#some-caveats-and-explanations).

You can upgrade the CRDs manually to **ensure the version of operator and CRDs are aligned**:
**We support CRD installation and upgrade automatically using the chart for deployment convenience**. You can disable the CRD installation by using `--set crds.install=false` when installing the chart. When you uninstall the release, **it will not delete the CRDs by default**.

If the previous version of the chart already installs your CRDs, you have to modify some metadata of CRDs before installing the new version of the chart:

```console
# Add the following labels to the CRDs.
kubectl patch crds greptimedbclusters.greptime.io -p '{"metadata":{"labels":{"app.kubernetes.io/managed-by":"Helm"}}}'
kubectl patch crds greptimedbstandalones.greptime.io -p '{"metadata":{"labels":{"app.kubernetes.io/managed-by":"Helm"}}}'

# Add the following annotations to the CRDs. The values of the annotations are the name and namespace of the release.
kubectl patch crds greptimedbclusters.greptime.io -p '{"metadata":{"annotations":{"meta.helm.sh/release-name":<your-release-name>, "meta.helm.sh/release-namespace":<your-namespace>>}}}'
kubectl patch crds greptimedbstandalones.greptime.io -p '{"metadata":{"annotations":{"meta.helm.sh/release-name":<your-release-name>, "meta.helm.sh/release-namespace":<your-namespace>>}}}'
```

If you want to upgrade CRDs manually, you can use the following steps (**ensure the version of the operator and CRDs are aligned**):

- If your `helm-charts` repository is already up-to-date, you can upgrade the CRDs by the following command:

Expand All @@ -63,6 +77,18 @@ You can upgrade the CRDs manually to **ensure the version of operator and CRDs a
helm uninstall greptimedb-operator -n greptimedb-admin
```

## How to Update the CRDs in the Chart

If you want to update the CRDs in the chart, you can use the following steps:

1. Update the `appVersion` in the `Chart.yaml` file.

2. Execute the following command:

```console
make update-crds
```

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}
Loading

0 comments on commit 7f1a665

Please sign in to comment.