Skip to content

Commit

Permalink
ci: modify scripts/ directory layout and add upgrade-crds.sh (#142)
Browse files Browse the repository at this point in the history
* refactor: move scripts from '.github/' to top directory for better maintaince

* ci: add upgrade-crds.sh

* ci: upgrade operator version
  • Loading branch information
zyy17 authored Jul 16, 2024
1 parent 13fc727 commit b0309a3
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
if: ${{ github.event.inputs.chart == 'greptimedb-cluster' }}
shell: bash
run: |
.github/scripts/deploy-greptimedb-cluster.sh
./scripts/deploy-greptimedb-cluster.sh
- name: Deploy greptimedb-standalone chart
if: ${{ github.event.inputs.chart == 'greptimedb-standalone' }}
shell: bash
run: |
.github/scripts/deploy-greptimedb-standalone.sh
./scripts/deploy-greptimedb-standalone.sh
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
- name: Release charts to S3
shell: bash
run: |
.github/scripts/release-charts-to-s3.sh ${{ vars.AWS_RELEASE_BUCKET }}
./scripts/release-charts-to-s3.sh ${{ vars.AWS_RELEASE_BUCKET }}
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ check-docs: docs ## Check docs

.PHONY: e2e
e2e: ## Run e2e tests
.github/scripts/deploy-greptimedb-cluster.sh
.github/scripts/deploy-greptimedb-standalone.sh
./scripts/deploy-greptimedb-cluster.sh
./scripts/deploy-greptimedb-standalone.sh

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

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

.PHONY: check-crds
check-crds: crds ## Check crd
Expand All @@ -44,4 +48,4 @@ check-crds: crds ## Check crd
# make update-chart CHART=greptimedb-operator VERSION=0.1.0-alpha.23 # [the greptimedb-operator image tag not have 'v' prefix]
.PHONY: update-chart
update-chart: ## Run update chart
.github/scripts/update-chart.sh $(CHART) $(VERSION)
./scripts/update-chart.sh $(CHART) $(VERSION)
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.27
version: 0.1.19
version: 0.1.20
type: application
home: https://github.com/GreptimeTeam/greptimedb-operator
sources:
Expand Down
21 changes: 15 additions & 6 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.1.19](https://img.shields.io/badge/Version-0.1.19-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0-alpha.27](https://img.shields.io/badge/AppVersion-0.1.0--alpha.27-informational?style=flat-square)
![Version: 0.1.20](https://img.shields.io/badge/Version-0.1.20-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0-alpha.27](https://img.shields.io/badge/AppVersion-0.1.0--alpha.27-informational?style=flat-square)

## Source Code

Expand Down Expand Up @@ -42,12 +42,21 @@ helm upgrade \

## Upgrade 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). When the CRDs are upgraded, you can upgrade CRDs by using `kubectl` manually:
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).

```console
kubectl apply -f https://github.com/GreptimeTeam/greptimedb-operator/releases/download/latest/greptimedbclusters.yaml
kubectl apply -f https://github.com/GreptimeTeam/greptimedb-operator/releases/download/latest/greptimedbstandalones.yaml
```
You can upgrade the CRDs manually to **ensure the version of operator and CRDs are aligned**:

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

```console
make upgrade-crds
```

- If you want to upgrade the CRDs to the latest released version:

```console
make upgrade-crds CRDS_VERSION=latest
```

## How to Uninstall

Expand Down
19 changes: 14 additions & 5 deletions charts/greptimedb-operator/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ helm upgrade \

## Upgrade 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). When the CRDs are upgraded, you can upgrade CRDs by using `kubectl` manually:
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).

```console
kubectl apply -f https://github.com/GreptimeTeam/greptimedb-operator/releases/download/latest/greptimedbclusters.yaml
kubectl apply -f https://github.com/GreptimeTeam/greptimedb-operator/releases/download/latest/greptimedbstandalones.yaml
```
You can upgrade the CRDs manually to **ensure the version of operator and CRDs are aligned**:

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

```console
make upgrade-crds
```

- If you want to upgrade the CRDs to the latest released version:

```console
make upgrade-crds CRDS_VERSION=latest
```

## How to Uninstall

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions scripts/upgrade-crds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -e

OPERATOR_VERSION=${1:-$(awk '/appVersion:/{print $2}' "charts/greptimedb-operator/Chart.yaml")}

function upgrade_crds() {
if [ -z "$OPERATOR_VERSION" ]; then
echo "Failed to get the operator version."
exit 1
fi

if [ "$OPERATOR_VERSION" == "latest" ]; then
echo "Applying CRDs for the latest released greptimedb-operator version"
kubectl apply -f "https://github.com/GreptimeTeam/greptimedb-operator/releases/latest/download/greptimedbclusters.yaml"
kubectl apply -f "https://github.com/GreptimeTeam/greptimedb-operator/releases/latest/download/greptimedbstandalones.yaml"
exit 0
fi

echo "Applying CRDs for the current greptimedb-operator version $OPERATOR_VERSION"
kubectl apply -f "https://github.com/GreptimeTeam/greptimedb-operator/releases/download/v$OPERATOR_VERSION/greptimedbclusters.yaml"
kubectl apply -f "https://github.com/GreptimeTeam/greptimedb-operator/releases/download/v$OPERATOR_VERSION/greptimedbstandalones.yaml"
}

upgrade_crds

0 comments on commit b0309a3

Please sign in to comment.