Refactor with helm-toolkit template functions

Change-Id: I32e59d6e9bb1833f2d143f545a06ed0c29092934
This commit is contained in:
Craig Anderson 2017-11-30 22:52:32 +00:00
parent ae819b9a3b
commit 82254b99e1
13 changed files with 350 additions and 326 deletions

View File

@ -128,7 +128,7 @@ conf:
net.ipv6.conf.all.forwarding: 1
fs.file-max: 9999
overrides:
divingbell-sysctl:
divingbell_sysctl:
labels:
- label:
key: compute_type

View File

@ -18,7 +18,7 @@
set -e
cat <<'EOF' > {{ .chroot_mnt_path | quote }}/tmp/ethtool_host.sh
cat <<'EOF' > {{ .Values.conf.chroot_mnt_path | quote }}/tmp/ethtool_host.sh
{{ include "divingbell.shcommon" . }}
old_ethtool_path='/var/divingbell/ethtool'
@ -150,7 +150,7 @@ WantedBy=multi-user.target"
curr_ethtool="${curr_ethtool}${systemd_name}"$'\n'
}
{{- range $iface, $unused := .ethtool }}
{{- range $iface, $unused := .Values.conf.ethtool }}
{{- range $ethtool_key, $ethtool_val := . }}
device={{ $iface | quote }} \
user_key={{ $ethtool_key | quote }} \
@ -211,8 +211,8 @@ fi
exit 0
EOF
chmod 755 {{ .chroot_mnt_path | quote }}/tmp/ethtool_host.sh
chroot {{ .chroot_mnt_path | quote }} /tmp/ethtool_host.sh
chmod 755 {{ .Values.conf.chroot_mnt_path | quote }}/tmp/ethtool_host.sh
chroot {{ .Values.conf.chroot_mnt_path | quote }} /tmp/ethtool_host.sh
sleep 1
echo 'INFO Putting the daemon to sleep.'

View File

@ -18,7 +18,7 @@
set -e
cat <<'EOF' > {{ .chroot_mnt_path | quote }}/tmp/mounts_host.sh
cat <<'EOF' > {{ .Values.conf.chroot_mnt_path | quote }}/tmp/mounts_host.sh
{{ include "divingbell.shcommon" . }}
old_mounts_path='/var/divingbell/mounts'
@ -105,7 +105,7 @@ WantedBy=local-fs.target"
curr_mounts="${curr_mounts}${systemd_name}"$'\n'
}
{{- range .mounts }}
{{- range .Values.conf.mounts }}
{{- range $key, $value := . }}
{{ $key }}={{ $value | quote }} \
{{- end }}
@ -141,8 +141,8 @@ fi
exit 0
EOF
chmod 755 {{ .chroot_mnt_path | quote }}/tmp/mounts_host.sh
chroot {{ .chroot_mnt_path | quote }} /tmp/mounts_host.sh
chmod 755 {{ .Values.conf.chroot_mnt_path | quote }}/tmp/mounts_host.sh
chroot {{ .Values.conf.chroot_mnt_path | quote }} /tmp/mounts_host.sh
sleep 1
echo 'INFO Putting the daemon to sleep.'

View File

@ -5,7 +5,7 @@ set -o errtrace
set -o pipefail
declare -Ax __log_types=(
{{- if .log_colors }}
{{- if .Values.conf.log_colors }}
[ERROR]='fd=2, color=\e[01;31m'
[TRACE]='fd=2, color=\e[01;31m'
[WARN]='fd=1, color=\e[01;93m'

View File

@ -18,7 +18,7 @@
set -e
cat <<'EOF' > {{ .chroot_mnt_path | quote }}/tmp/sysctl_host.sh
cat <<'EOF' > {{ .Values.conf.chroot_mnt_path | quote }}/tmp/sysctl_host.sh
{{ include "divingbell.shcommon" . }}
# TODO: Make prefix configurable to control param loading order
@ -89,7 +89,7 @@ add_sysctl_param(){
curr_settings="${curr_settings}${fname_prefix}${system_key}.conf"$'\n'
}
{{- range $key, $value := .sysctl }}
{{- range $key, $value := .Values.conf.sysctl }}
add_sysctl_param {{ $key | quote }} {{ $value | quote }}
{{- end }}
@ -126,8 +126,8 @@ fi
exit 0
EOF
chmod 755 {{ .chroot_mnt_path | quote }}/tmp/sysctl_host.sh
chroot {{ .chroot_mnt_path | quote }} /tmp/sysctl_host.sh
chmod 755 {{ .Values.conf.chroot_mnt_path | quote }}/tmp/sysctl_host.sh
chroot {{ .Values.conf.chroot_mnt_path | quote }} /tmp/sysctl_host.sh
sleep 1
echo 'INFO Putting the daemon to sleep.'

View File

@ -0,0 +1,30 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- define "divingbell.configmap.ethtool" }}
{{- $configMapName := index . 0 }}
{{- $envAll := index . 1 }}
{{- with $envAll }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $configMapName }}
data:
ethtool: |+
{{ tuple "bin/_ethtool.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,30 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- define "divingbell.configmap.mounts" }}
{{- $configMapName := index . 0 }}
{{- $envAll := index . 1 }}
{{- with $envAll }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $configMapName }}
data:
mounts: |+
{{ tuple "bin/_mounts.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,30 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- define "divingbell.configmap.sysctl" }}
{{- $configMapName := index . 0 }}
{{- $envAll := index . 1 }}
{{- with $envAll }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $configMapName }}
data:
sysctl: |+
{{ tuple "bin/_sysctl.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,65 @@
{{/*
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/}}
{{- define "divingbell.daemonset.ethtool" }}
{{- $daemonset := index . 0 }}
{{- $configMapName := index . 1 }}
{{- $envAll := index . 2 }}
{{- with $envAll }}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: {{ $daemonset }}
spec:
template:
metadata:
labels:
{{ list $envAll .Chart.Name $daemonset | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec:
hostNetwork: true
hostPID: true
hostIPC: true
containers:
- name: {{ $daemonset }}
image: {{ .Values.images.divingbell }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- /tmp/{{ $daemonset }}.sh
volumeMounts:
- name: rootfs-{{ $daemonset }}
mountPath: {{ .Values.conf.chroot_mnt_path }}
- name: {{ $configMapName }}
mountPath: /tmp/{{ $daemonset }}.sh
subPath: {{ $daemonset }}
readOnly: true
securityContext:
privileged: true
volumes:
- name: rootfs-{{ $daemonset }}
hostPath:
path: /
- name: {{ $configMapName }}
configMap:
name: {{ $configMapName }}
defaultMode: 0555
{{- end }}
{{- end }}
{{- $daemonset := "ethtool" }}
{{- $configMapName := "divingbell-ethtool" }}
{{- $daemonset_yaml := list $daemonset $configMapName . | include "divingbell.daemonset.ethtool" | toString | fromYaml }}
{{- $configmap_include := "divingbell.configmap.ethtool" }}
{{- list $daemonset $daemonset_yaml $configmap_include $configMapName . | include "helm-toolkit.utils.daemonset_overrides" }}

View File

@ -0,0 +1,65 @@
{{/*
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/}}
{{- define "divingbell.daemonset.mounts" }}
{{- $daemonset := index . 0 }}
{{- $configMapName := index . 1 }}
{{- $envAll := index . 2 }}
{{- with $envAll }}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: {{ $daemonset }}
spec:
template:
metadata:
labels:
{{ list $envAll .Chart.Name $daemonset | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec:
hostNetwork: true
hostPID: true
hostIPC: true
containers:
- name: {{ $daemonset }}
image: {{ .Values.images.divingbell }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- /tmp/{{ $daemonset }}.sh
volumeMounts:
- name: rootfs-{{ $daemonset }}
mountPath: {{ .Values.conf.chroot_mnt_path }}
- name: {{ $configMapName }}
mountPath: /tmp/{{ $daemonset }}.sh
subPath: {{ $daemonset }}
readOnly: true
securityContext:
privileged: true
volumes:
- name: rootfs-{{ $daemonset }}
hostPath:
path: /
- name: {{ $configMapName }}
configMap:
name: {{ $configMapName }}
defaultMode: 0555
{{- end }}
{{- end }}
{{- $daemonset := "mounts" }}
{{- $configMapName := "divingbell-mounts" }}
{{- $daemonset_yaml := list $daemonset $configMapName . | include "divingbell.daemonset.mounts" | toString | fromYaml }}
{{- $configmap_include := "divingbell.configmap.mounts" }}
{{- list $daemonset $daemonset_yaml $configmap_include $configMapName . | include "helm-toolkit.utils.daemonset_overrides" }}

View File

@ -0,0 +1,65 @@
{{/*
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/}}
{{- define "divingbell.daemonset.sysctl" }}
{{- $daemonset := index . 0 }}
{{- $configMapName := index . 1 }}
{{- $envAll := index . 2 }}
{{- with $envAll }}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: {{ $daemonset }}
spec:
template:
metadata:
labels:
{{ list $envAll .Chart.Name $daemonset | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec:
hostNetwork: true
hostPID: true
hostIPC: true
containers:
- name: {{ $daemonset }}
image: {{ .Values.images.divingbell }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- /tmp/{{ $daemonset }}.sh
volumeMounts:
- name: rootfs-{{ $daemonset }}
mountPath: {{ .Values.conf.chroot_mnt_path }}
- name: {{ $configMapName }}
mountPath: /tmp/{{ $daemonset }}.sh
subPath: {{ $daemonset }}
readOnly: true
securityContext:
privileged: true
volumes:
- name: rootfs-{{ $daemonset }}
hostPath:
path: /
- name: {{ $configMapName }}
configMap:
name: {{ $configMapName }}
defaultMode: 0555
{{- end }}
{{- end }}
{{- $daemonset := "sysctl" }}
{{- $configMapName := "divingbell-sysctl" }}
{{- $daemonset_yaml := list $daemonset $configMapName . | include "divingbell.daemonset.sysctl" | toString | fromYaml }}
{{- $configmap_include := "divingbell.configmap.sysctl" }}
{{- list $daemonset $daemonset_yaml $configmap_include $configMapName . | include "helm-toolkit.utils.daemonset_overrides" }}

View File

@ -1,256 +0,0 @@
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{{- $daemonsets := list "sysctl" "mounts" "ethtool" }}
{{- $envAll := . }}
{{- range $daemonset := $daemonsets }}
{{- $daemonset_root_name := printf (print $.Chart.Name "-" $daemonset) }}
{{- set $.Values "__daemonset_list" list }}
{{- set $.Values "__default" dict }}
{{- if hasKey $.Values.conf "overrides" }}
{{- range $key, $val := $.Values.conf.overrides }}
{{- if eq $key $daemonset_root_name }}
{{- range $type, $type_data := . }}
{{- if eq $type "hosts" }}
{{- range $host_data := . }}
# dictionary that will contain all info needed to generate this
# iteration of the daemonset
{{- $current_dict := dict }}
# generate daemonset name
{{- $name := printf (print $daemonset_root_name "-" $host_data.name) }}
{{- set $current_dict "name" $name }}
# apply overrides
{{- $override_conf_copy := $host_data.conf }}
# Omit overrides because they are not needed, and
# because it causes a stack overflow during compilation
{{- $root_conf_copy := omit $.Values.conf "overrides" }}
{{- $merged_dict := merge $override_conf_copy $root_conf_copy }}
{{- set $current_dict "nodeData" $merged_dict }}
# Schedule to this host explicitly.
{{- $nodeSelector_dict := dict }}
{{- set $nodeSelector_dict "key" "kubernetes.io/hostname" }}
{{- set $nodeSelector_dict "operator" "In" }}
{{- $values_list := list $host_data.name }}
{{- set $nodeSelector_dict "values" $values_list }}
{{- $list_aggregate := list $nodeSelector_dict }}
{{- set $current_dict "matchExpressions" $list_aggregate }}
# store completed daemonset entry/info into global list
{{- $list_aggregate := append $.Values.__daemonset_list $current_dict }}
{{- set $.Values "__daemonset_list" $list_aggregate }}
{{- end }}
{{- end }}
{{- if eq $type "labels" }}
{{- set $.Values "__label_list" . }}
{{- range $label_data := . }}
# dictionary that will contain all info needed to generate this
# iteration of the daemonset.
{{- set $.Values "__current_label" dict }}
# generate daemonset name
{{- $name := printf (print $daemonset_root_name "-" $label_data.label.key) }}
{{- set $.Values.__current_label "name" $name }}
# apply overrides
{{- $override_conf_copy := $label_data.conf }}
# Omit overrides because they are not needed, and
# because it causes a stack overflow during compilation
{{- $root_conf_copy := omit $.Values.conf "overrides" }}
{{- $merged_dict := merge $override_conf_copy $root_conf_copy }}
{{- set $.Values.__current_label "nodeData" $merged_dict }}
# Schedule to the provided label value(s)
{{- $label_dict := omit $label_data.label "NULL" }}
{{- set $label_dict "operator" "In" }}
{{- $list_aggregate := list $label_dict }}
{{- set $.Values.__current_label "matchExpressions" $list_aggregate }}
# Do not schedule to other specified labels, with higher
# precedence as the list position increases. Last defined label
# is highest priority.
{{- $other_labels := without $.Values.__label_list $label_data }}
{{- range $label_data2 := $other_labels }}
{{- $label_dict := omit $label_data2.label "NULL" }}
{{- set $label_dict "operator" "NotIn" }}
{{- $list_aggregate := append $.Values.__current_label.matchExpressions $label_dict }}
{{- set $.Values.__current_label "matchExpressions" $list_aggregate }}
{{- end }}
{{- set $.Values "__label_list" $other_labels }}
# Do not schedule to any other specified hosts
{{- range $type, $type_data := $val }}
{{- if eq $type "hosts" }}
{{- range $host_data := . }}
{{- $label_dict := dict }}
{{- set $label_dict "key" "kubernetes.io/hostname" }}
{{- set $label_dict "operator" "NotIn" }}
{{- $values_list := list $host_data.name }}
{{- set $label_dict "values" $values_list }}
{{- $list_aggregate := append $.Values.__current_label.matchExpressions $label_dict }}
{{- set $.Values.__current_label "matchExpressions" $list_aggregate }}
{{- end }}
{{- end }}
{{- end }}
# store completed daemonset entry/info into global list
{{- $list_aggregate := append $.Values.__daemonset_list $.Values.__current_label }}
{{- set $.Values "__daemonset_list" $list_aggregate }}
{{- unset $.Values "__current_label" }}
{{- end }}
{{- end }}
{{- end }}
# scheduler exceptions for the default daemonset
{{- set $.Values.__default "matchExpressions" list }}
{{- range $type, $type_data := . }}
# Do not schedule to other specified labels
{{- if eq $type "labels" }}
{{- range $label_data := . }}
{{- $default_dict := omit $label_data.label "NULL" }}
{{- set $default_dict "operator" "NotIn" }}
{{- $list_aggregate := append $.Values.__default.matchExpressions $default_dict }}
{{- set $.Values.__default "matchExpressions" $list_aggregate }}
{{- end }}
{{- end }}
# Do not schedule to other specified hosts
{{- if eq $type "hosts" }}
{{- range $host_data := . }}
{{- $default_dict := dict }}
{{- set $default_dict "key" "kubernetes.io/hostname" }}
{{- set $default_dict "operator" "NotIn" }}
{{- $values_list := list $host_data.name }}
{{- set $default_dict "values" $values_list }}
{{- $list_aggregate := append $.Values.__default.matchExpressions $default_dict }}
{{- set $.Values.__default "matchExpressions" $list_aggregate }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
# generate the default daemonset
# name
{{- $name := printf (print $daemonset_root_name "-default") }}
{{- set $.Values.__default "name" $name }}
# use values.conf as-is, minus overrides
{{- $root_conf_copy := omit $.Values.conf "overrides" }}
{{- set $.Values.__default "nodeData" $root_conf_copy }}
# add to global list
{{- $list_aggregate := append $.Values.__daemonset_list $.Values.__default }}
{{- set $.Values "__daemonset_list" $list_aggregate }}
{{- unset $.Values "__default" }}
{{- range $current_dict := $.Values.__daemonset_list }}
{{- $template_location := printf (print "bin/_" $daemonset ".sh.tpl") | toString -}}
# referenced by helm toolkit
{{- set $current_dict.nodeData "Template" dict -}}
{{- set $current_dict.nodeData.Template "Name" $.Template.Name }}
# name needs to be a DNS-1123 compliant name
# generate a uuid since the version of sprig packaged with helm 2.5.1 does
# not contain regex* functions. As a result we wont use $current_dict.name
{{- $dns_1123_name := printf (print $.Chart.Name "-" $daemonset "-" uuidv4) | lower }}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: {{ $dns_1123_name }}
spec:
template:
metadata:
labels:
{{ list $envAll $.Chart.Name $daemonset | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
annotations:
values-hash: {{ list $current_dict.nodeData . | quote | sha256sum }}
spec:
{{- if hasKey $current_dict "matchExpressions" }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
{{- range $matchExpression := $current_dict.matchExpressions }}
- key: {{ $matchExpression.key }}
operator: {{ $matchExpression.operator }}
values:
{{- range $schedule_val := $matchExpression.values }}
- {{ $schedule_val | quote }}
{{- end }}
{{- end }}
{{- end }}
hostNetwork: true
hostPID: true
hostIPC: true
containers:
- name: {{ $dns_1123_name }}
image: {{ $.Values.images.divingbell }}
imagePullPolicy: {{ $.Values.images.pull_policy }}
command:
- /tmp/{{ $daemonset }}.sh
volumeMounts:
- name: rootfs-{{ $daemonset }}
mountPath: {{ $.Values.conf.chroot_mnt_path }}
- name: {{ $dns_1123_name }}
mountPath: /tmp/{{ $daemonset }}.sh
subPath: {{ $daemonset }}
readOnly: true
securityContext:
privileged: true
volumes:
- name: rootfs-{{ $daemonset }}
hostPath:
path: /
- name: {{ $dns_1123_name }}
configMap:
name: {{ $dns_1123_name }}
defaultMode: 0555
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $dns_1123_name }}
data:
{{ $daemonset }}: |+
{{- tuple $current_dict.nodeData $template_location $current_dict.nodeData | include "helm-toolkit.utils.configmap_templater" | indent 4 }}
{{- end -}}
{{- unset $.Values "__daemonset_list" -}}
{{- end -}}

View File

@ -483,7 +483,7 @@ test_overrides(){
net.ipv4.ip_forward: 1
net.ipv6.conf.all.forwarding: 1
overrides:
divingbell-sysctl:
divingbell_sysctl:
labels:
- label:
key: compute_type
@ -494,16 +494,16 @@ test_overrides(){
sysctl:
net.ipv4.ip_forward: 1
- label:
key: another_label
key: compute_type
values:
- another_value
- special
conf:
sysctl:
net.ipv4.ip_forward: 1
- label:
key: test_label
key: compute_type
values:
- test_value
- special
conf:
sysctl:
net.ipv4.ip_forward: 1
@ -521,7 +521,7 @@ test_overrides(){
conf:
sysctl:
net.ipv6.conf.all.forwarding: 1
divingbell-mounts:
divingbell_mounts:
labels:
- label:
key: blarg
@ -535,14 +535,14 @@ test_overrides(){
device: tmpfs
type: tmpfs
options: 'defaults,noatime,nosuid,nodev,noexec,mode=1777,size=32M'
divingbell-ethtool:
divingbell_ethtool:
hosts:
- name: ethtool-host
conf:
ethtool:
ens3:
hw-tc-offload: on
divingbell-bogus:
divingbell_bogus:
labels:
- label:
key: bogus
@ -581,33 +581,6 @@ test_overrides(){
# TODO: Implement more robust tests that do not depend on match expression
# ordering.
# Verify generated affinity for test_label
echo "${tc_output}" | grep ' spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: test_label
operator: In
values:
- "test_value"
- key: kubernetes.io/hostname
operator: NotIn
values:
- "superhost"
- key: kubernetes.io/hostname
operator: NotIn
values:
- "helm1"
- key: kubernetes.io/hostname
operator: NotIn
values:
- "specialhost"
hostNetwork: true' &&
echo '[SUCCESS] overrides test 2 passed successfully' >> "${TEST_RESULTS}" ||
(echo '[FAILURE] overrides test 2 failed' && exit 1)
# Verify generated affinity for another_label
echo "${tc_output}" | grep ' spec:
affinity:
@ -619,10 +592,6 @@ test_overrides(){
operator: In
values:
- "another_value"
- key: test_label
operator: NotIn
values:
- "test_value"
- key: kubernetes.io/hostname
operator: NotIn
values:
@ -634,8 +603,37 @@ test_overrides(){
- key: kubernetes.io/hostname
operator: NotIn
values:
- "specialhost"
hostNetwork: true' &&
- "specialhost"' &&
echo '[SUCCESS] overrides test 2 passed successfully' >> "${TEST_RESULTS}" ||
(echo '[FAILURE] overrides test 2 failed' && exit 1)
# Verify generated affinity for compute_type
echo "${tc_output}" | grep ' spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: compute_type
operator: In
values:
- "special"
- key: another_label
operator: NotIn
values:
- "another_value"
- key: kubernetes.io/hostname
operator: NotIn
values:
- "superhost"
- key: kubernetes.io/hostname
operator: NotIn
values:
- "helm1"
- key: kubernetes.io/hostname
operator: NotIn
values:
- "specialhost"' &&
echo '[SUCCESS] overrides test 3 passed successfully' >> "${TEST_RESULTS}" ||
(echo '[FAILURE] overrides test 3 failed' && exit 1)
@ -651,14 +649,14 @@ test_overrides(){
values:
- "dpdk"
- "sriov"
- key: compute_type
operator: NotIn
values:
- "special"
- key: another_label
operator: NotIn
values:
- "another_value"
- key: test_label
operator: NotIn
values:
- "test_value"
- key: kubernetes.io/hostname
operator: NotIn
values:
@ -670,8 +668,7 @@ test_overrides(){
- key: kubernetes.io/hostname
operator: NotIn
values:
- "specialhost"
hostNetwork: true' &&
- "specialhost"' &&
echo '[SUCCESS] overrides test 4 passed successfully' >> "${TEST_RESULTS}" ||
(echo '[FAILURE] overrides test 4 failed' && exit 1)
@ -686,8 +683,7 @@ test_overrides(){
operator: In
values:
- "soup"
- "chips"
hostNetwork: true' &&
- "chips"' &&
echo '[SUCCESS] overrides test 5 passed successfully' >> "${TEST_RESULTS}" ||
(echo '[FAILURE] overrides test 5 failed' && exit 1)
@ -715,15 +711,14 @@ test_overrides(){
values:
- "dpdk"
- "sriov"
- key: compute_type
operator: NotIn
values:
- "special"
- key: another_label
operator: NotIn
values:
- "another_value"
- key: test_label
operator: NotIn
values:
- "test_value"
hostNetwork: true' &&
- "another_value"' &&
echo '[SUCCESS] overrides test 6 passed successfully' >> "${TEST_RESULTS}" ||
(echo '[FAILURE] overrides test 6 failed' && exit 1)
@ -735,7 +730,7 @@ test_overrides(){
$SYSCTL_KEY1: 1
$SYSCTL_KEY2: $key2_non_override_val
overrides:
divingbell-sysctl:
divingbell_sysctl:
hosts:
- name: $(hostname -f)
conf: