ingress.yaml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {{- if .Values.ingress.enabled -}}
  2. {{- $fullName := include "grafana.fullname" . -}}
  3. {{- $servicePort := .Values.service.port -}}
  4. {{- $ingressPath := .Values.ingress.path -}}
  5. {{- $extraPaths := .Values.ingress.extraPaths -}}
  6. {{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }}
  7. apiVersion: networking.k8s.io/v1beta1
  8. {{ else }}
  9. apiVersion: extensions/v1beta1
  10. {{ end -}}
  11. kind: Ingress
  12. metadata:
  13. name: {{ $fullName }}
  14. namespace: {{ template "grafana.namespace" . }}
  15. labels:
  16. {{- include "grafana.labels" . | nindent 4 }}
  17. {{- if .Values.ingress.labels }}
  18. {{ toYaml .Values.ingress.labels | indent 4 }}
  19. {{- end }}
  20. {{- if .Values.ingress.annotations }}
  21. annotations:
  22. {{- range $key, $value := .Values.ingress.annotations }}
  23. {{ $key }}: {{ tpl $value $ | quote }}
  24. {{- end }}
  25. {{- end }}
  26. spec:
  27. {{- if .Values.ingress.tls }}
  28. tls:
  29. {{ toYaml .Values.ingress.tls | indent 4 }}
  30. {{- end }}
  31. rules:
  32. {{- if .Values.ingress.hosts }}
  33. {{- range .Values.ingress.hosts }}
  34. - host: {{ . }}
  35. http:
  36. paths:
  37. {{ if $extraPaths }}
  38. {{ toYaml $extraPaths | indent 10 }}
  39. {{- end }}
  40. - path: {{ $ingressPath }}
  41. backend:
  42. serviceName: {{ $fullName }}
  43. servicePort: {{ $servicePort }}
  44. {{- end }}
  45. {{- else }}
  46. - http:
  47. paths:
  48. - backend:
  49. serviceName: {{ $fullName }}
  50. servicePort: {{ $servicePort }}
  51. {{- if $ingressPath }}
  52. path: {{ $ingressPath }}
  53. {{- end }}
  54. {{- end -}}
  55. {{- end }}