mirror of
https://github.com/truenas/charts.git
synced 2026-06-17 07:27:44 +08:00
noedport
This commit is contained in:
@@ -41,6 +41,7 @@ tests:
|
||||
some_ip: 172.16.20.35
|
||||
some_other_ip: 10.100.200.45
|
||||
some_range: 11.100.200.0/24
|
||||
some_family: IPv6
|
||||
service:
|
||||
my-service:
|
||||
enabled: true
|
||||
@@ -55,7 +56,7 @@ tests:
|
||||
ipFamilyPolicy: PreferDualStack
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
- IPv6
|
||||
- "{{ .Values.some_family }}"
|
||||
ports:
|
||||
port-name:
|
||||
enabled: true
|
||||
|
||||
75
library/common-test/tests/service/node_port_test.yaml
Normal file
75
library/common-test/tests/service/node_port_test.yaml
Normal file
@@ -0,0 +1,75 @@
|
||||
suite: service nodePort test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with type nodePort
|
||||
set:
|
||||
service:
|
||||
my-service:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: NodePort
|
||||
ports:
|
||||
port-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
workload:
|
||||
my-workload:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: &serviceDoc 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *serviceDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *serviceDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test
|
||||
- documentIndex: *serviceDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
type: NodePort
|
||||
|
||||
- it: should pass with type NodePort and available options set
|
||||
set:
|
||||
some_ip: 172.16.20.35
|
||||
some_family: IPv6
|
||||
service:
|
||||
my-service:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: NodePort
|
||||
clusterIP: "{{ .Values.some_ip }}"
|
||||
externalTrafficPolicy: Local
|
||||
ipFamilyPolicy: PreferDualStack
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
- "{{ .Values.some_family }}"
|
||||
ports:
|
||||
port-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
workload:
|
||||
my-workload:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *serviceDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
type: NodePort
|
||||
clusterIP: 172.16.20.35
|
||||
externalTrafficPolicy: Local
|
||||
ipFamilyPolicy: PreferDualStack
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
- IPv6
|
||||
@@ -12,8 +12,6 @@ objectData: The service data, that will be used to render the Service object.
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- $svcType := $objectData.type | default "ClusterIP" -}}
|
||||
{{/* Expand svcType in case it has tpl */}}
|
||||
{{- $svcType = (tpl $svcType $rootCtx) -}}
|
||||
|
||||
{{/* Get Pod Values based on the selector (or the absence of it) */}}
|
||||
{{- $podValues := fromJson (include "ix.v1.common.lib.service.getSelectedPodValues" (dict "rootCtx" $rootCtx "objectData" $objectData)) -}}
|
||||
@@ -72,6 +70,8 @@ spec:
|
||||
{{- include "ix.v1.common.lib.service.spec.clusterIP" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 }}
|
||||
{{- else if eq $svcType "LoadBalancer" -}}
|
||||
{{- include "ix.v1.common.lib.service.spec.loadBalancer" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 }}
|
||||
{{- else if eq $svcType "NodePort" -}}
|
||||
{{- include "ix.v1.common.lib.service.spec.nodePort" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- if not (mustHas $svcType (list "ExternalName" "ExternalIP")) }}
|
||||
selector:
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{{/* Service - NodePort Spec */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.service.spec.nodePort" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
rootCtx: The root context of the service
|
||||
objectData: The service object data
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.lib.service.spec.nodePort" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData }}
|
||||
|
||||
type: NodePort
|
||||
{{- include "ix.v1.common.lib.service.clusterIP" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 0 }}
|
||||
{{- include "ix.v1.common.lib.service.ipFamily" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 0 }}
|
||||
{{- include "ix.v1.common.lib.service.externalTrafficPolicy" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 0 }}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user