controller-service.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {{- if and .Values.controller.service.enabled .Values.controller.service.external.enabled -}}
  2. apiVersion: v1
  3. kind: Service
  4. metadata:
  5. annotations:
  6. {{- range $key, $value := .Values.controller.service.annotations }}
  7. {{ $key }}: {{ $value | quote }}
  8. {{- end }}
  9. labels:
  10. {{- include "ingress-nginx.labels" . | nindent 4 }}
  11. app.kubernetes.io/component: controller
  12. {{- if .Values.controller.service.labels }}
  13. {{- toYaml .Values.controller.service.labels | nindent 4 }}
  14. {{- end }}
  15. name: {{ include "ingress-nginx.controller.fullname" . }}
  16. namespace: {{ .Release.Namespace }}
  17. spec:
  18. type: {{ .Values.controller.service.type }}
  19. {{- if .Values.controller.service.clusterIP }}
  20. clusterIP: {{ .Values.controller.service.clusterIP }}
  21. {{- end }}
  22. {{- if .Values.controller.service.externalIPs }}
  23. externalIPs: {{ toYaml .Values.controller.service.externalIPs | nindent 4 }}
  24. {{- end }}
  25. {{- if .Values.controller.service.loadBalancerIP }}
  26. loadBalancerIP: {{ .Values.controller.service.loadBalancerIP }}
  27. {{- end }}
  28. {{- if .Values.controller.service.loadBalancerSourceRanges }}
  29. loadBalancerSourceRanges: {{ toYaml .Values.controller.service.loadBalancerSourceRanges | nindent 4 }}
  30. {{- end }}
  31. {{- if .Values.controller.service.externalTrafficPolicy }}
  32. externalTrafficPolicy: {{ .Values.controller.service.externalTrafficPolicy }}
  33. {{- end }}
  34. {{- if .Values.controller.service.sessionAffinity }}
  35. sessionAffinity: {{ .Values.controller.service.sessionAffinity }}
  36. {{- end }}
  37. {{- if .Values.controller.service.healthCheckNodePort }}
  38. healthCheckNodePort: {{ .Values.controller.service.healthCheckNodePort }}
  39. {{- end }}
  40. {{- if semverCompare ">=1.21.0-0" .Capabilities.KubeVersion.Version -}}
  41. {{- if .Values.controller.service.ipFamilyPolicy }}
  42. ipFamilyPolicy: {{ .Values.controller.service.ipFamilyPolicy }}
  43. {{- end }}
  44. {{- end }}
  45. {{- if semverCompare ">=1.21.0-0" .Capabilities.KubeVersion.Version -}}
  46. {{- if .Values.controller.service.ipFamilies }}
  47. ipFamilies: {{ toYaml .Values.controller.service.ipFamilies | nindent 4 }}
  48. {{- end }}
  49. {{- end }}
  50. ports:
  51. {{- $setNodePorts := (or (eq .Values.controller.service.type "NodePort") (eq .Values.controller.service.type "LoadBalancer")) }}
  52. {{- if .Values.controller.service.enableHttp }}
  53. - name: http
  54. port: {{ .Values.controller.service.ports.http }}
  55. protocol: TCP
  56. targetPort: {{ .Values.controller.service.targetPorts.http }}
  57. {{- if and (semverCompare ">=1.20" .Capabilities.KubeVersion.Version) (.Values.controller.service.appProtocol) }}
  58. appProtocol: http
  59. {{- end }}
  60. {{- if (and $setNodePorts (not (empty .Values.controller.service.nodePorts.http))) }}
  61. nodePort: {{ .Values.controller.service.nodePorts.http }}
  62. {{- end }}
  63. {{- end }}
  64. {{- if .Values.controller.service.enableHttps }}
  65. - name: https
  66. port: {{ .Values.controller.service.ports.https }}
  67. protocol: TCP
  68. targetPort: {{ .Values.controller.service.targetPorts.https }}
  69. {{- if and (semverCompare ">=1.20" .Capabilities.KubeVersion.Version) (.Values.controller.service.appProtocol) }}
  70. appProtocol: https
  71. {{- end }}
  72. {{- if (and $setNodePorts (not (empty .Values.controller.service.nodePorts.https))) }}
  73. nodePort: {{ .Values.controller.service.nodePorts.https }}
  74. {{- end }}
  75. {{- end }}
  76. {{- range $key, $value := .Values.tcp }}
  77. - name: {{ if $.Values.portNamePrefix }}{{ $.Values.portNamePrefix }}-{{ end }}{{ $key }}-tcp
  78. port: {{ $key }}
  79. protocol: TCP
  80. targetPort: {{ if $.Values.portNamePrefix }}{{ $.Values.portNamePrefix }}-{{ end }}{{ $key }}-tcp
  81. {{- if $.Values.controller.service.nodePorts.tcp }}
  82. {{- if index $.Values.controller.service.nodePorts.tcp $key }}
  83. nodePort: {{ index $.Values.controller.service.nodePorts.tcp $key }}
  84. {{- end }}
  85. {{- end }}
  86. {{- end }}
  87. {{- range $key, $value := .Values.udp }}
  88. - name: {{ if $.Values.portNamePrefix }}{{ $.Values.portNamePrefix }}-{{ end }}{{ $key }}-udp
  89. port: {{ $key }}
  90. protocol: UDP
  91. targetPort: {{ if $.Values.portNamePrefix }}{{ $.Values.portNamePrefix }}-{{ end }}{{ $key }}-udp
  92. {{- if $.Values.controller.service.nodePorts.udp }}
  93. {{- if index $.Values.controller.service.nodePorts.udp $key }}
  94. nodePort: {{ index $.Values.controller.service.nodePorts.udp $key }}
  95. {{- end }}
  96. {{- end }}
  97. {{- end }}
  98. selector:
  99. {{- include "ingress-nginx.selectorLabels" . | nindent 4 }}
  100. app.kubernetes.io/component: controller
  101. {{- end }}