Skip to content

Commit

Permalink
[Graphite]: fix #443
Browse files Browse the repository at this point in the history
- template ingress in all api versions and add ingress class
  • Loading branch information
dabo committed Feb 1, 2022
1 parent 68b6ed2 commit 21a8e52
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/graphite/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
version: 0.7.2
version: 0.7.3
appVersion: "1.1.7-6"
description: Graphite metrics server
name: graphite
Expand Down
2 changes: 1 addition & 1 deletion charts/graphite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The following table lists the configurable parameters of the Graphite chart and
| `resources` | Resource limits for Graphite pod | `{}` |
| `ingress.enabled` | Ingress enabled | `false` |
| `ingress.annotations` | Ingress annotations | `{}` |
| `ingress.path` | Ingress path | `/` |
| `ingress.className` | Ingress class | `nil` |
| `ingress.hosts` | Ingress hosts | `[]` |
| `ingress.tls` | Ingress TLS | `[]` |
| `resources` | Resources | `{}` |
Expand Down
37 changes: 32 additions & 5 deletions charts/graphite/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "graphite.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 }}
Expand All @@ -15,6 +27,9 @@ metadata:
{{ toYaml . | indent 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 }}
Expand All @@ -26,13 +41,25 @@ spec:
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
{{- 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: {{ $.Values.service.port }}
{{- end }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
13 changes: 10 additions & 3 deletions charts/graphite/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ ingress:
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- chart-example.local
## IngressClassName is the name of the IngressClass cluster resource. The
## associated IngressClass defines which controller will implement the
## resource. This replaces the deprecated `kubernetes.io/ingress.class`
## annotation.
className: ""
hosts: []
# - host: chart-example.local
# paths:
# - path: /
# pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
Expand Down

0 comments on commit 21a8e52

Please sign in to comment.