ingress.yaml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.tls }}
  23. tls:
  24. {{- range .Values.ingress.tls }}
  25. - hosts:
  26. {{- range .hosts }}
  27. - {{ . | quote }}
  28. {{- end }}
  29. secretName: {{ .secretName }}
  30. {{- end }}
  31. {{- end }}
  32. rules:
  33. {{- range .Values.ingress.hosts }}
  34. - host: {{ .host | quote }}
  35. http:
  36. paths:
  37. {{- range .paths }}
  38. - path: {{ .path }}
  39. backend:
  40. {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  41. service:
  42. name: {{ $fullName }}-web
  43. port:
  44. number: {{ $webPort }}
  45. {{- else }}
  46. serviceName: {{ $fullName }}-web
  47. servicePort: {{ $webPort }}
  48. {{- end }}
  49. {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  50. pathType: ImplementationSpecific
  51. {{- end }}
  52. - path: {{ .path }}api/v1/streaming
  53. backend:
  54. {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  55. service:
  56. name: {{ $fullName }}-streaming
  57. port:
  58. number: {{ $streamingPort }}
  59. {{- else }}
  60. serviceName: {{ $fullName }}-streaming
  61. servicePort: {{ $streamingPort }}
  62. {{- end }}
  63. {{- if or ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not ($.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  64. pathType: ImplementationSpecific
  65. {{- end }}
  66. {{- end }}
  67. {{- end }}
  68. {{- end }}