From d393d48f5235a7383a30b993db84ffa5fd4ef458 Mon Sep 17 00:00:00 2001 From: Leo Q Date: Thu, 2 Dec 2021 18:40:30 +0800 Subject: [PATCH] add k8s 1.22 compat (#9) * add k8s 1.22 compat * fix helpdesk and nginx error * update schema --- charts/helpdesk/Chart.yaml | 2 +- charts/helpdesk/templates/ingress.yaml | 56 +++++++++++++----- charts/helpdesk/values.yaml | 13 ++-- charts/karma/Chart.yaml | 2 +- charts/karma/templates/ingress.yaml | 59 +++++++++++++------ charts/karma/values.schema.json | 2 +- charts/karma/values.yaml | 7 ++- charts/mergeable/Chart.yaml | 2 +- charts/mergeable/templates/ingress.yaml | 26 +++++++- charts/mergeable/values.yaml | 5 +- charts/nginx/.helmignore | 1 + charts/nginx/Chart.yaml | 11 +++- charts/nginx/templates/NOTES.txt | 5 +- charts/nginx/templates/_helpers.tpl | 47 ++++++++------- charts/nginx/templates/deployment.yaml | 20 ++++--- charts/nginx/templates/hpa.yaml | 28 +++++++++ charts/nginx/templates/ingress.yaml | 42 +++++++++---- charts/nginx/templates/serviceaccount.yaml | 8 ++- .../templates/tests/test-connection.yaml | 6 +- charts/nginx/values.yaml | 21 ++++++- charts/overlord/Chart.yaml | 2 +- charts/overlord/templates/ingress.yaml | 48 ++++++++++----- charts/overlord/values.yaml | 5 +- 23 files changed, 296 insertions(+), 122 deletions(-) create mode 100644 charts/nginx/templates/hpa.yaml diff --git a/charts/helpdesk/Chart.yaml b/charts/helpdesk/Chart.yaml index 1c005c9..f1dd24e 100644 --- a/charts/helpdesk/Chart.yaml +++ b/charts/helpdesk/Chart.yaml @@ -32,7 +32,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 0.2.1 +version: 0.3.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. diff --git a/charts/helpdesk/templates/ingress.yaml b/charts/helpdesk/templates/ingress.yaml index 77c58f9..059a661 100644 --- a/charts/helpdesk/templates/ingress.yaml +++ b/charts/helpdesk/templates/ingress.yaml @@ -1,7 +1,14 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "helpdesk.fullname" . -}} {{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1beta1 {{- else -}} apiVersion: extensions/v1beta1 @@ -16,34 +23,55 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: -{{- if .Values.ingress.tls }} + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} tls: - {{- range .Values.ingress.tls }} + {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} + {{- range .hosts }} - {{ . | quote }} - {{- end }} + {{- end }} secretName: {{ .secretName }} + {{- end }} {{- end }} -{{- end }} rules: - {{- range .Values.ingress.hosts }} + {{- range .Values.ingress.hosts }} - host: {{ .host | quote }} http: paths: - {{- range .paths }} - - path: {{ . }}api/ + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + - path: "/api/" + pathType: {{ .pathType }} + backend: + service: + name: {{ $fullName }} + port: {{ $svcPort }} + - path: "/auth/" + pathType: {{ .pathType }} + backend: + service: + name: {{ $fullName }} + port: {{ $svcPort }} + - path: / + pathType: {{ .pathType }} + backend: + service: + name: {{ $fullName }}-frontend + port: {{ $svcPort }} + {{- else }} + - path: "/api/" backend: serviceName: {{ $fullName }} servicePort: {{ $svcPort }} - - path: {{ . }}auth/ + - path: "/auth/" backend: serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - - path: {{ . }} + - path: / backend: serviceName: {{ $fullName }}-frontend servicePort: {{ $svcPort }} - {{- end }} - {{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/helpdesk/values.yaml b/charts/helpdesk/values.yaml index 9a5e216..eeb69c4 100644 --- a/charts/helpdesk/values.yaml +++ b/charts/helpdesk/values.yaml @@ -46,15 +46,14 @@ service: port: 80 ingress: - enabled: true - annotations: - kubernetes.io/ingress.class: nginx + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" - hosts: - - host: helpdesk.example.com - paths: - - / + - host: "chart-example.local" + pathType: ImplementationSpecific tls: [] # - secretName: helpldesk-example-tls # hosts: diff --git a/charts/karma/Chart.yaml b/charts/karma/Chart.yaml index 2084a4b..adbfe08 100644 --- a/charts/karma/Chart.yaml +++ b/charts/karma/Chart.yaml @@ -5,7 +5,7 @@ home: https://github.com/prymitive/karma sources: - https://github.com/wiremind/wiremind-helm-charts/tree/main/charts/karma - https://github.com/prymitive/karma -version: 1.8.1 +version: 1.9.0 appVersion: "0.85" maintainers: - name: desaintmartin diff --git a/charts/karma/templates/ingress.yaml b/charts/karma/templates/ingress.yaml index 16114b4..e67fafb 100644 --- a/charts/karma/templates/ingress.yaml +++ b/charts/karma/templates/ingress.yaml @@ -1,38 +1,61 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "karma.fullname" . -}} -{{- $ingressPath := .Values.ingress.path -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} apiVersion: extensions/v1beta1 +{{- end }} kind: Ingress metadata: name: {{ $fullName }} labels: - app.kubernetes.io/name: {{ include "karma.name" . }} - helm.sh/chart: {{ include "karma.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} + {{- include "karma.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} annotations: -{{ toYaml . | indent 4 }} -{{- end }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: -{{- if .Values.ingress.tls }} + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} tls: - {{- range .Values.ingress.tls }} + {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} + {{- range .hosts }} - {{ . | quote }} - {{- end }} + {{- end }} secretName: {{ .secretName }} + {{- end }} {{- end }} -{{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . | quote }} + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} http: paths: - - path: {{ $ingressPath }} + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} serviceName: {{ $fullName }} - servicePort: http - {{- end }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/karma/values.schema.json b/charts/karma/values.schema.json index cec04d1..817ff8f 100644 --- a/charts/karma/values.schema.json +++ b/charts/karma/values.schema.json @@ -56,7 +56,7 @@ "hosts": { "type": "array", "items": { - "type": "string" + "type": "object" } }, "path": { diff --git a/charts/karma/values.yaml b/charts/karma/values.yaml index d908fa2..5387aee 100644 --- a/charts/karma/values.yaml +++ b/charts/karma/values.yaml @@ -36,12 +36,15 @@ serviceAccount: ingress: enabled: false + className: "" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" - path: / hosts: - - chart-example.local + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific tls: [] # - secretName: chart-example-tls # hosts: diff --git a/charts/mergeable/Chart.yaml b/charts/mergeable/Chart.yaml index fa4593e..664ab35 100644 --- a/charts/mergeable/Chart.yaml +++ b/charts/mergeable/Chart.yaml @@ -18,7 +18,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/mergeable/templates/ingress.yaml b/charts/mergeable/templates/ingress.yaml index dd9291a..042553e 100644 --- a/charts/mergeable/templates/ingress.yaml +++ b/charts/mergeable/templates/ingress.yaml @@ -1,7 +1,14 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "mergeable.fullname" . -}} {{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1beta1 {{- else -}} apiVersion: extensions/v1beta1 @@ -16,6 +23,9 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} {{- if .Values.ingress.tls }} tls: {{- range .Values.ingress.tls }} @@ -32,10 +42,20 @@ spec: http: paths: {{- range .paths }} - - path: {{ . }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} serviceName: {{ $fullName }} servicePort: {{ $svcPort }} + {{- end }} {{- end }} {{- end }} - {{- end }} +{{- end }} diff --git a/charts/mergeable/values.yaml b/charts/mergeable/values.yaml index 0906e91..aec3e56 100644 --- a/charts/mergeable/values.yaml +++ b/charts/mergeable/values.yaml @@ -56,12 +56,15 @@ service: ingress: enabled: false + className: "" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - host: chart-example.local - paths: [] + paths: + - path: / + pathType: ImplementationSpecific tls: [] # - secretName: chart-example-tls # hosts: diff --git a/charts/nginx/.helmignore b/charts/nginx/.helmignore index 50af031..0e8a0eb 100644 --- a/charts/nginx/.helmignore +++ b/charts/nginx/.helmignore @@ -14,6 +14,7 @@ *.swp *.bak *.tmp +*.orig *~ # Various IDEs .project diff --git a/charts/nginx/Chart.yaml b/charts/nginx/Chart.yaml index 8119f10..08d9b12 100644 --- a/charts/nginx/Chart.yaml +++ b/charts/nginx/Chart.yaml @@ -4,6 +4,7 @@ home: https://nginx.org/ description: A Helm chart for Kubernetes maintainers: - name: douban + # A chart can be either an 'application' or a 'library' chart. # # Application charts are a collection of templates that can be packaged into versioned archives @@ -16,7 +17,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 0.1.2 +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.2.0 -# This is actually not used. -appVersion: 0.16.0 +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/nginx/templates/NOTES.txt b/charts/nginx/templates/NOTES.txt index d3dd58b..918bb64 100644 --- a/charts/nginx/templates/NOTES.txt +++ b/charts/nginx/templates/NOTES.txt @@ -2,7 +2,7 @@ {{- if .Values.ingress.enabled }} {{- range $host := .Values.ingress.hosts }} {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} {{- end }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} @@ -16,6 +16,7 @@ echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "nginx.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT {{- end }} diff --git a/charts/nginx/templates/_helpers.tpl b/charts/nginx/templates/_helpers.tpl index 4a7640b..ad9f432 100644 --- a/charts/nginx/templates/_helpers.tpl +++ b/charts/nginx/templates/_helpers.tpl @@ -1,10 +1,9 @@ -{{/* vim: set filetype=mustache: */}} {{/* Expand the name of the chart. */}} {{- define "nginx.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Create a default fully qualified app name. @@ -12,24 +11,24 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "nginx.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} {{/* Create chart name and version as used by the chart label. */}} {{- define "nginx.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Common labels @@ -41,7 +40,7 @@ helm.sh/chart: {{ include "nginx.chart" . }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end -}} +{{- end }} {{/* Selector labels @@ -49,15 +48,15 @@ Selector labels {{- define "nginx.selectorLabels" -}} app.kubernetes.io/name: {{ include "nginx.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} +{{- end }} {{/* Create the name of the service account to use */}} {{- define "nginx.serviceAccountName" -}} -{{- if .Values.serviceAccount.create -}} - {{ default (include "nginx.fullname" .) .Values.serviceAccount.name }} -{{- else -}} - {{ default "default" .Values.serviceAccount.name }} -{{- end -}} -{{- end -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "nginx.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/nginx/templates/deployment.yaml b/charts/nginx/templates/deployment.yaml index a33f6d8..27a46f8 100644 --- a/charts/nginx/templates/deployment.yaml +++ b/charts/nginx/templates/deployment.yaml @@ -5,19 +5,25 @@ metadata: labels: {{- include "nginx.labels" . | nindent 4 }} spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} + {{- end }} selector: matchLabels: {{- include "nginx.selectorLabels" . | nindent 6 }} template: metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} labels: {{- include "nginx.selectorLabels" . | nindent 8 }} spec: - {{- with .Values.imagePullSecrets }} + {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} serviceAccountName: {{ include "nginx.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} @@ -25,7 +31,7 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http @@ -45,11 +51,11 @@ spec: nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.affinity }} + {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} + {{- end }} + {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} diff --git a/charts/nginx/templates/hpa.yaml b/charts/nginx/templates/hpa.yaml new file mode 100644 index 0000000..9af6c1b --- /dev/null +++ b/charts/nginx/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "nginx.fullname" . }} + labels: + {{- include "nginx.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "nginx.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/nginx/templates/ingress.yaml b/charts/nginx/templates/ingress.yaml index a539cee..fc6576a 100644 --- a/charts/nginx/templates/ingress.yaml +++ b/charts/nginx/templates/ingress.yaml @@ -1,7 +1,14 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "nginx.fullname" . -}} {{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1beta1 {{- else -}} apiVersion: extensions/v1beta1 @@ -16,26 +23,39 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: -{{- if .Values.ingress.tls }} + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} tls: - {{- range .Values.ingress.tls }} + {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} + {{- range .hosts }} - {{ . | quote }} - {{- end }} + {{- end }} secretName: {{ .secretName }} + {{- end }} {{- end }} -{{- end }} rules: - {{- range .Values.ingress.hosts }} + {{- range .Values.ingress.hosts }} - host: {{ .host | quote }} http: paths: - {{- range .paths }} - - path: {{ . }} + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} serviceName: {{ $fullName }} servicePort: {{ $svcPort }} - {{- end }} - {{- end }} + {{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/nginx/templates/serviceaccount.yaml b/charts/nginx/templates/serviceaccount.yaml index f33e516..3650603 100644 --- a/charts/nginx/templates/serviceaccount.yaml +++ b/charts/nginx/templates/serviceaccount.yaml @@ -4,5 +4,9 @@ kind: ServiceAccount metadata: name: {{ include "nginx.serviceAccountName" . }} labels: -{{ include "nginx.labels" . | nindent 4 }} -{{- end -}} + {{- include "nginx.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/nginx/templates/tests/test-connection.yaml b/charts/nginx/templates/tests/test-connection.yaml index cf00c1a..5879b4f 100644 --- a/charts/nginx/templates/tests/test-connection.yaml +++ b/charts/nginx/templates/tests/test-connection.yaml @@ -3,13 +3,13 @@ kind: Pod metadata: name: "{{ include "nginx.fullname" . }}-test-connection" labels: -{{ include "nginx.labels" . | nindent 4 }} + {{- include "nginx.labels" . | nindent 4 }} annotations: - "helm.sh/hook": test-success + "helm.sh/hook": test spec: containers: - name: wget image: busybox command: ['wget'] - args: ['{{ include "nginx.fullname" . }}:{{ .Values.service.port }}'] + args: ['{{ include "nginx.fullname" . }}:{{ .Values.service.port }}'] restartPolicy: Never diff --git a/charts/nginx/values.yaml b/charts/nginx/values.yaml index 64a289f..e7d6408 100644 --- a/charts/nginx/values.yaml +++ b/charts/nginx/values.yaml @@ -6,8 +6,9 @@ replicaCount: 1 image: repository: nginx - tag: 0.16.0 pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" imagePullSecrets: [] nameOverride: "" @@ -16,9 +17,13 @@ fullnameOverride: "" serviceAccount: # Specifies whether a service account should be created create: true + # Annotations to add to the service account + annotations: {} # The name of the service account to use. # If not set and create is true, a name is generated using the fullname template - name: + name: "" + +podAnnotations: {} podSecurityContext: {} # fsGroup: 2000 @@ -37,12 +42,15 @@ service: ingress: enabled: false + className: "" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - host: chart-example.local - paths: [] + paths: + - path: / + pathType: ImplementationSpecific tls: [] # - secretName: chart-example-tls # hosts: @@ -60,6 +68,13 @@ resources: {} # cpu: 100m # memory: 128Mi +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + nodeSelector: {} tolerations: [] diff --git a/charts/overlord/Chart.yaml b/charts/overlord/Chart.yaml index e109634..ee3dd4b 100644 --- a/charts/overlord/Chart.yaml +++ b/charts/overlord/Chart.yaml @@ -21,7 +21,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 0.1.0 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. diff --git a/charts/overlord/templates/ingress.yaml b/charts/overlord/templates/ingress.yaml index fbd45da..bbc5597 100644 --- a/charts/overlord/templates/ingress.yaml +++ b/charts/overlord/templates/ingress.yaml @@ -1,7 +1,14 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "overlord.fullname" . -}} {{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1beta1 {{- else -}} apiVersion: extensions/v1beta1 @@ -16,30 +23,39 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: -{{- if .Values.ingress.tls }} + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} tls: - {{- range .Values.ingress.tls }} + {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} + {{- range .hosts }} - {{ . | quote }} - {{- end }} + {{- end }} secretName: {{ .secretName }} + {{- end }} {{- end }} -{{- end }} rules: - {{- range .Values.ingress.hosts }} + {{- range .Values.ingress.hosts }} - host: {{ .host | quote }} http: paths: - {{- range .paths }} - - path: {{ . }}api/ + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} backend: - serviceName: {{ $fullName }}-apiserver + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} servicePort: {{ $svcPort }} - - path: {{ . }} - backend: - serviceName: {{ $fullName }}-web - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} + {{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/overlord/values.yaml b/charts/overlord/values.yaml index 436525d..f1a8faf 100644 --- a/charts/overlord/values.yaml +++ b/charts/overlord/values.yaml @@ -49,12 +49,15 @@ service: ingress: enabled: false + className: "" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - host: chart-example.local - paths: [] + paths: + - path: / + pathType: ImplementationSpecific tls: [] # - secretName: chart-example-tls # hosts: