From 6c08d23a3f94cabe5415a6612092c9bcb31af909 Mon Sep 17 00:00:00 2001 From: wangyelei Date: Fri, 15 Nov 2024 09:53:28 +0800 Subject: [PATCH] chore: fix install 1.0 bug when existing KB 0.9 (#8457) --- .../helm/templates/conversion-patch-hook.yaml | 6 +++++ .../rbac/shardingdefinition_editor_role.yaml | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 deploy/helm/templates/rbac/shardingdefinition_editor_role.yaml diff --git a/deploy/helm/templates/conversion-patch-hook.yaml b/deploy/helm/templates/conversion-patch-hook.yaml index 2a2c0b47cf5..e25833b6e15 100644 --- a/deploy/helm/templates/conversion-patch-hook.yaml +++ b/deploy/helm/templates/conversion-patch-hook.yaml @@ -44,6 +44,7 @@ spec: old_kb_json=$(kubectl get deployment ${name} -n ${namespace} -o json) version=$(echo ${old_kb_json} | jq '.metadata.labels["app.kubernetes.io/version"]' | tr -d '"') replicas=$(echo ${old_kb_json} | jq '.spec.replicas') + statusReplicas=$(echo ${old_kb_json} | jq '.status.replicas') if echo "$version" | grep -q '^0\.9'; then echo "TODO: add it when released 0.9.2" # patch_num=$(echo $version | awk -F. '{print $3}' | awk -F- '{print $1}') @@ -59,6 +60,11 @@ spec: echo "ERROR: You must stop the existing ${namespace}/${name} version (${version}) before installing version 1.0." exit 1 fi + echo "status: $statusReplicas" + if [ "$statusReplicas" != "null" ] || [ $statusReplicas -ne 0 ]; then + echo "ERROR: You must stop the existing ${namespace}/${name} version (${version}) before installing version 1.0." + exit 1 + fi done IFS=$OLD_IFS # 2. patch crds diff --git a/deploy/helm/templates/rbac/shardingdefinition_editor_role.yaml b/deploy/helm/templates/rbac/shardingdefinition_editor_role.yaml new file mode 100644 index 00000000000..9b1e4842211 --- /dev/null +++ b/deploy/helm/templates/rbac/shardingdefinition_editor_role.yaml @@ -0,0 +1,26 @@ +# permissions for end users to edit shardingdefinitions. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "kubeblocks.fullname" . }}-shardingdefinition-editor-role + labels: + {{- include "kubeblocks.labels" . | nindent 4 }} +rules: +- apiGroups: + - apps.kubeblocks.io + resources: + - shardingdefinitions + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - apps.kubeblocks.io + resources: + - shardingdefinitions/status + verbs: + - get