Skip to content

Commit

Permalink
fix: check if HR exists in pre-upgrade scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cbuto committed Aug 1, 2023
1 parent 0576383 commit aca2a8d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 9 additions & 1 deletion services/gatekeeper/3.12.0/pre-upgrade/pre-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "watch", "list", "update", "patch", "create"]
- apiGroups: ["helm.toolkit.fluxcd.io"]
resources: ["helmreleases"]
verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down Expand Up @@ -51,8 +54,13 @@ spec:
- |-
/bin/bash <<'EOF'
set -o nounset
set -o errexit
set -o pipefail
kubectl get helmreleases.helm.toolkit.fluxcd.io -n ${releaseNamespace} gatekeeper
if [[ $? -ne 0 ]]; then
echo "Since the gatekeeper HelmRelease does not exist, this might not be an upgrade scenario. Exiting..."
exit 0
fi
helm mapkubeapis kommander-gatekeeper --namespace ${releaseNamespace}
EOF
10 changes: 9 additions & 1 deletion services/kubecost/0.35.1/pre-upgrade/pre-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "watch", "list", "update", "patch", "create"]
- apiGroups: ["helm.toolkit.fluxcd.io"]
resources: ["helmreleases"]
verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down Expand Up @@ -51,8 +54,13 @@ spec:
- |-
/bin/bash <<'EOF'
set -o nounset
set -o errexit
set -o pipefail
kubectl get helmreleases.helm.toolkit.fluxcd.io -n ${releaseNamespace} kubecost
if [[ $? -ne 0 ]]; then
echo "Since the kubecost HelmRelease does not exist, this might not be an upgrade scenario. Exiting..."
exit 0
fi
helm mapkubeapis kubecost --namespace ${releaseNamespace}
EOF
10 changes: 9 additions & 1 deletion services/logging-operator/4.2.3/pre-upgrade/pre-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "watch", "list", "update", "patch", "create"]
- apiGroups: ["helm.toolkit.fluxcd.io"]
resources: ["helmreleases"]
verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down Expand Up @@ -51,8 +54,13 @@ spec:
- |-
/bin/bash <<'EOF'
set -o nounset
set -o errexit
set -o pipefail
kubectl get helmreleases.helm.toolkit.fluxcd.io -n ${releaseNamespace} logging-operator
if [[ $? -ne 0 ]]; then
echo "Since the logging-operator HelmRelease does not exist, this might not be an upgrade scenario. Exiting..."
exit 0
fi
helm mapkubeapis logging-operator --namespace ${releaseNamespace}
EOF

0 comments on commit aca2a8d

Please sign in to comment.