-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZooKeeper Operator API Resource Hook. (#221)
* Add api-resource Helm hook. Signed-off-by: co-jo <[email protected]> * Add api-resource Helm hook. Signed-off-by: co-jo <[email protected]> * Add checks in hook for available pods. Signed-off-by: co-jo <[email protected]> * Add role to get deployment status. Signed-off-by: co-jo <[email protected]> * Fix test command. Signed-off-by: co-jo <[email protected]> * Remove redundant replica checks. Signed-off-by: co-jo <[email protected]> * Parameterize backoffLimit. Signed-off-by: co-jo <[email protected]>
- Loading branch information
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
charts/zookeeper-operator/templates/post-install-upgrade-hooks.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,107 @@ | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": post-install, post-upgrade | ||
"helm.sh/hook-weight": "1" | ||
"helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation, hook-failed | ||
rules: | ||
- apiGroups: | ||
- zookeeper.pravega.io | ||
resources: | ||
- "*" | ||
verbs: | ||
- get | ||
- apiGroups: | ||
- extensions | ||
resources: | ||
- "deployments" | ||
verbs: | ||
- get | ||
--- | ||
|
||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": post-install, post-upgrade | ||
"helm.sh/hook-weight": "1" | ||
"helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation, hook-failed | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
namespace: {{.Release.Namespace}} | ||
roleRef: | ||
kind: Role | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
apiGroup: rbac.authorization.k8s.io | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": post-install, post-upgrade | ||
"helm.sh/hook-weight": "1" | ||
"helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation, hook-failed | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": post-install, post-upgrade | ||
"helm.sh/hook-weight": "1" | ||
"helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation, hook-failed | ||
data: | ||
validations.sh: | | ||
#!/bin/sh | ||
set -e | ||
sleep 30 | ||
if [ -z "$(kubectl api-resources | grep ZookeeperCluster)" ]; then | ||
exit 1 | ||
fi | ||
--- | ||
|
||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": post-install, post-upgrade | ||
"helm.sh/hook-weight": "2" | ||
"helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation, hook-failed | ||
spec: | ||
backoffLimit: {{ .Values.hooks.backoffLimit }} | ||
template: | ||
metadata: | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
spec: | ||
serviceAccountName: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
restartPolicy: Never | ||
containers: | ||
- name: post-install-upgrade-job | ||
image: "{{ .Values.hooks.image.repository }}:{{ .Values.hooks.image.tag }}" | ||
command: | ||
- /scripts/validations.sh | ||
volumeMounts: | ||
- name: sh | ||
mountPath: /scripts | ||
readOnly: true | ||
volumes: | ||
- name: sh | ||
configMap: | ||
name: {{ template "zookeeper-operator.fullname" . }}-post-install-upgrade | ||
defaultMode: 0555 |
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