ingress.yaml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. {{- if .Values.ingress.enabled }}
  2. {{- if or (.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not (.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  3. apiVersion: networking.k8s.io/v1
  4. {{- else }}
  5. apiVersion: networking.k8s.io/v1beta1
  6. {{- end }}
  7. kind: Ingress
  8. metadata:
  9. name: {{ template "rancher.fullname" . }}
  10. labels:
  11. {{ include "rancher.labels" . | indent 4 }}
  12. annotations:
  13. {{- if .Values.ingress.configurationSnippet }}
  14. nginx.ingress.kubernetes.io/configuration-snippet: |
  15. {{- template "configurationSnippet" . }}
  16. {{- end }}
  17. {{- if eq .Values.tls "external" }}
  18. nginx.ingress.kubernetes.io/ssl-redirect: "false" # turn off ssl redirect for external.
  19. {{- else }}
  20. {{- if ne .Values.ingress.tls.source "secret" }}
  21. {{- $certmanagerVer := split "." .Values.certmanager.version -}}
  22. {{- if or (.Capabilities.APIVersions.Has "certmanager.k8s.io/v1alpha1") (and (gt (len $certmanagerVer._0) 0) (eq (int $certmanagerVer._0) 0) (lt (int $certmanagerVer._1) 11)) }}
  23. certmanager.k8s.io/issuer: {{ template "rancher.fullname" . }}
  24. {{- else }}
  25. cert-manager.io/issuer: {{ template "rancher.fullname" . }}
  26. cert-manager.io/issuer-kind: Issuer
  27. {{- end }}
  28. {{- end }}
  29. {{- end }}
  30. {{- if .Values.ingress.includeDefaultExtraAnnotations }}
  31. nginx.ingress.kubernetes.io/proxy-connect-timeout: "30"
  32. nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"
  33. nginx.ingress.kubernetes.io/proxy-send-timeout: "1800"
  34. {{- end }}
  35. {{- if .Values.ingress.extraAnnotations }}
  36. {{ toYaml .Values.ingress.extraAnnotations | indent 4 }}
  37. {{- end }}
  38. spec:
  39. {{- if .Values.ingress.ingressClassName }}
  40. ingressClassName: {{ .Values.ingress.ingressClassName }}
  41. {{- end }}
  42. rules:
  43. - host: {{ .Values.hostname }} # hostname to access rancher server
  44. http:
  45. paths:
  46. - backend:
  47. {{- if or (.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not (.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  48. service:
  49. name: {{ template "rancher.fullname" . }}
  50. port:
  51. number: {{ .Values.ingress.servicePort }}
  52. {{- else }}
  53. serviceName: {{ template "rancher.fullname" . }}
  54. servicePort: {{ .Values.ingress.servicePort }}
  55. {{- end }}
  56. {{- if or (.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (not (.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress")) }}
  57. pathType: ImplementationSpecific
  58. {{- end }}
  59. {{- if eq .Values.tls "ingress" }}
  60. tls:
  61. - hosts:
  62. - {{ .Values.hostname }}
  63. secretName: {{ .Values.ingress.tls.secretName }}
  64. {{- end }}
  65. {{- end }}