ingress.yaml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {{- if .Values.ingress.enabled -}}
  2. {{- $fullName := include "mastodon.fullname" . -}}
  3. {{- $webPort := .Values.mastodon.web.port -}}
  4. {{- $streamingPort := .Values.mastodon.streaming.port -}}
  5. {{- if or (.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not (.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) -}}
  6. apiVersion: networking.k8s.io/v1
  7. {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
  8. apiVersion: networking.k8s.io/v1beta1
  9. {{- else -}}
  10. apiVersion: extensions/v1beta1
  11. {{- end }}
  12. kind: Ingress
  13. metadata:
  14. name: {{ $fullName }}
  15. labels:
  16. {{- include "mastodon.labels" . | nindent 4 }}
  17. {{- with .Values.ingress.annotations }}
  18. annotations:
  19. {{- toYaml . | nindent 4 }}
  20. {{- end }}
  21. spec:
  22. {{- if .Values.ingress.ingressClassName }}
  23. ingressClassName: {{ .Values.ingress.ingressClassName }}
  24. {{- end }}
  25. {{- if .Values.ingress.tls }}
  26. tls:
  27. {{- range .Values.ingress.tls }}
  28. - hosts:
  29. {{- range .hosts }}
  30. - {{ . | quote }}
  31. {{- end }}
  32. secretName: {{ .secretName }}
  33. {{- end }}
  34. {{- end }}
  35. rules:
  36. {{- range .Values.ingress.hosts }}
  37. - host: {{ .host | quote }}
  38. http:
  39. paths:
  40. {{- range .paths }}
  41. - path: {{ .path }}
  42. backend:
  43. {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  44. service:
  45. name: {{ $fullName }}-web
  46. port:
  47. number: {{ $webPort }}
  48. {{- else }}
  49. serviceName: {{ $fullName }}-web
  50. servicePort: {{ $webPort }}
  51. {{- end }}
  52. {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  53. pathType: Prefix
  54. {{- end }}
  55. - path: {{ .path }}api/v1/streaming/
  56. backend:
  57. {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  58. service:
  59. name: {{ $fullName }}-streaming
  60. port:
  61. number: {{ $streamingPort }}
  62. {{- else }}
  63. serviceName: {{ $fullName }}-streaming
  64. servicePort: {{ $streamingPort }}
  65. {{- end }}
  66. {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  67. pathType: Exact
  68. {{- end }}
  69. {{- end }}
  70. {{- end }}
  71. {{- end }}