Files
deprecated-helm-charts/stable/wordpress/templates/svc.yaml
T
Alex Tennant 4bde54c86c [stable/wordpress] Explicitly unset nodePort when service is ClusterIP (#13009)
This allows the Helm release to be switch between LoadBalancer and ClusterIP with getting the following error:
Service "wordpress" is invalid: [spec.ports[0].nodePort: Forbidden: may not be used when `type` is 'ClusterIP', spec.ports[1].nodePort: Forbidden: may not be used when `type` is 'ClusterIP']

Signed-off-by: adtennant <alex@adtennant.co.uk>
2019-04-12 07:44:46 -07:00

41 lines
1.4 KiB
YAML

apiVersion: v1
kind: Service
metadata:
name: {{ template "wordpress.fullname" . }}
labels:
app: "{{ template "wordpress.fullname" . }}"
chart: "{{ template "wordpress.chart" . }}"
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
annotations:
{{- if .Values.service.annotations }}
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
{{- end }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: http
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}}
nodePort: {{ .Values.service.nodePorts.http }}
{{- else if eq .Values.service.type "ClusterIP" }}
nodePort: null
{{- end }}
- name: https
port: {{ .Values.service.httpsPort }}
targetPort: https
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.https)))}}
nodePort: {{ .Values.service.nodePorts.https }}
{{- else if eq .Values.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if .Values.service.extraPorts }}
{{ toYaml .Values.service.extraPorts | indent 6 }}
{{- end }}
selector:
app: "{{ template "wordpress.fullname" . }}"