Skip to content

Commit

Permalink
Autodetect apiVersion for Ingress (#205)
Browse files Browse the repository at this point in the history
* Autodetect apiVersion for Ingress

* Bump chart version

* Simplified
  • Loading branch information
dex4er authored May 17, 2021
1 parent 2ed0b16 commit 9655b51
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/netdata/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: netdata
version: 3.6.7
version: 3.6.8
description: Real-time performance monitoring, done right!
type: application
keywords:
Expand Down
2 changes: 2 additions & 0 deletions charts/netdata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The following table lists the configurable parameters of the netdata chart and t

| Parameter | Description | Default |
|------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| `kubeVersion` | Kubernetes version | Autodetected |
| `replicaCount` | Number of `replicas` for the parent netdata `Deployment` | `1` |
| `image.repository` | Container image repo | `netdata/netdata` |
| `image.tag` | Container image tag | Latest stable netdata release (e.g. `v1.30.1`) |
Expand All @@ -95,6 +96,7 @@ The following table lists the configurable parameters of the netdata chart and t
| `service.clusterIP` | Specific cluster IP when service type is cluster IP. Use `None` for headless service | Allocated an IP from your cluster's service IP range |
| `service.annotations` | Additional annotations to add to the service | `{}` |
| `ingress.enabled` | Create Ingress to access the netdata web UI | `true` |
| `ingress.apiVersion` | apiVersion for the Ingress | Depends on Kubernetes version |
| `ingress.annotations` | Associate annotations to the Ingress | `kubernetes.io/ingress.class: nginx` and `kubernetes.io/tls-acme: "true"` |
| `ingress.path` | URL path for the ingress | `/` |
| `ingress.hosts` | URL hostnames for the ingress (they need to resolve to the external IP of the ingress controller) | `netdata.k8s.local` |
Expand Down
22 changes: 22 additions & 0 deletions charts/netdata/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,25 @@ Create chart name and version as used by the chart label.
{{- define "netdata.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the target Kubernetes version
*/}}
{{- define "netdata.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "netdata.ingress.apiVersion" -}}
{{- if .Values.ingress.apiVersion -}}
{{- .Values.ingress.apiVersion -}}
{{- else if semverCompare "<1.14-0" (include "netdata.kubeVersion" .) -}}
{{- "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" (include "netdata.kubeVersion" .) -}}
{{- "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- "networking.k8s.io/v1" -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/netdata/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{- $fullName := include "netdata.name" . -}}
{{- $ingressPath := .Values.ingress.path -}}

apiVersion: extensions/v1beta1
apiVersion: {{ include "netdata.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand Down

0 comments on commit 9655b51

Please sign in to comment.