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 <hchen@redhat.com>
This commit is contained in:
Huamin Chen 2017-09-07 08:54:24 -04:00
parent 209be41928
commit c56ebf2ea6
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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