ingress.yaml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {{- if .Values.ingress.enabled -}}
  2. {{- $ingressApiIsStable := eq (include "grafana.ingress.isStable" .) "true" -}}
  3. {{- $ingressSupportsIngressClassName := eq (include "grafana.ingress.supportsIngressClassName" .) "true" -}}
  4. {{- $ingressSupportsPathType := eq (include "grafana.ingress.supportsPathType" .) "true" -}}
  5. {{- $fullName := include "grafana.fullname" . -}}
  6. {{- $servicePort := .Values.service.port -}}
  7. {{- $ingressPath := .Values.ingress.path -}}
  8. {{- $ingressPathType := .Values.ingress.pathType -}}
  9. {{- $extraPaths := .Values.ingress.extraPaths -}}
  10. apiVersion: {{ include "grafana.ingress.apiVersion" . }}
  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 and $ingressSupportsIngressClassName .Values.ingress.ingressClassName }}
  28. ingressClassName: {{ .Values.ingress.ingressClassName }}
  29. {{- end -}}
  30. {{- if .Values.ingress.tls }}
  31. tls:
  32. {{ tpl (toYaml .Values.ingress.tls) $ | indent 4 }}
  33. {{- end }}
  34. rules:
  35. {{- if .Values.ingress.hosts }}
  36. {{- range .Values.ingress.hosts }}
  37. - host: {{ tpl . $}}
  38. http:
  39. paths:
  40. {{- if $extraPaths }}
  41. {{ toYaml $extraPaths | indent 10 }}
  42. {{- end }}
  43. - path: {{ $ingressPath }}
  44. {{- if $ingressSupportsPathType }}
  45. pathType: {{ $ingressPathType }}
  46. {{- end }}
  47. backend:
  48. {{- if $ingressApiIsStable }}
  49. service:
  50. name: {{ $fullName }}
  51. port:
  52. number: {{ $servicePort }}
  53. {{- else }}
  54. serviceName: {{ $fullName }}
  55. servicePort: {{ $servicePort }}
  56. {{- end }}
  57. {{- end }}
  58. {{- else }}
  59. - http:
  60. paths:
  61. - backend:
  62. {{- if $ingressApiIsStable }}
  63. service:
  64. name: {{ $fullName }}
  65. port:
  66. number: {{ $servicePort }}
  67. {{- else }}
  68. serviceName: {{ $fullName }}
  69. servicePort: {{ $servicePort }}
  70. {{- end }}
  71. {{- if $ingressPath }}
  72. path: {{ $ingressPath }}
  73. {{- end }}
  74. {{- if $ingressSupportsPathType }}
  75. pathType: {{ $ingressPathType }}
  76. {{- end }}
  77. {{- end -}}
  78. {{- end }}