svc.yaml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: {{ include "common.names.fullname" . }}
  5. namespace: {{ .Release.Namespace | quote }}
  6. labels: {{- include "common.labels.standard" . | nindent 4 }}
  7. {{- if .Values.commonLabels }}
  8. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  9. {{- end }}
  10. {{- if or .Values.service.annotations .Values.commonAnnotations }}
  11. annotations:
  12. {{- if .Values.service.annotations }}
  13. {{- include "common.tplvalues.render" (dict "value" .Values.service.annotations "context" $) | nindent 4 }}
  14. {{- end }}
  15. {{- if .Values.commonAnnotations }}
  16. {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  17. {{- end }}
  18. {{- end }}
  19. spec:
  20. type: {{ .Values.service.type }}
  21. {{- if and .Values.service.clusterIP (eq .Values.service.type "ClusterIP") }}
  22. clusterIP: {{ .Values.service.clusterIP }}
  23. {{- end }}
  24. {{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
  25. externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
  26. {{- end }}
  27. {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerSourceRanges)) }}
  28. loadBalancerSourceRanges: {{ .Values.service.loadBalancerSourceRanges }}
  29. {{- end }}
  30. {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP)) }}
  31. loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  32. {{- end }}
  33. {{- if .Values.service.sessionAffinity }}
  34. sessionAffinity: {{ .Values.service.sessionAffinity }}
  35. {{- end }}
  36. {{- if .Values.service.sessionAffinityConfig }}
  37. sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.service.sessionAffinityConfig "context" $) | nindent 4 }}
  38. {{- end }}
  39. ports:
  40. - name: http
  41. port: {{ .Values.service.ports.http }}
  42. protocol: TCP
  43. targetPort: http
  44. {{- if (and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.http))) }}
  45. nodePort: {{ .Values.service.nodePorts.http }}
  46. {{- else if eq .Values.service.type "ClusterIP" }}
  47. nodePort: null
  48. {{- end }}
  49. {{- if .Values.service.extraPorts }}
  50. {{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
  51. {{- end }}
  52. selector: {{- include "common.labels.matchLabels" . | nindent 4 }}