-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
[kube-prometheus-stack] WIP: upgrade CRDs using helm #5175
Draft
jkroepke
wants to merge
5
commits into
prometheus-community:main
Choose a base branch
from
jkroepke:upgrade-crds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+424
−2
Draft
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ba8f7e0
[kube-prometheus-stack] upgrade CRDs using helm
jkroepke a689ff6
[kube-prometheus-stack] upgrade CRDs using helm
jkroepke 6844d4f
[kube-prometheus-stack] upgrade CRDs using helm
jkroepke 72562f9
[kube-prometheus-stack] use gtar on mac
jkroepke ec80534
[kube-prometheus-stack] do not use xz
jkroepke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible we should make this dynamic so we don't miss new CRDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done