mirror of
https://github.com/truenas/charts.git
synced 2026-06-18 09:37:12 +08:00
force ClusterIP when hostPort is defined
This commit is contained in:
@@ -44,3 +44,30 @@ tests:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: common-test
|
||||
release: RELEASE-NAME
|
||||
|
||||
- it: should pass with hostPort defined, should be forced to ClusterIP
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
main:
|
||||
port: 65535
|
||||
hostPort: 12345
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
type: ClusterIP
|
||||
ports: &defaultPort
|
||||
- name: main
|
||||
port: 65535
|
||||
protocol: TCP
|
||||
targetPort: main
|
||||
publishNotReadyAddresses: false
|
||||
selector: &defaultSelector
|
||||
app: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: common-test
|
||||
release: RELEASE-NAME
|
||||
|
||||
@@ -16,6 +16,16 @@
|
||||
{{- $svcType = "ClusterIP" -}} {{/* When hostNetwork is enabled, force ClusterIP as service type */}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* When hostPort is used, this port can only be assiged to a ClusterIP Service */}}
|
||||
{{/* If at least one port in a service has hostPort this service will be forced to ClusterIP */}}
|
||||
{{- range $name, $port := $svcValues.ports -}}
|
||||
{{- if $port.enabled -}}
|
||||
{{- if $port.hostPort -}}
|
||||
{{- $svcType = "ClusterIP" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $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 }}
|
||||
|
||||
Reference in New Issue
Block a user