From 51235e8b0393713b06b713d462b7b0822de39ac0 Mon Sep 17 00:00:00 2001 From: ricolin Date: Fri, 29 Sep 2023 00:59:10 +0800 Subject: [PATCH] Allow manila properly config network host This allow manila to respect fqdn host config for share network host Depends-On: https://review.opendev.org/c/openstack/manila/+/897077 Change-Id: I8393f2b130c8c8914d946a1772fff08ff8b58652 --- manila/Chart.yaml | 2 +- .../templates/bin/_manila-share-init.sh.tpl | 24 +++++++++++++++++++ manila/templates/bin/_manila-share.sh.tpl | 5 +++- manila/templates/configmap-bin.yaml | 2 ++ manila/templates/deployment-share.yaml | 22 ++++++++++++++++- manila/values.yaml | 6 +++++ releasenotes/notes/manila.yaml | 1 + 7 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 manila/templates/bin/_manila-share-init.sh.tpl diff --git a/manila/Chart.yaml b/manila/Chart.yaml index b313bd96bc..a332c5c576 100644 --- a/manila/Chart.yaml +++ b/manila/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Manila name: manila -version: 0.1.6 +version: 0.1.7 home: https://docs.openstack.org/manila/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Manila/OpenStack_Project_Manila_vertical.png sources: diff --git a/manila/templates/bin/_manila-share-init.sh.tpl b/manila/templates/bin/_manila-share-init.sh.tpl new file mode 100644 index 0000000000..2140ba70c7 --- /dev/null +++ b/manila/templates/bin/_manila-share-init.sh.tpl @@ -0,0 +1,24 @@ +#!/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 and ( empty .Values.conf.manila.generic.service_network_host ) ( .Values.pod.use_fqdn.share ) }} +tee > /tmp/pod-shared/manila-share-fqdn.conf << EOF +[generic] +service_network_host = $(hostname --fqdn) +EOF +{{- end }} diff --git a/manila/templates/bin/_manila-share.sh.tpl b/manila/templates/bin/_manila-share.sh.tpl index 8177983429..8dc2665cd2 100644 --- a/manila/templates/bin/_manila-share.sh.tpl +++ b/manila/templates/bin/_manila-share.sh.tpl @@ -16,4 +16,7 @@ limitations under the License. set -ex exec manila-share \ - --config-file /etc/manila/manila.conf + --config-file /etc/manila/manila.conf \ +{{- if and ( empty .Values.conf.manila.generic.service_network_host ) ( .Values.pod.use_fqdn.share ) }} + --config-file /tmp/pod-shared/manila-share-fqdn.conf +{{- end }} diff --git a/manila/templates/configmap-bin.yaml b/manila/templates/configmap-bin.yaml index 5a4222d9cd..8baa2db77e 100644 --- a/manila/templates/configmap-bin.yaml +++ b/manila/templates/configmap-bin.yaml @@ -45,6 +45,8 @@ data: {{- include "helm-toolkit.scripts.keystone_user" . | indent 4 }} rabbit-init.sh: | {{- include "helm-toolkit.scripts.rabbit_init" . | indent 4 }} + manila-share-init.sh: | +{{ tuple "bin/_manila-share-init.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} manila-api.sh: | {{ tuple "bin/_manila-api.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} manila-data.sh: | diff --git a/manila/templates/deployment-share.yaml b/manila/templates/deployment-share.yaml index a1c3ac5596..87bff3b11e 100644 --- a/manila/templates/deployment-share.yaml +++ b/manila/templates/deployment-share.yaml @@ -43,7 +43,7 @@ spec: {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }} -{{ dict "envAll" $envAll "podName" "manila-share" "containerNames" (list "init" "manila-share") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} +{{ dict "envAll" $envAll "podName" "manila-share" "containerNames" (list "init" "manila-share" "manila-share-init") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} spec: {{ dict "envAll" $envAll "application" "manila" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} serviceAccountName: {{ $serviceAccountName }} @@ -58,6 +58,22 @@ spec: hostNetwork: true initContainers: {{ tuple $envAll "share" $mounts_manila_share_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + - name: manila-share-init +{{ tuple $envAll "manila_share" | include "helm-toolkit.snippets.image" | indent 10 }} +{{ dict "envAll" $envAll "application" "manila" "container" "manila_share" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} + env: [] + command: + - /tmp/manila-share-init.sh + volumeMounts: + - name: pod-tmp + mountPath: /tmp + - name: manila-bin + mountPath: /tmp/manila-share-init.sh + subPath: manila-share-init.sh + readOnly: true + - name: pod-shared + mountPath: /tmp/pod-shared +{{ if $mounts_manila_share.volumeMounts }}{{ toYaml $mounts_manila_share.volumeMounts | indent 12 }}{{ end }} containers: - name: manila-share {{ tuple $envAll "manila_share" | include "helm-toolkit.snippets.image" | indent 10 }} @@ -73,6 +89,8 @@ spec: volumeMounts: - name: pod-tmp mountPath: /tmp + - name: pod-shared + mountPath: /tmp/pod-shared - name: etcmanila mountPath: /etc/manila - name: state-tmp @@ -127,6 +145,8 @@ spec: volumes: - name: pod-tmp emptyDir: {} + - name: pod-shared + emptyDir: {} - name: state-tmp emptyDir: {} - name: etcmanila diff --git a/manila/values.yaml b/manila/values.yaml index 76e19d36dd..4c3f83a68e 100644 --- a/manila/values.yaml +++ b/manila/values.yaml @@ -90,6 +90,12 @@ pod: manila_test: allowPrivilegeEscalation: false readOnlyRootFilesystem: true + use_fqdn: + # NOTE: Setting the option here to true will cause use $(hostname --fqdn) + # as the host name by default. If the short name is desired + # $(hostname --short), set the option to false. Specifying a host in the + # manila.conf via the conf section will supersede the value of this option. + share: true affinity: anti: type: diff --git a/releasenotes/notes/manila.yaml b/releasenotes/notes/manila.yaml index 6b83d631da..eda1defa88 100644 --- a/releasenotes/notes/manila.yaml +++ b/releasenotes/notes/manila.yaml @@ -7,4 +7,5 @@ manila: - 0.1.4 Add Ubuntu Jammy overrides - 0.1.5 Update port name of service-api.yaml - 0.1.6 Add 2023.2 Ubuntu Jammy overrides + - 0.1.7 Properly config network host for share service ...