ingresses.yaml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {{- $name := .Chart.Name }}
  2. {{- range $index, $val := .Values.items }}
  3. {{- if eq $val.type "ingress" }}
  4. {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
  5. apiVersion: networking.k8s.io/v1
  6. {{- else }}
  7. apiVersion: networking.k8s.io/v1beta1
  8. {{- end }}
  9. kind: Ingress
  10. metadata:
  11. {{- if $val.type }}
  12. name: {{ $val.name | default (print $name "-" $val.type "-" $index) }}
  13. {{- else }}
  14. name: {{ $val.name | default (print $name "-ingress-" $index) }}
  15. {{- end }}
  16. labels:
  17. app: {{ $name }}
  18. tier: {{ $val.name | default (print $name "-ingress") }}
  19. {{- if or $val.annotations }}
  20. annotations:
  21. {{- if $val.annotations }}
  22. {{- toYaml $val.annotations | nindent 4 }}
  23. {{- end }}
  24. {{- else }}
  25. annotations:
  26. kubernetes.io/ingress.class: "nginx"
  27. nginx.ingress.kubernetes.io/proxy-body-size: 50m
  28. {{- end }}
  29. spec:
  30. {{- if and $val.tls $val.tls.enabled }}
  31. tls:
  32. - secretName: {{ $val.tls.name | default (print $name "-secret-tls") }}
  33. {{- end }}
  34. rules:
  35. {{- range $val.rules }}
  36. - host: {{ .host | quote }}
  37. http:
  38. paths:
  39. {{- range .http.paths }}
  40. - path: {{ .path | default "/" }}
  41. {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
  42. pathType: {{ .pathType | default (print "ImplementationSpecific") }}
  43. {{- end }}
  44. backend:
  45. {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
  46. service:
  47. name: {{ .backend.serviceName | default (print $name "-service" )}}
  48. port:
  49. number: {{ .backend.servicePort }}
  50. {{- else }}
  51. serviceName: {{ .backend.serviceName | default (print $name "-service") }}
  52. servicePort: {{ .backend.servicePort | default (print "3000") }}
  53. {{- end }}
  54. {{- end }}
  55. {{- end }}
  56. {{ print "---" }}
  57. {{- end }}{{- end }}
  58. {{- range $index, $val := .Values.items }}
  59. {{- if not (empty $val.containers) }}
  60. {{- range $Index, $Containers := $val.containers }}
  61. {{- if and $Containers.url (semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion) }}
  62. apiVersion: networking.k8s.io/v1
  63. kind: Ingress
  64. metadata:
  65. name: {{ $val.name | default (print $name "-ingress-" $index "-" $Index) }}
  66. labels:
  67. app: {{ $name }}
  68. tier: {{ $val.name | default (print $name "-ingress") }}
  69. annotations:
  70. kubernetes.io/ingress.class: "nginx"
  71. nginx.ingress.kubernetes.io/proxy-body-size: 50m
  72. spec:
  73. {{- if and $val.tls $val.tls.enabled }}
  74. tls:
  75. - secretName: {{ $val.tls.name | default (print $name "-secret-tls") }}
  76. {{- end }}
  77. rules:
  78. {{- range $indexPorts, $Ports := $Containers.ports }}
  79. - host: {{ $Containers.url | quote }}
  80. http:
  81. paths:
  82. - backend:
  83. {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
  84. service:
  85. name: {{ $val.name | default (print $name "-service-" $index "-" $Index) }}
  86. port:
  87. number: {{ printf "3%v%v%v" $index $Index $indexPorts }}
  88. {{- else }}
  89. serviceName: {{ $val.name | default (print $name "-service-" $index "-" $Index) }}
  90. servicePort: {{ printf "3%v%v%v" $index $Index $indexPorts }}
  91. {{- end }}
  92. path: {{ $Ports.path | default (print "/") }}
  93. {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
  94. pathType: ImplementationSpecific
  95. {{- end }}
  96. {{- end }}
  97. {{ print "---" }}
  98. {{- end }}{{- end }}{{- end }}{{- end }}