mirror of
https://github.com/truenas/charts.git
synced 2026-06-18 01:26:53 +08:00
hostname
This commit is contained in:
56
library/common-test/tests/pod/hostname_test.yaml
Normal file
56
library/common-test/tests/pod/hostname_test.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
suite: pod hostname name test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with empty hostname
|
||||
set:
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: StatefulSet
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: &statefulSetDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *statefulSetDoc
|
||||
isNull:
|
||||
path: spec.template.spec.hostname
|
||||
|
||||
- it: should pass with hostname set
|
||||
set:
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: StatefulSet
|
||||
podSpec:
|
||||
hostname: some-other-hostname
|
||||
asserts:
|
||||
- documentIndex: *statefulSetDoc
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *statefulSetDoc
|
||||
equal:
|
||||
path: spec.template.spec.hostname
|
||||
value: some-other-hostname
|
||||
|
||||
- it: should pass with hostname from "pod" with tpl
|
||||
set:
|
||||
host: some-other-hostname
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: StatefulSet
|
||||
podSpec:
|
||||
hostname: "{{ .Values.host }}"
|
||||
asserts:
|
||||
- documentIndex: *statefulSetDoc
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *statefulSetDoc
|
||||
equal:
|
||||
path: spec.template.spec.hostname
|
||||
value: some-other-hostname
|
||||
@@ -31,7 +31,7 @@ tests:
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
@@ -51,7 +51,7 @@ tests:
|
||||
podSpec:
|
||||
priorityClassName: some-other-priority-class
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
@@ -72,7 +72,7 @@ tests:
|
||||
podSpec:
|
||||
priorityClassName: "{{ .Values.priorityclass }}"
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
|
||||
@@ -32,7 +32,7 @@ tests:
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
@@ -93,7 +93,7 @@ tests:
|
||||
podSpec:
|
||||
restartPolicy: "{{ .Values.policy }}"
|
||||
asserts:
|
||||
- documentIndex: &jobDoc 0
|
||||
- documentIndex: *jobDoc
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *jobDoc
|
||||
|
||||
@@ -31,7 +31,7 @@ tests:
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
@@ -51,7 +51,7 @@ tests:
|
||||
podSpec:
|
||||
schedulerName: some-other-scheduler
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
@@ -72,7 +72,7 @@ tests:
|
||||
podSpec:
|
||||
schedulerName: "{{ .Values.scheduler }}"
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
- documentIndex: *deploymentDoc
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
| controllers.[controller-name].podSpec.restartPolicy | `string` | ❌ | ✅ | `{{ .Values.podOptions.restartPolicy }}` (Always) | Pod's restartPolicy. (Always, Never, OnFailure) |
|
||||
| controllers.[controller-name].podSpec.schedulerName | `string` | ❌ | ✅ | `{{ .Values.podOptions.schedulerName }}` ("") | Pod's schedulerName |
|
||||
| controllers.[controller-name].podSpec.priorityClassName | `string` | ❌ | ✅ | `{{ .Values.podOptions.priorityClassName }}` ("") | Pod's priorityClassName |
|
||||
| controllers.[controller-name].podSpec.hostname | `string` | ❌ | ✅ | `""` | Pod's hostname |
|
||||
|
||||
---
|
||||
|
||||
@@ -60,4 +61,5 @@ controllers:
|
||||
enableServiceLinks: false
|
||||
schedulerName: some-scheduler
|
||||
priorityClassName: some-priority-class-name
|
||||
hostname: some-hostname
|
||||
```
|
||||
|
||||
@@ -7,6 +7,7 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- define "ix.v1.common.lib.controller.pod" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
#TODO:serviceAccountName:
|
||||
{{- with (include "ix.v1.common.lib.pod.imagePullSecrets" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim) }}
|
||||
imagePullSecrets:
|
||||
{{- . | nindent 2 }}
|
||||
@@ -20,4 +21,7 @@ schedulerName: {{ . }}
|
||||
{{- with (include "ix.v1.common.lib.pod.priorityClassName" (dict "rootCtx" $rootCtx "objectData" $objectData)) }}
|
||||
priorityClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- with (include "ix.v1.common.lib.pod.hostname" (dict "rootCtx" $rootCtx "objectData" $objectData)) }}
|
||||
hostname: {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
22
library/common/1.0.0/templates/lib/pod/_hostname.tpl.tpl
Normal file
22
library/common/1.0.0/templates/lib/pod/_hostname.tpl.tpl
Normal file
@@ -0,0 +1,22 @@
|
||||
{{/* Returns Host Name */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.pod.hostname" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
rootCtx: The root context of the template. It is used to access the global context.
|
||||
objectData: The object data to be used to render the Pod.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.pod.hostname" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- $hostname := "" -}}
|
||||
|
||||
{{- with $objectData.podSpec.hostname -}}
|
||||
{{- $hostname = tpl . $rootCtx -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $hostname -}}
|
||||
{{- include "ix.v1.common.lib.chart.names.validation" (dict "name" $hostname) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $hostname -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user