mirror of
https://github.com/truenas/charts.git
synced 2026-06-17 07:27:44 +08:00
cleanup service
This commit is contained in:
@@ -14,10 +14,7 @@
|
||||
{{- if $root.Values.hostNetwork -}}
|
||||
{{- $svcType = "ClusterIP" -}} {{/* When hostNetwork is enabled, force ClusterIP as service type */}}
|
||||
{{- end -}}
|
||||
{{- $primaryPort := get $svcValues.ports (include "ix.v1.common.lib.util.service.ports.primary" (dict "values" $svcValues "svcName" $svcName)) -}}
|
||||
{{/* Prepare a dict to pass into includes */}}
|
||||
{{- $tmpSVC := dict -}}
|
||||
{{- $_ := set $tmpSVC "name" $svcName }}
|
||||
{{- $primaryPort := get $svcValues.ports (include "ix.v1.common.lib.util.service.ports.primary" (dict "values" $svcValues "svcName" $svcName)) }}
|
||||
---
|
||||
apiVersion: {{ include "ix.v1.common.capabilities.service.apiVersion" $root }}
|
||||
kind: Service
|
||||
@@ -41,22 +38,18 @@ metadata:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if has $svcType (list "ClusterIP" "NodePort" "ExternalName") }}
|
||||
type: {{ $svcType }} {{/* Specify type only for the above types */}}
|
||||
{{- end -}}
|
||||
{{- include "ix.v1.common.class.serivce.loadBalancer" (dict "svc" $svcValues "svcType" $svcType "root" $root) | trim | nindent 2 -}}
|
||||
{{- if has $svcType (list "ClusterIP" "NodePort" "LoadBalancer") -}} {{/* ClusterIP */}}
|
||||
{{- with $svcValues.clusterIP }}
|
||||
clusterIP: {{ . }}
|
||||
{{- if eq $svcType "ClusterIP" -}}
|
||||
{{- include "ix.v1.common.class.serivce.clusterIP.spec" (dict "svc" $svcValues "root" $root) | indent 2 -}}
|
||||
{{- else if eq $svcType "LoadBalancer" -}}
|
||||
{{- include "ix.v1.common.class.serivce.loadBalancer.spec" (dict "svc" $svcValues "root" $root)| indent 2 -}}
|
||||
{{- else if eq $svcType "NodePort" -}}
|
||||
{{- include "ix.v1.common.class.serivce.nodePort.spec" (dict "svc" $svcValues "root" $root) | indent 2 -}}
|
||||
{{- else if eq $svcType "ExternalName" -}}
|
||||
{{- include "ix.v1.common.class.serivce.externalName.spec" (dict "svc" $svcValues "root" $root) | indent 2 -}}
|
||||
{{- end -}}
|
||||
{{- else if eq $svcType "ExternalName" }} {{/* ExternalName */}}
|
||||
externalName: {{ required "<externalName> is required when service type is set to ExternalName" $svcValues.externalName }}
|
||||
{{- end -}}
|
||||
{{- include "ix.v1.common.class.serivce.externalTrafficPolicy" (dict "svc" $svcValues "svcType" $svcType "root" $root) | trim | nindent 2 -}}
|
||||
{{- include "ix.v1.common.class.serivce.sessionAffinity" (dict "svc" $svcValues "root" $root) | trim | nindent 2 -}}
|
||||
{{- include "ix.v1.common.class.serivce.externalIPs" (dict "svc" $svcValues "root" $root) | trim | nindent 2 -}}
|
||||
{{- include "ix.v1.common.class.serivce.publishNotReadyAddresses" (dict "publishNotReadyAddresses" $svcValues.publishNotReadyAddresses) | trim | nindent 2 -}}
|
||||
{{- include "ix.v1.common.class.serivce.ipFamily" (dict "svcType" $svcType "svc" $svcValues "root" $root) | trim | nindent 2 }}
|
||||
{{- include "ix.v1.common.class.serivce.sessionAffinity" (dict "svc" $svcValues "root" $root) | indent 2 -}}
|
||||
{{- include "ix.v1.common.class.serivce.externalIPs" (dict "svc" $svcValues "root" $root) | indent 2 -}}
|
||||
{{- include "ix.v1.common.class.serivce.publishNotReadyAddresses" (dict "publishNotReadyAddresses" $svcValues.publishNotReadyAddresses) | indent 2 }}
|
||||
ports:
|
||||
{{- range $name, $port := $svcValues.ports }}
|
||||
{{- if $port.enabled }}
|
||||
@@ -83,12 +76,12 @@ spec:
|
||||
{{- range $k, $v := . }}
|
||||
{{ $k }}: {{ tpl $v $root }}
|
||||
{{- end -}}
|
||||
{{- else }} {{/* else use the generated selectors */}}
|
||||
{{- include "ix.v1.common.labels.selectorLabels" $root | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- if eq $svcType "ExternalIP" -}}
|
||||
{{- $_ := set $tmpSVC "values" $svcValues -}}
|
||||
{{- include "ix.v1.common.class.serivce.endpoints" (dict "svc" $svcValues "svcName" $svcName "root" $root) }}
|
||||
{{- else -}} {{/* else use the generated selectors */}}
|
||||
{{- include "ix.v1.common.labels.selectorLabels" $root | nindent 4 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if eq $svcType "ExternalIP" -}}
|
||||
{{- include "ix.v1.common.class.serivce.externalTrafficPolicy" (dict "svc" $svcValues "root" $root) | nindent 2 -}}
|
||||
{{- include "ix.v1.common.class.serivce.endpoints" (dict "svc" $svcValues "svcName" $svcName "root" $root) | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{{- define "ix.v1.common.class.serivce.clusterIP" -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
|
||||
{{- with $svcValues.clusterIP }}
|
||||
clusterIP: {{ . }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,7 @@
|
||||
{{- define "ix.v1.common.class.serivce.clusterIP.spec" -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $root := .root }}
|
||||
type: ClusterIP
|
||||
{{- include "ix.v1.common.class.serivce.clusterIP" (dict "svc" $svcValues) | trim | nindent 0 -}}
|
||||
{{- include "ix.v1.common.class.serivce.ipFamily" (dict "svc" $svcValues "root" $root) | trim | nindent 0 -}}
|
||||
{{- end -}}
|
||||
@@ -2,10 +2,10 @@
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
{{- with $svcValues.externalIPs -}}
|
||||
{{- with $svcValues.externalIPs }}
|
||||
externalIPs:
|
||||
{{- range . }}
|
||||
- {{ tpl . $root }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{{- define "ix.v1.common.class.serivce.externalName.spec" -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $root := .root }}
|
||||
type: ExternalName
|
||||
externalName: {{ required "<externalName> is required when service type is set to ExternalName" $svcValues.externalName }}
|
||||
{{- include "ix.v1.common.class.serivce.clusterIP" (dict "svc" $svcValues) | trim | nindent 0 -}}
|
||||
{{- include "ix.v1.common.class.serivce.externalTrafficPolicy" (dict "svc" $svcValues "root" $root) | trim | nindent 0 -}}
|
||||
{{- end -}}
|
||||
@@ -1,13 +1,13 @@
|
||||
{{- define "ix.v1.common.class.serivce.externalTrafficPolicy" -}}
|
||||
{{- $svcType := .svcType -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $svcType := .svcType -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
|
||||
{{- if ne $svcType "ClusterIP" -}}
|
||||
{{- with $svcValues.externalTrafficPolicy -}}
|
||||
{{- if not (has . (list "Cluster" "Local")) -}}
|
||||
{{- fail (printf "Invalid option (%s) for <externalTrafficPolicy>. Valid options are Cluster and Local" .) -}}
|
||||
{{- end }}
|
||||
externalTrafficPolicy: {{ . }}
|
||||
{{- end -}}
|
||||
{{- if ne $svcType "ClusterIP" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
{{- define "ix.v1.common.class.serivce.ipFamily" -}}
|
||||
{{- $svcType := .svcType -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
{{- if has $svcType (list "ClusterIP" "NodePort" "LoadBalancer") -}}
|
||||
{{- with $svcValues.ipFamilyPolicy -}}
|
||||
{{- if not (has . (list "SingleStack" "PreferDualStack" "RequireDualStack")) -}}
|
||||
{{- fail (printf "Invalid option (%s) for <ipFamilyPolicy>. Valid options are SingleStack, PreferDualStack, RequireDualStack" .) -}}
|
||||
{{- end }}
|
||||
{{- with $svcValues.ipFamilyPolicy -}}
|
||||
{{- if not (has . (list "SingleStack" "PreferDualStack" "RequireDualStack")) -}}
|
||||
{{- fail (printf "Invalid option (%s) for <ipFamilyPolicy>. Valid options are SingleStack, PreferDualStack, RequireDualStack" .) -}}
|
||||
{{- end }}
|
||||
ipFamilyPolicy: {{ . }}
|
||||
{{- end -}}
|
||||
{{- with $svcValues.ipFamilies }}
|
||||
{{- end -}}
|
||||
{{- with $svcValues.ipFamilies }}
|
||||
ipFamilies:
|
||||
{{- range . }}
|
||||
{{- $ipFam := tpl . $root -}}
|
||||
{{- if not (has $ipFam (list "IPv4" "IPv6")) -}}
|
||||
{{- fail (printf "Invalid option (%s) for <ipFamilies[]>. Valid options are IPv4 and IPv6" $ipFam) -}}
|
||||
{{- end }}
|
||||
- {{ $ipFam }}
|
||||
{{- range . }}
|
||||
{{- $ipFam := tpl . $root -}}
|
||||
{{- if not (has $ipFam (list "IPv4" "IPv6")) -}}
|
||||
{{- fail (printf "Invalid option (%s) for <ipFamilies[]>. Valid options are IPv4 and IPv6" $ipFam) -}}
|
||||
{{- end }}
|
||||
- {{ $ipFam }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{{- define "ix.v1.common.class.serivce.loadBalancer" -}}
|
||||
{{- $svcType := .svcType -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
{{- if eq $svcType "LoadBalancer" -}}
|
||||
type: LoadBalancer
|
||||
{{- with $svcValues.loadBalancerIP }}
|
||||
loadBalancerIP: {{ . }}
|
||||
{{- end -}}
|
||||
{{- with $svcValues.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges:
|
||||
{{- range . }}
|
||||
- {{ tpl . $root }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,17 @@
|
||||
{{- define "ix.v1.common.class.serivce.loadBalancer.spec" -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $root := .root }}
|
||||
type: LoadBalancer
|
||||
{{- with $svcValues.loadBalancerIP }}
|
||||
loadBalancerIP: {{ . }}
|
||||
{{- end -}}
|
||||
{{- with $svcValues.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges:
|
||||
{{- range . }}
|
||||
- {{ tpl . $root }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- include "ix.v1.common.class.serivce.clusterIP" (dict "svc" $svcValues) | trim | nindent 0 -}}
|
||||
{{- include "ix.v1.common.class.serivce.ipFamily" (dict "svc" $svcValues "root" $root) | trim | nindent 0 -}}
|
||||
{{- include "ix.v1.common.class.serivce.externalTrafficPolicy" (dict "svc" $svcValues "root" $root) | trim | nindent 0 -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,8 @@
|
||||
{{- define "ix.v1.common.class.serivce.nodePort.spec" -}}
|
||||
{{- $svcValues := .svc -}}
|
||||
{{- $root := .root }}
|
||||
type: NodePort
|
||||
{{- include "ix.v1.common.class.serivce.clusterIP" (dict "svc" $svcValues) | trim | nindent 0 -}}
|
||||
{{- include "ix.v1.common.class.serivce.ipFamily" (dict "svc" $svcValues "root" $root) | trim | nindent 0 -}}
|
||||
{{- include "ix.v1.common.class.serivce.externalTrafficPolicy" (dict "svc" $svcValues "root" $root) | trim | nindent 0 -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user