From 510ee6c0dff1ac275c963ca22007c24250db6c57 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Mon, 6 May 2024 17:02:53 -0500 Subject: [PATCH] ironic: make conductor statefulset more configurable Made the conductor statefulset more configurable by allowing the user to enable/disable the http or pxe containers and to modify their init and/or runtime scripts. Allow another OS to potentially be used by letting the user supply the HOST_OS value and FILEPATH. Simplify the code by using the variables already defined. Include the snponly image as the counterpart to undionly. Change-Id: I181657bca6ace0f94f6e0ef0b6f8a5bc7a433ac3 --- ironic/Chart.yaml | 2 +- .../bin/_ironic-conductor-http-init.sh.tpl | 37 ---------- .../bin/_ironic-conductor-http.sh.tpl | 21 ------ .../bin/_ironic-conductor-pxe-init.sh.tpl | 60 --------------- .../bin/_ironic-conductor-pxe.sh.tpl | 37 ---------- ironic/templates/configmap-bin.yaml | 16 ++-- ironic/templates/statefulset-conductor.yaml | 8 ++ ironic/values.yaml | 73 +++++++++++++++++++ releasenotes/notes/ironic.yaml | 1 + 9 files changed, 91 insertions(+), 164 deletions(-) delete mode 100644 ironic/templates/bin/_ironic-conductor-http-init.sh.tpl delete mode 100644 ironic/templates/bin/_ironic-conductor-http.sh.tpl delete mode 100644 ironic/templates/bin/_ironic-conductor-pxe-init.sh.tpl delete mode 100644 ironic/templates/bin/_ironic-conductor-pxe.sh.tpl diff --git a/ironic/Chart.yaml b/ironic/Chart.yaml index 573a815926..1f16d45af2 100644 --- a/ironic/Chart.yaml +++ b/ironic/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Ironic name: ironic -version: 0.2.14 +version: 0.2.15 home: https://docs.openstack.org/ironic/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Ironic/OpenStack_Project_Ironic_vertical.png sources: diff --git a/ironic/templates/bin/_ironic-conductor-http-init.sh.tpl b/ironic/templates/bin/_ironic-conductor-http-init.sh.tpl deleted file mode 100644 index 7acce1a557..0000000000 --- a/ironic/templates/bin/_ironic-conductor-http-init.sh.tpl +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -{{/* -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. -*/}} - -set -ex - -if [ "x" == "x${PROVISIONER_INTERFACE}" ]; then - echo "Provisioner interface is not set" - exit 1 -fi - -function net_pxe_addr { - ip addr | awk "/inet / && /${PROVISIONER_INTERFACE}/{print \$2; exit }" -} -function net_pxe_ip { - echo $(net_pxe_addr) | awk -F '/' '{ print $1; exit }' -} -PXE_IP=$(net_pxe_ip) - -if [ "x" == "x${PXE_IP}" ]; then - echo "Could not find IP for pxe to bind to" - exit 1 -fi - -sed "s|OSH_PXE_IP|${PXE_IP}|g" /etc/nginx/nginx.conf > /tmp/pod-shared/nginx.conf diff --git a/ironic/templates/bin/_ironic-conductor-http.sh.tpl b/ironic/templates/bin/_ironic-conductor-http.sh.tpl deleted file mode 100644 index 6a97b41a05..0000000000 --- a/ironic/templates/bin/_ironic-conductor-http.sh.tpl +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -{{/* -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. -*/}} - -set -ex - -mkdir -p /var/lib/openstack-helm/httpboot -cp -v /tmp/pod-shared/nginx.conf /etc/nginx/nginx.conf -exec nginx -g 'daemon off;' diff --git a/ironic/templates/bin/_ironic-conductor-pxe-init.sh.tpl b/ironic/templates/bin/_ironic-conductor-pxe-init.sh.tpl deleted file mode 100644 index 96f5fcb655..0000000000 --- a/ironic/templates/bin/_ironic-conductor-pxe-init.sh.tpl +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -{{/* -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. -*/}} - -set -ex - -. /etc/os-release -HOST_OS=${HOST_OS:="${ID}"} -FILEPATH=${FILEPATH:-/usr/lib/ipxe} - -if [ "x$ID" == "xubuntu" ]; then - #NOTE(portdirect): this works around a limitation in Kolla images - if ! dpkg -l ipxe; then - apt-get update - apt-get install ipxe -y - fi - - FILEPATH=/usr/lib/ipxe - -elif [ "x$ID" == "xcentos" ]; then - - if ! yum list installed ipxe-bootimgs >/dev/null 2>&1; then - yum update --nogpgcheck -y - yum install ipxe-bootimgs syslinux-tftpboot --nogpgcheck -y - fi - - FILEPATH=/usr/share/ipxe - -fi - -mkdir -p /var/lib/openstack-helm/tftpboot -mkdir -p /var/lib/openstack-helm/tftpboot/master_images - -for FILE in undionly.kpxe ipxe.efi pxelinux.0; do - if [ -f /usr/lib/ipxe/$FILE ]; then - cp -v /usr/lib/ipxe/$FILE /var/lib/openstack-helm/tftpboot - fi - - # ipxe and pxe support for CentOS - if [ "x$ID" == "xcentos" ]; then - if [ -f /var/lib/tftpboot/$FILE ]; then - cp -v /var/lib/tftpboot/$FILE /var/lib/openstack-helm/tftpboot - fi - if [ -f /usr/share/ipxe/$FILE ]; then - cp -v /usr/share/ipxe/$FILE /var/lib/openstack-helm/tftpboot - fi - fi -done diff --git a/ironic/templates/bin/_ironic-conductor-pxe.sh.tpl b/ironic/templates/bin/_ironic-conductor-pxe.sh.tpl deleted file mode 100644 index 19451abf5c..0000000000 --- a/ironic/templates/bin/_ironic-conductor-pxe.sh.tpl +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -{{/* -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. -*/}} - -set -ex -function net_pxe_addr { - ip addr | awk "/inet / && /${PROVISIONER_INTERFACE}/{print \$2; exit }" -} -function net_pxe_ip { - echo $(net_pxe_addr) | awk -F '/' '{ print $1; exit }' -} -PXE_IP=$(net_pxe_ip) - -if [ "x" == "x${PXE_IP}" ]; then - echo "Could not find IP for pxe to bind to" - exit 1 -fi - -ln -s /var/lib/openstack-helm/tftpboot /tftpboot -exec /usr/sbin/in.tftpd \ - --verbose \ - --foreground \ - --user root \ - --address ${PXE_IP}:69 \ - --map-file /tftp-map-file /tftpboot diff --git a/ironic/templates/configmap-bin.yaml b/ironic/templates/configmap-bin.yaml index e2c6de2624..96668032b5 100644 --- a/ironic/templates/configmap-bin.yaml +++ b/ironic/templates/configmap-bin.yaml @@ -52,14 +52,14 @@ data: {{ tuple "bin/_ironic-conductor.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} ironic-conductor-init.sh: | {{ tuple "bin/_ironic-conductor-init.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} - ironic-conductor-pxe.sh: | -{{ tuple "bin/_ironic-conductor-pxe.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} - ironic-conductor-pxe-init.sh: | -{{ tuple "bin/_ironic-conductor-pxe-init.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} - ironic-conductor-http.sh: | -{{ tuple "bin/_ironic-conductor-http.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} - ironic-conductor-http-init.sh: | -{{ tuple "bin/_ironic-conductor-http-init.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} +{{- if .Values.conductor.pxe.enabled }} +{{ include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conductor.pxe.script "key" "ironic-conductor-pxe.sh") | indent 2 }} +{{ include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conductor.pxe.init_script "key" "ironic-conductor-pxe-init.sh") | indent 2 }} +{{ end }} +{{- if .Values.conductor.http.enabled }} +{{ include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conductor.http.script "key" "ironic-conductor-http.sh") | indent 2 }} +{{ include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conductor.http.init_script "key" "ironic-conductor-http-init.sh") | indent 2 }} +{{ end }} rabbit-init.sh: | {{- include "helm-toolkit.scripts.rabbit_init" . | indent 4 }} {{- end }} diff --git a/ironic/templates/statefulset-conductor.yaml b/ironic/templates/statefulset-conductor.yaml index 43be977648..cb46b9edfb 100644 --- a/ironic/templates/statefulset-conductor.yaml +++ b/ironic/templates/statefulset-conductor.yaml @@ -59,6 +59,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet initContainers: {{ tuple $envAll "conductor" $mounts_ironic_conductor_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} +{{- if $envAll.Values.conductor.pxe.enabled }} - name: ironic-conductor-pxe-init {{ tuple $envAll "ironic_pxe_init" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.conductor | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} @@ -73,6 +74,7 @@ spec: readOnly: true - name: pod-data mountPath: /var/lib/openstack-helm +{{- end }} - name: ironic-conductor-init {{ tuple $envAll "ironic_conductor" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.conductor | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} @@ -90,6 +92,7 @@ spec: readOnly: true - name: pod-shared mountPath: /tmp/pod-shared +{{- if $envAll.Values.conductor.http.enabled }} - name: ironic-conductor-http-init {{ tuple $envAll "ironic_conductor" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.conductor | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} @@ -111,6 +114,7 @@ spec: readOnly: true - name: pod-shared mountPath: /tmp/pod-shared +{{- end }} {{- if and (.Values.bootstrap.object_store.enabled) (.Values.bootstrap.object_store.openstack.enabled) }} - name: ironic-retrive-swift-config {{ tuple $envAll "ironic_retrive_swift_config" | include "helm-toolkit.snippets.image" | indent 10 }} @@ -198,6 +202,7 @@ spec: - name: pod-data mountPath: /var/lib/openstack-helm {{ if $mounts_ironic_conductor.volumeMounts }}{{ toYaml $mounts_ironic_conductor.volumeMounts | indent 12 }}{{ end }} +{{- if $envAll.Values.conductor.pxe.enabled }} - name: ironic-conductor-pxe {{ tuple $envAll "ironic_pxe" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.conductor | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} @@ -221,6 +226,8 @@ spec: readOnly: true - name: pod-data mountPath: /var/lib/openstack-helm +{{- end }} +{{- if $envAll.Values.conductor.http.enabled }} - name: ironic-conductor-http {{ tuple $envAll "ironic_pxe_http" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.conductor | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} @@ -239,6 +246,7 @@ spec: - name: pod-data mountPath: /var/lib/openstack-helm {{ if $mounts_ironic_conductor.volumeMounts }}{{ toYaml $mounts_ironic_conductor.volumeMounts | indent 12 }}{{ end }} +{{- end }} volumes: - name: pod-tmp emptyDir: {} diff --git a/ironic/values.yaml b/ironic/values.yaml index 2a78b866c2..25a2688094 100644 --- a/ironic/values.yaml +++ b/ironic/values.yaml @@ -201,6 +201,79 @@ conf: format: "%(message)s" datefmt: "%Y-%m-%d %H:%M:%S" +conductor: + http: + enabled: true + init_script: | + #!/bin/bash + set -ex + if [ "x" == "x${PROVISIONER_INTERFACE}" ]; then + echo "Provisioner interface is not set" + exit 1 + fi + + function net_pxe_addr { + ip addr | awk "/inet / && /${PROVISIONER_INTERFACE}/{print \$2; exit }" + } + function net_pxe_ip { + echo $(net_pxe_addr) | awk -F '/' '{ print $1; exit }' + } + PXE_IP=$(net_pxe_ip) + + if [ "x" == "x${PXE_IP}" ]; then + echo "Could not find IP for pxe to bind to" + exit 1 + fi + + sed "s|OSH_PXE_IP|${PXE_IP}|g" /etc/nginx/nginx.conf > /tmp/pod-shared/nginx.conf + script: | + #!/bin/bash + set -ex + mkdir -p /var/lib/openstack-helm/httpboot + cp -v /tmp/pod-shared/nginx.conf /etc/nginx/nginx.conf + exec nginx -g 'daemon off;' + pxe: + enabled: true + init_script: | + #!/bin/bash + set -ex + # default to Ubuntu path + FILEPATH=${FILEPATH:-/usr/lib/ipxe} + + mkdir -p /var/lib/openstack-helm/tftpboot + mkdir -p /var/lib/openstack-helm/tftpboot/master_images + + for FILE in undionly.kpxe ipxe.efi pxelinux.0 snponly.efi; do + # copy in default file + if [ -f $FILEPATH/$FILE ]; then + cp -v $FILEPATH/$FILE /var/lib/openstack-helm/tftpboot + fi + + done + script: | + #!/bin/bash + set -ex + function net_pxe_addr { + ip addr | awk "/inet / && /${PROVISIONER_INTERFACE}/{print \$2; exit }" + } + function net_pxe_ip { + echo $(net_pxe_addr) | awk -F '/' '{ print $1; exit }' + } + PXE_IP=$(net_pxe_ip) + + if [ "x" == "x${PXE_IP}" ]; then + echo "Could not find IP for pxe to bind to" + exit 1 + fi + + ln -s /var/lib/openstack-helm/tftpboot /tftpboot + exec /usr/sbin/in.tftpd \ + --verbose \ + --foreground \ + --user root \ + --address ${PXE_IP}:69 \ + --map-file /tftp-map-file /tftpboot + network: pxe: device: ironic-pxe diff --git a/releasenotes/notes/ironic.yaml b/releasenotes/notes/ironic.yaml index 60c942afd0..a921202c78 100644 --- a/releasenotes/notes/ironic.yaml +++ b/releasenotes/notes/ironic.yaml @@ -18,4 +18,5 @@ ironic: - 0.2.12 allow custom annotations on jobs - 0.2.13 Enable custom annotations for Openstack secrets - 0.2.14 Update images used by default + - 0.2.15 Allow enabling/disabling of conductor http and pxe containers and overriding their init and runtime scripts ...