feat: update healthchecks helm chart by making templating related changes in ingress

main
Shyam Vyas 2022-08-24 18:41:55 +05:30
parent f21418a2d2
commit 414ab02fd1
4 changed files with 61 additions and 29 deletions

View File

@ -1,6 +1,6 @@
dependencies: dependencies:
- name: postgresql - name: postgresql
repository: https://charts.bitnami.com/bitnami repository: https://charts.bitnami.com/bitnami
version: 9.1.1 version: 10.14.3
digest: sha256:4949a7dab1ae4d5ba4f6ecf12667c6b720d385d66d97f14af018e864da292cd7 digest: sha256:f523a047b9e2ae36143e7ae661f0a08ebfa4df65f1b7e757f4acd6888dd7642f
generated: "2021-05-14T10:33:25.768505088+05:30" generated: "2022-08-24T18:21:08.145589508+05:30"

View File

@ -1,10 +1,10 @@
version: 1.0.5 version: 1.0.6
apiVersion: v2 apiVersion: v2
name: healthchecks name: healthchecks
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
maintainers: maintainers:
- email: pratik@improeised.com - email: rakshit@improwised.com
name: praitk name: rakshit
# A chart can be either an 'application' or a 'library' chart. # 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 # Application charts are a collection of templates that can be packaged into versioned archives
@ -26,6 +26,6 @@ sources:
- https://github.com/healthchecks/healthchecks - https://github.com/healthchecks/healthchecks
dependencies: dependencies:
- name: postgresql - name: postgresql
version: 9.1.1 version: 10.14.3
repository: https://charts.bitnami.com/bitnami repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled,global.postgresql.enabled condition: postgresql.enabled,global.postgresql.enabled

View File

@ -50,3 +50,40 @@ Selector labels
app.kubernetes.io/name: {{ include "healthchecks.name" . }} app.kubernetes.io/name: {{ include "healthchecks.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }} {{- end }}
{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "ingress.apiVersion" -}}
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.Version -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end -}}
{{- end -}}
{{- define "ingress.backend" -}}
{{- $apiVersion := (include "ingress.apiVersion" .context) -}}
{{- if or (eq $apiVersion "extensions/v1beta1") (eq $apiVersion "networking.k8s.io/v1beta1") -}}
serviceName: {{ .serviceName }}
servicePort: {{ .servicePort }}
{{- else -}}
service:
name: {{ .serviceName }}
port:
{{- if typeIs "string" .servicePort }}
name: {{ .servicePort }}
{{- else if or (typeIs "int" .servicePort) (typeIs "float64" .servicePort) }}
number: {{ .servicePort | int }}
{{- end }}
{{- end -}}
{{- end -}}
{{- define "ingress.pathtype" -}}
{{- $apiVersion := (include "ingress.apiVersion" .) -}}
{{- if (eq $apiVersion "networking.k8s.io/v1") -}}
pathType: ImplementationSpecific
{{- end -}}
{{- end -}}

View File

@ -1,11 +1,7 @@
{{- if .Values.ingress.enabled -}} {{- if .Values.ingress.enabled -}}
{{- $fullName := include "healthchecks.fullname" . -}} {{- $fullName := include "healthchecks.fullname" . -}}
{{- $svcPort := .Values.service.port -}} {{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: {{ include "ingress.apiVersion" . }}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress kind: Ingress
metadata: metadata:
name: {{ $fullName }} name: {{ $fullName }}
@ -18,24 +14,23 @@ metadata:
spec: spec:
{{- if .Values.ingress.tls }} {{- if .Values.ingress.tls }}
tls: tls:
{{- range .Values.ingress.tls }} {{- range .Values.ingress.tls }}
- hosts: - hosts:
{{- range .hosts }} {{- range .hosts }}
- {{ . | quote }} - {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }} {{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }} {{- end }}
rules: rules:
{{- range .Values.ingress.hosts }} {{- range .Values.ingress.hosts }}
- host: {{ .host | quote }} - host: {{ .host | quote }}
http: http:
paths: paths:
{{- range .paths }} {{- range .paths }}
- path: {{ . }} - path: {{ .path }}
backend: pathType: {{ .pathType }}
serviceName: {{ $fullName }} backend: {{- include "ingress.backend" (dict "serviceName" $fullName "servicePort" $svcPort "context" $) | nindent 10 }}
servicePort: {{ $svcPort }} {{- end }}
{{- end }}
{{- end }}
{{- end }} {{- end }}
{{- end }}