diff --git a/ceph/templates/bin/_start_mon.sh.tpl b/ceph/templates/bin/_start_mon.sh.tpl index 46059d086e..12b386bb1b 100644 --- a/ceph/templates/bin/_start_mon.sh.tpl +++ b/ceph/templates/bin/_start_mon.sh.tpl @@ -30,9 +30,9 @@ function get_mon_config { while [[ -z "${MONMAP_ADD// }" && "${timeout}" -gt 0 ]]; do # Get the ceph mon pods (name and IP) from the Kubernetes API. Formatted as a set of monmap params if [[ ${K8S_HOST_NETWORK} -eq 0 ]]; then - MONMAP_ADD=$(kubectl get pods --namespace=${NAMESPACE} -l application=ceph -l component=mon -o template --template="{{`{{range .items}}`}}{{`{{if .status.podIP}}`}}--add {{`{{.metadata.name}}`}} {{`{{.status.podIP}}`}} {{`{{end}}`}} {{`{{end}}`}}") + MONMAP_ADD=$(kubectl get pods --namespace=${NAMESPACE} ${KUBECTL_PARAM} -o template --template="{{`{{range .items}}`}}{{`{{if .status.podIP}}`}}--add {{`{{.metadata.name}}`}} {{`{{.status.podIP}}`}} {{`{{end}}`}} {{`{{end}}`}}") else - MONMAP_ADD=$(kubectl get pods --namespace=${NAMESPACE} -l application=ceph -l component=mon -o template --template="{{`{{range .items}}`}}{{`{{if .status.podIP}}`}}--add {{`{{.spec.nodeName}}`}} {{`{{.status.podIP}}`}} {{`{{end}}`}} {{`{{end}}`}}") + MONMAP_ADD=$(kubectl get pods --namespace=${NAMESPACE} ${KUBECTL_PARAM} -o template --template="{{`{{range .items}}`}}{{`{{if .status.podIP}}`}}--add {{`{{.spec.nodeName}}`}} {{`{{.status.podIP}}`}} {{`{{end}}`}} {{`{{end}}`}}") fi (( timeout-- )) sleep 1 diff --git a/ceph/templates/daemonset-mon.yaml b/ceph/templates/daemonset-mon.yaml index c04c0c85c7..931fd4f371 100644 --- a/ceph/templates/daemonset-mon.yaml +++ b/ceph/templates/daemonset-mon.yaml @@ -75,6 +75,8 @@ spec: value: mon - name: CEPH_PUBLIC_NETWORK value: {{ .Values.network.public | quote }} + - name: KUBECTL_PARAM + value: {{ tuple $envAll "ceph" "mon" | include "helm-toolkit.snippets.kubernetes_kubectl_params" | indent 10 }} - name: MON_IP valueFrom: fieldRef: diff --git a/helm-toolkit/templates/snippets/_kubernetes_kubectl_params.tpl b/helm-toolkit/templates/snippets/_kubernetes_kubectl_params.tpl new file mode 100644 index 0000000000..988292943f --- /dev/null +++ b/helm-toolkit/templates/snippets/_kubernetes_kubectl_params.tpl @@ -0,0 +1,22 @@ +{{/* +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 "helm-toolkit.snippets.kubernetes_kubectl_params" -}} +{{- $envAll := index . 0 -}} +{{- $application := index . 1 -}} +{{- $component := index . 2 -}} +{{ print "-l application=" $application " -l component=" $component }} +{{- end -}}