mirror of
https://github.com/truenas/charts.git
synced 2024-04-21 15:21:45 +00:00
externalname
This commit is contained in:
@@ -35,6 +35,7 @@ tests:
|
||||
path: spec
|
||||
value:
|
||||
type: ClusterIP
|
||||
publishNotReadyAddresses: false
|
||||
|
||||
- it: should pass with type ClusterIP and available options set
|
||||
set:
|
||||
@@ -69,6 +70,7 @@ tests:
|
||||
type: ClusterIP
|
||||
clusterIP: 172.16.20.35
|
||||
ipFamilyPolicy: PreferDualStack
|
||||
publishNotReadyAddresses: false
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
- IPv6
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
suite: service externalName test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with type externalName
|
||||
set:
|
||||
service:
|
||||
my-service:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: ExternalName
|
||||
externalName: my-external-name
|
||||
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: ExternalName
|
||||
externalName: my-external-name
|
||||
publishNotReadyAddresses: false
|
||||
|
||||
- it: should pass with type ExternalName and available options set
|
||||
set:
|
||||
some_ip: 172.16.20.35
|
||||
some_name: my-external-name
|
||||
service:
|
||||
my-service:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: ExternalName
|
||||
clusterIP: "{{ .Values.some_ip }}"
|
||||
externalName: "{{ .Values.some_name }}"
|
||||
externalTrafficPolicy: Local
|
||||
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: ExternalName
|
||||
clusterIP: 172.16.20.35
|
||||
externalTrafficPolicy: Local
|
||||
externalName: my-external-name
|
||||
publishNotReadyAddresses: false
|
||||
@@ -35,6 +35,7 @@ tests:
|
||||
path: spec
|
||||
value:
|
||||
type: LoadBalancer
|
||||
publishNotReadyAddresses: false
|
||||
|
||||
- it: should pass with type LoadBalancer and available options set
|
||||
set:
|
||||
@@ -80,6 +81,7 @@ tests:
|
||||
- 10.100.200.0/24
|
||||
externalTrafficPolicy: Local
|
||||
ipFamilyPolicy: PreferDualStack
|
||||
publishNotReadyAddresses: false
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
- IPv6
|
||||
|
||||
@@ -35,6 +35,7 @@ tests:
|
||||
path: spec
|
||||
value:
|
||||
type: NodePort
|
||||
publishNotReadyAddresses: false
|
||||
|
||||
- it: should pass with type NodePort and available options set
|
||||
set:
|
||||
@@ -70,6 +71,7 @@ tests:
|
||||
clusterIP: 172.16.20.35
|
||||
externalTrafficPolicy: Local
|
||||
ipFamilyPolicy: PreferDualStack
|
||||
publishNotReadyAddresses: false
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
- IPv6
|
||||
|
||||
@@ -293,3 +293,25 @@ tests:
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Service - Expected <externalTrafficPolicy> to be one of [Cluster, Local], but got [not-a-policy]
|
||||
|
||||
- it: should fail with invalid externalName
|
||||
set:
|
||||
service:
|
||||
service-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: ExternalName
|
||||
externalName: ""
|
||||
ports:
|
||||
port-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
workload:
|
||||
some-pod-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Service - Expected non-empty <externalName> on ExternalName service type.
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
| service.[service-name].labels | `dict` | ❌ | ✅ (On value only) | `{}` | Additional labels for service |
|
||||
| service.[service-name].annotations | `dict` | ❌ | ✅ (On value only) | `{}` | Additional annotations for service |
|
||||
| service.[service-name].type | `string` | ❌ | ✅ | `ClusterIP` | Define the service type (ClusterIP, LoadBalancer, NodePort, ExternalIP, ExternalName) |
|
||||
| service.[service-name].publishNotReadyAddresses | `boolean` | ❌ | ❌ | `false` | Define whether to publishNotReadyAddresses or not |
|
||||
| service.[service-name].sharedKey | `string` | ❌ | ✅ | `$FullName` | Custom Shared Key for MetalLB Annotation |
|
||||
| service.[service-name].clusterIP | `string` | ❌ | ✅ | | Custom Cluster IP |
|
||||
| service.[service-name].ipFamilyPolicy | `string` | ❌ | ✅ | | Define the ipFamilyPolicy (SingleStack, PreferDualStack, RequireDualStack) |
|
||||
@@ -42,6 +43,7 @@ service:
|
||||
service-clusterip:
|
||||
enabled: true
|
||||
primary: true
|
||||
publishNotReadyAddresses: true
|
||||
clusterIP: 172.16.20.233
|
||||
ipFamilyPolicy: SingleStack
|
||||
ipFamilies:
|
||||
|
||||
@@ -72,7 +72,10 @@ spec:
|
||||
{{- 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 }}
|
||||
{{- else if eq $svcType "ExternalName" -}}
|
||||
{{- include "ix.v1.common.lib.service.spec.externalName" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 }}
|
||||
{{- end }}
|
||||
publishNotReadyAddresses: {{ include "ix.v1.common.lib.service.publishNotReadyAddresses" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim }}
|
||||
{{- if not (mustHas $svcType (list "ExternalName" "ExternalIP")) }}
|
||||
selector:
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $podValues.shortName) | trim | nindent 2 }}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{{/* Service - externalIPs */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.service.externalIPs" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
rootCtx: The root context of the service
|
||||
objectData: The service object data
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.lib.service.externalIPs" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData }}
|
||||
|
||||
{{- $publishAddr := false -}}
|
||||
|
||||
{{- if (kindIs "bool" $objectData.publishNotReadyAddresses) -}}
|
||||
{{- $publishAddr = $objectData.publishNotReadyAddresses -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $publishAddr -}}
|
||||
{{- end -}}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{{/* Service - publishNotReadyAddresses */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.service.publishNotReadyAddresses" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
rootCtx: The root context of the service
|
||||
objectData: The service object data
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.lib.service.publishNotReadyAddresses" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData }}
|
||||
|
||||
{{- $publishAddr := false -}}
|
||||
|
||||
{{- if (kindIs "bool" $objectData.publishNotReadyAddresses) -}}
|
||||
{{- $publishAddr = $objectData.publishNotReadyAddresses -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $publishAddr -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,20 @@
|
||||
{{/* Service - ExternalName Spec */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.service.spec.externalName" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
rootCtx: The root context of the service
|
||||
objectData: The service object data
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.lib.service.spec.externalName" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData }}
|
||||
|
||||
{{- if not $objectData.externalName -}}
|
||||
{{- fail "Service - Expected non-empty <externalName> on ExternalName service type." -}}
|
||||
{{- end }}
|
||||
|
||||
type: ExternalName
|
||||
externalName: {{ tpl $objectData.externalName $rootCtx }}
|
||||
{{- include "ix.v1.common.lib.service.clusterIP" (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