Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pravega Operator API Resource Hook. #427

Merged
merged 3 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions charts/pravega-operator/templates/post-install-upgrade-hooks.yaml
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 "pravega-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:
- pravega.pravega.io
resources:
- "*"
verbs:
- get
- apiGroups:
- extensions
resources:
- "deployments"
verbs:
- get
---

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "pravega-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 "pravega-operator.fullname" . }}-post-install-upgrade
namespace: {{.Release.Namespace}}
roleRef:
kind: Role
name: {{ template "pravega-operator.fullname" . }}-post-install-upgrade
apiGroup: rbac.authorization.k8s.io

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "pravega-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 "pravega-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 PravegaCluster)" ]; then
exit 1
fi
---

apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "pravega-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: 3
co-jo marked this conversation as resolved.
Show resolved Hide resolved
template:
metadata:
name: {{ template "pravega-operator.fullname" . }}-post-install-upgrade
spec:
serviceAccountName: {{ template "pravega-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 "pravega-operator.fullname" . }}-post-install-upgrade
defaultMode: 0555
6 changes: 6 additions & 0 deletions charts/pravega-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ webhookCert:
## Specifies which namespace the Operator should watch over.
## An empty string means all namespaces.
watchNamespace: ""

hooks:
image:
repository: lachlanevenson/k8s-kubectl
tag: v1.16.10
backoffLimit: 10
co-jo marked this conversation as resolved.
Show resolved Hide resolved