-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jan-Otto Kröpke <[email protected]> Signed-off-by: Jan-Otto Kröpke <[email protected]>
- Loading branch information
Showing
11 changed files
with
397 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
charts/kube-prometheus-stack/charts/crds/templates/_helpers.tpl
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,20 @@ | ||
{{/* Shortened name suffixed with upgrade-crd */}} | ||
{{- define "kube-prometheus-stack.upgradeCRD.name" -}} | ||
{{- print (include "kube-prometheus-stack.fullname" .) "-upgrade" -}} | ||
{{- end -}} | ||
|
||
{{- define "kube-prometheus-stack.upgradeCRD.labels" -}} | ||
{{- include "kube-prometheus-stack.labels" . }} | ||
app: {{ template "kube-prometheus-stack.name" . }}-operator | ||
app.kubernetes.io/name: {{ template "kube-prometheus-stack.name" . }}-prometheus-operator | ||
app.kubernetes.io/component: crds-upgrade | ||
{{- end -}} | ||
|
||
{{/* Create the name of upgradeCRD service account to use */}} | ||
{{- define "kube-prometheus-stack.upgradeCRD.serviceAccountName" -}} | ||
{{- if .Values.upgradeJob.serviceAccount.create -}} | ||
{{ default (include "kube-prometheus-stack.upgradeCRD.name" .) .Values.upgradeJob.serviceAccount.name }} | ||
{{- else -}} | ||
{{ default "default" .Values.upgradeJob.serviceAccount.name }} | ||
{{- end -}} | ||
{{- end -}} |
35 changes: 35 additions & 0 deletions
35
charts/kube-prometheus-stack/charts/crds/templates/upgrade/clusterrole.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,35 @@ | ||
{{- if .Values.upgradeJob.enabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ template "kube-prometheus-stack.upgradeCRD.name" . }} | ||
namespace: {{ template "kube-prometheus-stack.namespace" . }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,pre-rollback | ||
"helm.sh/hook-weight": "-5" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
{{- include "kube-prometheus-stack.upgradeCRD.labels" . | nindent 4 }} | ||
rules: | ||
- apiGroups: | ||
- "apiextensions.k8s.io" | ||
resources: | ||
- "customresourcedefinitions" | ||
verbs: | ||
- create | ||
- patch | ||
- update | ||
- get | ||
- list | ||
resourceNames: | ||
- alertmanagerconfigs.monitoring.coreos.com | ||
- alertmanagers.monitoring.coreos.com | ||
- podmonitors.monitoring.coreos.com | ||
- probes.monitoring.coreos.com | ||
- prometheusagents.monitoring.coreos.com | ||
- prometheuses.monitoring.coreos.com | ||
- prometheusrules.monitoring.coreos.com | ||
- scrapeconfigs.monitoring.coreos.com | ||
- servicemonitors.monitoring.coreos.com | ||
- thanosrulers.monitoring.coreos.com | ||
{{- end }} |
21 changes: 21 additions & 0 deletions
21
charts/kube-prometheus-stack/charts/crds/templates/upgrade/clusterrolebinding.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,21 @@ | ||
{{- if .Values.upgradeJob.enabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ template "kube-prometheus-stack.upgradeCRD.name" . }} | ||
namespace: {{ template "kube-prometheus-stack.namespace" . }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,pre-rollback | ||
"helm.sh/hook-weight": "-3" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
{{- include "kube-prometheus-stack.upgradeCRD.labels" . | nindent 4 }} | ||
subjects: | ||
- kind: ServiceAccount | ||
namespace: {{ template "kube-prometheus-stack.namespace" . }} | ||
name: {{ template "kube-prometheus-stack.upgradeCRD.serviceAccountName" . }} | ||
roleRef: | ||
kind: ClusterRole | ||
name: {{ template "kube-prometheus-stack.upgradeCRD.name" . }} | ||
apiGroup: rbac.authorization.k8s.io | ||
{{- end }} |
15 changes: 15 additions & 0 deletions
15
charts/kube-prometheus-stack/charts/crds/templates/upgrade/crds.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,15 @@ | ||
{{- if .Values.upgradeJob.enabled }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "kube-prometheus-stack.upgradeCRD.serviceAccountName" . }} | ||
namespace: {{ template "kube-prometheus-stack.namespace" . }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,pre-rollback | ||
"helm.sh/hook-weight": "-2" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
{{- include "kube-prometheus-stack.upgradeCRD.labels" . | nindent 4 }} | ||
binaryData: | ||
crds.tar.xz: {{ .Files.Get "files/crds.tar.xz" | b64enc }} | ||
{{- end }} |
143 changes: 143 additions & 0 deletions
143
charts/kube-prometheus-stack/charts/crds/templates/upgrade/job.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,143 @@ | ||
{{- if .Values.upgradeJob.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ template "kube-prometheus-stack.upgradeCRD.name" . }} | ||
namespace: {{ template "kube-prometheus-stack.namespace" . }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,pre-rollback | ||
"helm.sh/hook-weight": "5" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- with .Values.upgradeJob.annotations }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
labels: | ||
{{- include "kube-prometheus-stack.upgradeCRD.labels" . | nindent 4 }} | ||
{{- with .Values.upgradeJob.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
backoffLimit: 3 | ||
template: | ||
metadata: | ||
{{- with .Values.upgradeJob.podLabels }} | ||
labels: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
{{- if .Values.global.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- include "kube-prometheus-stack.imagePullSecrets" . | indent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "kube-prometheus-stack.upgradeCRD.serviceAccountName" . }} | ||
initContainers: | ||
- name: busybox | ||
{{- $busyboxRegistry := .Values.global.imageRegistry | default .Values.upgradeJob.image.busybox.registry -}} | ||
{{- if .Values.upgradeJob.image.sha }} | ||
image: "{{ $busyboxRegistry }}/{{ .Values.upgradeJob.image.busybox.repository }}:{{ .Values.upgradeJob.image.busybox.tag }}@sha256:{{ .Values.upgradeJob.image.busybox.sha }}" | ||
{{- else }} | ||
image: "{{ $busyboxRegistry }}/{{ .Values.upgradeJob.image.busybox.repository }}:{{ .Values.upgradeJob.image.busybox.tag }}" | ||
{{- end }} | ||
imagePullPolicy: "{{ .Values.upgradeJob.image.busybox.pullPolicy }}" | ||
workingDir: /tmp/ | ||
command: | ||
- tar | ||
args: | ||
- xvJf | ||
- /crds/crds.tar.xz | ||
{{- with .Values.upgradeJob.resources }} | ||
resources: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.containerSecurityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
volumeMounts: | ||
- mountPath: /crds/ | ||
name: crds | ||
- mountPath: /tmp/ | ||
name: tmp | ||
{{- with .Values.upgradeJob.extraVolumeMounts }} | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.env }} | ||
env: | ||
{{- range $key, $value := . }} | ||
- name: {{ $key }} | ||
value: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
containers: | ||
- name: kubectl | ||
{{- $kubectlRegistry := .Values.global.imageRegistry | default .Values.upgradeJob.image.kubectl.registry -}} | ||
{{- if .Values.upgradeJob.image.kubectl.sha }} | ||
image: "{{ $kubectlRegistry }}/{{ .Values.upgradeJob.image.kubectl.repository }}:{{ .Values.upgradeJob.image.kubectl.tag | default .Capabilities.KubeVersion.Version }}@sha256:{{ .Values.upgradeJob.image.kubectl.sha }}" | ||
{{- else }} | ||
image: "{{ $kubectlRegistry }}/{{ .Values.upgradeJob.image.kubectl.repository }}:{{ .Values.upgradeJob.image.kubectl.tag | default .Capabilities.KubeVersion.Version }}" | ||
{{- end }} | ||
imagePullPolicy: "{{ .Values.upgradeJob.image.kubectl.pullPolicy }}" | ||
command: | ||
- kubectl | ||
args: | ||
- apply | ||
- --server-side | ||
- --recursive | ||
- --filename | ||
- /tmp/ | ||
{{- with .Values.upgradeJob.resources }} | ||
resources: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.containerSecurityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
volumeMounts: | ||
- mountPath: /tmp/ | ||
name: tmp | ||
{{- with .Values.upgradeJob.extraVolumeMounts }} | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.env }} | ||
env: | ||
{{- range $key, $value := . }} | ||
- name: {{ $key }} | ||
value: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
volumes: | ||
- name: tmp | ||
emptyDir: {} | ||
- name: crds | ||
configMap: | ||
name: {{ template "kube-prometheus-stack.upgradeCRD.name" . }} | ||
{{- with .Values.upgradeJob.extraVolumes }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
restartPolicy: OnFailure | ||
{{- with .Values.upgradeJob.podSecurityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.upgradeJob.topologySpreadConstraints }} | ||
topologySpreadConstraints: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- end }} |
20 changes: 20 additions & 0 deletions
20
charts/kube-prometheus-stack/charts/crds/templates/upgrade/serviceaccount.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,20 @@ | ||
{{- if and .Values.upgradeJob.enabled .Values.upgradeJob.serviceAccount.create }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
automountServiceAccountToken: {{ .Values.upgradeJob.serviceAccount.automountServiceAccountToken }} | ||
metadata: | ||
name: {{ include "kube-prometheus-stack.upgradeCRD.serviceAccountName" . }} | ||
namespace: {{ template "kube-prometheus-stack.namespace" . }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,pre-rollback | ||
"helm.sh/hook-weight": "-4" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- with .Values.upgradeJob.serviceAccount.annotations }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
labels: | ||
{{- include "kube-prometheus-stack.upgradeCRD.labels" . | nindent 4 }} | ||
{{- with .Values.upgradeJob.serviceAccount.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
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
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
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
Oops, something went wrong.