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

helm: Update Ingress and HPA manifests to support modern K8s versions #13806

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ integration-tests/gen-scripts/
/bin/
*.hprof
**/.ipynb_checkpoints/
helm/druid/charts
website/.yarn/
website/node_modules/
website/.docusaurus/
Expand Down
2 changes: 1 addition & 1 deletion helm/druid/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies:
version: 8.6.4
repository: https://charts.helm.sh/stable
condition: postgresql.enabled
version: 0.3.5
version: 0.3.6
home: https://druid.apache.org/
icon: https://druid.apache.org/img/favicon.png
sources:
Expand Down
18 changes: 18 additions & 0 deletions helm/druid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ The following table lists the configurable parameters of the Druid chart and the
| `broker.ingress.hosts` | hosts for the broker api | `[ "chart-example.local" ]` |
| `broker.ingress.path` | path of the broker api | `/` |
| `broker.ingress.annotations` | annotations for the broker api ingress | `{}` |
| `broker.ingress.labels` | labels for the broker api ingress | `{}` |
| `broker.ingress.ingressClassName` | ingressClassName of the broker api ingress | `` |
| `broker.ingress.pathType` | pathType of the broker api ingress | `` |
| `broker.ingress.tls` | TLS configuration for the ingress | `[]` |
| `coordinator.enabled` | enable coordinator | `true` |
| `coordinator.name` | coordinator component name | `coordinator` |
Expand All @@ -138,6 +141,9 @@ The following table lists the configurable parameters of the Druid chart and the
| `coordinator.ingress.hosts` | hosts for the coordinator api | `[ "chart-example.local" ]` |
| `coordinator.ingress.path` | path of the coordinator api | `/` |
| `coordinator.ingress.annotations` | annotations for the coordinator api ingress | `{}` |
| `coordinator.ingress.labels` | labels for the coordinator api ingress | `{}` |
| `coordinator.ingress.ingressClassName` | ingressClassName of the coordinator api ingress | `` |
| `coordinator.ingress.pathType` | pathType of the coordinator api ingress | `` |
| `coordinator.ingress.tls` | TLS configuration for the ingress | `[]` |
| `overlord.enabled` | enable overlord | `false` |
| `overlord.name` | overlord component name | `overlord` |
Expand All @@ -159,6 +165,9 @@ The following table lists the configurable parameters of the Druid chart and the
| `overlord.ingress.hosts` | hosts for the overlord api | `[ "chart-example.local" ]` |
| `overlord.ingress.path` | path of the overlord api | `/` |
| `overlord.ingress.annotations` | annotations for the overlord api ingress | `{}` |
| `overlord.ingress.labels` | labels for the overlord api ingress | `{}` |
| `overlord.ingress.ingressClassName` | ingressClassName of the overlord api ingress | `` |
| `overlord.ingress.pathType` | pathType of the overlord api ingress | `` |
| `overlord.ingress.tls` | TLS configuration for the ingress | `[]` |
| `historical.enabled` | enable historical | `true` |
| `historical.name` | historical component name | `historical` |
Expand Down Expand Up @@ -188,6 +197,9 @@ The following table lists the configurable parameters of the Druid chart and the
| `historical.ingress.hosts` | hosts for the historical api | `[ "chart-example.local" ]` |
| `historical.ingress.path` | path of the historical api | `/` |
| `historical.ingress.annotations` | annotations for the historical api ingress | `{}` |
| `historical.ingress.labels` | labels for the historical api ingress | `{}` |
| `historical.ingress.ingressClassName` | ingressClassName of the historical api ingress | `` |
| `historical.ingress.pathType` | pathType of the historical api ingress | `` |
| `historical.ingress.tls` | TLS configuration for the ingress | `[]` |
| `middleManager.enabled` | enable middleManager | `true` |
| `middleManager.name` | middleManager component name | `middleManager` |
Expand Down Expand Up @@ -219,6 +231,9 @@ The following table lists the configurable parameters of the Druid chart and the
| `middleManager.ingress.hosts` | hosts for the middleManager api | `[ "chart-example.local" ]` |
| `middleManager.ingress.path` | path of the middleManager api | `/` |
| `middleManager.ingress.annotations` | annotations for the middleManager api ingress | `{}` |
| `middleManager.ingress.labels` | labels for the middleManager api ingress | `{}` |
| `middleManager.ingress.ingressClassName` | ingressClassName of the middleManager api ingress | `` |
| `middleManager.ingress.pathType` | pathType of the middleManager api ingress | `` |
| `middleManager.ingress.tls` | TLS configuration for the ingress | `[]` |
| `router.enabled` | enable router | `false` |
| `router.name` | router component name | `router` |
Expand All @@ -240,6 +255,9 @@ The following table lists the configurable parameters of the Druid chart and the
| `router.ingress.hosts` | hosts for the router api | `[ "chart-example.local" ]` |
| `router.ingress.path` | path of the router api | `/` |
| `router.ingress.annotations` | annotations for the router api ingress | `{}` |
| `router.ingress.labels` | labels for the router api ingress | `{}` |
| `router.ingress.ingressClassName` | ingressClassName of the router api ingress | `` |
| `router.ingress.pathType` | pathType of the router api ingress | `` |
| `router.ingress.tls` | TLS configuration for the ingress | `[]` |
| `prometheus.enabled` | Support scraping from prometheus | `false` |
| `prometheus.port` | expose prometheus port | `9090` |
Expand Down
45 changes: 40 additions & 5 deletions helm/druid/templates/_capabilities.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,47 @@ Return the target Kubernetes version
{{- end -}}

{{/*
Return the appropriate apiVersion for poddisruptionbudget.
Return the appropriate apiVersion for podDisruptionBudget.
*/}}
{{- define "capabilities.policy.apiVersion" -}}
{{- if semverCompare "<1.21-0" (include "capabilities.kubeVersion" .) -}}
{{- print "policy/v1beta1" -}}
{{- else -}}
{{- print "policy/v1" -}}
{{- if semverCompare "<1.21-0" (include "capabilities.kubeVersion" .) -}}
{{- print "policy/v1beta1" -}}
{{- else -}}
{{- print "policy/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion and manifest format for ingress
*/}}
{{- define "capabilities.ingress.apiVersion" -}}
{{- if semverCompare "<1.14-0" (include "capabilities.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" (include "capabilities.kubeVersion" .) -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end }}
{{- end -}}

{{/* Check Ingress stability */}}
{{- define "capabilities.ingress.isStable" -}}
{{- eq (include "capabilities.ingress.apiVersion" .) "networking.k8s.io/v1" -}}
{{- end -}}

{{/* Check Ingress supports pathType */}}
{{/* pathType was added to networking.k8s.io/v1beta1 in Kubernetes 1.18 */}}
{{- define "capabilities.ingress.supportsPathType" -}}
{{- or (eq (include "capabilities.ingress.isStable" .) "true") (and (eq (include "capabilities.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" (include "capabilities.kubeVersion" .))) -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for Horizontal Pod Autoscaler.
*/}}
{{- define "capabilities.hpa.apiVersion" -}}
{{- if semverCompare "<1.23-0" (include "capabilities.kubeVersion" .) -}}
{{- print "autoscaling/v2beta2" -}}
{{- else -}}
{{- print "autoscaling/v2" -}}
{{- end -}}
{{- end -}}
38 changes: 30 additions & 8 deletions helm/druid/templates/broker/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

{{- if .Values.broker.ingress.enabled -}}
{{- $fullName := include "druid.broker.fullname" . -}}
{{- $svcPort := .Values.broker.port -}}
{{- $ingressPath := .Values.broker.ingress.path -}}
apiVersion: extensions/v1beta1
{{- $ingressPathType := .Values.broker.ingress.pathType | default "ImplementationSpecific" -}}
{{- $apiIsStable := eq (include "capabilities.ingress.isStable" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "capabilities.ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "capabilities.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -30,29 +34,47 @@ metadata:
component: {{ .Values.broker.name }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.broker.ingress.annotations }}
{{- with .Values.broker.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.broker.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.broker.ingress.tls }}
{{- if $apiIsStable }}
{{- if .Values.broker.ingress.ingressClassName }}
ingressClassName: {{ .Values.broker.ingress.ingressClassName }}
{{- end }}
{{- end }}
{{- if .Values.broker.ingress.tls }}
tls:
{{- range .Values.broker.ingress.tls }}
{{- range .Values.broker.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .Values.broker.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
{{- if and $ingressPathType $ingressSupportsPathType }}
pathType: {{ $ingressPathType }}
{{- end }}
backend:
{{- if $apiIsStable }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
38 changes: 30 additions & 8 deletions helm/druid/templates/coordinator/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

{{- if .Values.coordinator.ingress.enabled -}}
{{- $fullName := include "druid.coordinator.fullname" . -}}
{{- $svcPort := .Values.coordinator.port -}}
{{- $ingressPath := .Values.coordinator.ingress.path -}}
apiVersion: extensions/v1beta1
{{- $ingressPathType := .Values.coordinator.ingress.pathType | default "ImplementationSpecific" -}}
{{- $apiIsStable := eq (include "capabilities.ingress.isStable" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "capabilities.ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "capabilities.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -30,29 +34,47 @@ metadata:
component: {{ .Values.coordinator.name }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.coordinator.ingress.annotations }}
{{- with .Values.coordinator.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.coordinator.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.coordinator.ingress.tls }}
{{- if $apiIsStable }}
{{- if .Values.coordinator.ingress.ingressClassName }}
ingressClassName: {{ .Values.coordinator.ingress.ingressClassName }}
{{- end }}
{{- end }}
{{- if .Values.coordinator.ingress.tls }}
tls:
{{- range .Values.coordinator.ingress.tls }}
{{- range .Values.coordinator.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .Values.coordinator.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
{{- if and $ingressPathType $ingressSupportsPathType }}
pathType: {{ $ingressPathType }}
{{- end }}
backend:
{{- if $apiIsStable }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
38 changes: 30 additions & 8 deletions helm/druid/templates/historical/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

{{- if .Values.historical.ingress.enabled -}}
{{- $fullName := include "druid.historical.fullname" . -}}
{{- $svcPort := .Values.historical.port -}}
{{- $ingressPath := .Values.historical.ingress.path -}}
apiVersion: extensions/v1beta1
{{- $ingressPathType := .Values.historical.ingress.pathType | default "ImplementationSpecific" -}}
{{- $apiIsStable := eq (include "capabilities.ingress.isStable" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "capabilities.ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "capabilities.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -30,29 +34,47 @@ metadata:
component: {{ .Values.historical.name }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.historical.ingress.annotations }}
{{- with .Values.historical.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.historical.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.historical.ingress.tls }}
{{- if $apiIsStable }}
{{- if .Values.historical.ingress.ingressClassName }}
ingressClassName: {{ .Values.historical.ingress.ingressClassName }}
{{- end }}
{{- end }}
{{- if .Values.historical.ingress.tls }}
tls:
{{- range .Values.historical.ingress.tls }}
{{- range .Values.historical.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .Values.historical.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
{{- if and $ingressPathType $ingressSupportsPathType }}
pathType: {{ $ingressPathType }}
{{- end }}
backend:
{{- if $apiIsStable }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions helm/druid/templates/middleManager/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/}}

{{- if .Values.middleManager.autoscaling.enabled }}
apiVersion: autoscaling/v2beta2
apiVersion: {{ include "capabilities.hpa.apiVersion" . }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "druid.middleManager.fullname" . }}
Expand All @@ -36,5 +36,5 @@ spec:
minReplicas: {{ .Values.middleManager.autoscaling.minReplicas }}
maxReplicas: {{ .Values.middleManager.autoscaling.maxReplicas }}
metrics:
{{ toYaml .Values.middleManager.autoscaling.metrics | indent 4 }}
{{- toYaml .Values.middleManager.autoscaling.metrics | nindent 4 }}
{{- end }}