mirror of
https://github.com/helm/charts.git
synced 2026-08-23 22:37:45 +00:00
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>
41 lines
1.4 KiB
YAML
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" . }}"
|