From c56ebf2ea66884fef13f351894dcb6de1a703ced Mon Sep 17 00:00:00 2001 From: Huamin Chen Date: Thu, 7 Sep 2017 08:54:24 -0400 Subject: [PATCH] Ceph: mon should get Pods from namespace other than ceph Currently CLUSTER and deployment namespace both default to ceph, so these variables can be used exchangeably.But once deployment namespace changes, MON daemonset will not be able to get its IP from ceph namespace. This fix swaps CLUSTER with NAMESPACE and solves this problem Change-Id: I0cf6afafb71f3972e24d13d479192e7a4e155de4 Signed-off-by: Huamin Chen --- ceph/templates/bin/_start_mon.sh.tpl | 4 ++-- ceph/templates/daemonset-mon.yaml | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ceph/templates/bin/_start_mon.sh.tpl b/ceph/templates/bin/_start_mon.sh.tpl index f2ed4a8c62..46059d086e 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=${CLUSTER} -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} -l application=ceph -l component=mon -o template --template="{{`{{range .items}}`}}{{`{{if .status.podIP}}`}}--add {{`{{.metadata.name}}`}} {{`{{.status.podIP}}`}} {{`{{end}}`}} {{`{{end}}`}}") else - MONMAP_ADD=$(kubectl get pods --namespace=${CLUSTER} -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} -l application=ceph -l component=mon -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 30856873ce..901d2aa851 100644 --- a/ceph/templates/daemonset-mon.yaml +++ b/ceph/templates/daemonset-mon.yaml @@ -65,6 +65,11 @@ spec: value: "1" - name: MONMAP value: /var/lib/ceph/mon/monmap + - name: NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace - name: CEPH_DAEMON value: mon - name: CEPH_PUBLIC_NETWORK