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

feat(t8s-cluster/management-cluster): validate new k8s version before upgrade #508

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- $cluster := include (print $.Template.BasePath "/management-cluster/cluster.yaml") . | fromYaml }}
{{- $existingCluster := lookup $cluster.apiVersion $cluster.kind $cluster.metadata.namespace $cluster.metadata.name }}
{{/* Should always pass, just doesn't work for local diffs 😥 */}}
{{- if $existingCluster }}
apiVersion: batch/v1
kind: Job
metadata:
name: check-k8s-version
namespace: {{ .Release.Namespace }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
annotations:
helm.sh/hook: pre-upgrade
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsGroup: 1000
runAsUser: 1000
fsGroup: 1000
containers:
- name: check-k8s-version
image: {{ include "common.images.image" (dict "imageRoot" .Values.global.semver.image "global" .Values.global) }}
{{- if .Values.global.semver.image.digest }}
imagePullPolicy: IfNotPresent
{{- else }}
imagePullPolicy: Always
{{- end }}
securityContext:
readOnlyRootFilesystem: true
privileged: false
capabilities:
drop:
- ALL
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
command:
- semver
- --range
- '>={{ $existingCluster.spec.version }}'
{{- with .Values.version }}
- {{ printf "v%d.%d.%d" (.major | int) (.minor | int) (.patch | int) }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/t8s-cluster/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
},
"additionalProperties": false
},
"semver": {
"type": "object",
"description": "Image with `semver` binary",
"properties": {
"image": {
"$ref": "#/$defs/image"
}
},
"additionalProperties": false
},
"injectedCertificateAuthorities": {
"type": "string"
},
Expand Down
5 changes: 5 additions & 0 deletions charts/t8s-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ global:
registry: docker.io
repository: bitnami/kubectl
tag: 1.27.4
semver:
image:
registry: docker.io
repository: alpine/semver
tag: 7.5.4
injectedCertificateAuthorities: ""
kubeletExtraConfig:
# This is only used when using 1.27 or later
Expand Down