diff --git a/ceph-client/templates/bin/utils/_checkDNS.sh.tpl b/ceph-client/templates/bin/utils/_checkDNS.sh.tpl index 482dcaf67d..2cd7d8991d 100644 --- a/ceph-client/templates/bin/utils/_checkDNS.sh.tpl +++ b/ceph-client/templates/bin/utils/_checkDNS.sh.tpl @@ -17,17 +17,14 @@ limitations under the License. */}} : "${CEPH_CONF:="/etc/ceph/${CLUSTER}.conf"}" -ENDPOINT=$1 +ENDPOINT="{$1}" function check_mon_dns () { GREP_CMD=$(grep -rl 'ceph-mon' ${CEPH_CONF}) - if [[ ${ENDPOINT} == "up" ]]; then - # If DNS is working, we simply restore the ${CEPH_CONF} file - if [[ ${GREP_CMD} == "" ]]; then - sh -c -e "cat ${CEPH_CONF}.template | tee ${CEPH_CONF}" > /dev/null 2>&1 - fi - elif [[ ${ENDPOINT} != "" ]]; then + if [[ "${ENDPOINT}" == "up" ]]; then + echo "If DNS is working, we are good here" + elif [[ "${ENDPOINT}" != "" ]]; then if [[ ${GREP_CMD} != "" ]]; then # No DNS, write CEPH MONs IPs into ${CEPH_CONF} sh -c -e "cat ${CEPH_CONF}.template | sed 's/mon_host.*/mon_host = ${ENDPOINT}/g' | tee ${CEPH_CONF}" > /dev/null 2>&1 diff --git a/ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl b/ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl index c91a2b9ffe..e9c303d8a2 100644 --- a/ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl +++ b/ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl @@ -20,15 +20,19 @@ set -xe function check_mon_dns { DNS_CHECK=$(getent hosts ceph-mon | head -n1) - PODS=$(kubectl get pods --namespace=${NAMESPACE} --selector=application=ceph --field-selector=status.phase=Running --output=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E 'ceph-mon|ceph-osd|ceph-mgr|ceph-mds') - ENDPOINT=$(kubectl get endpoints ceph-mon -n ${NAMESPACE} -o json | awk -F'"' -v port=${MON_PORT} '/ip/{print $4":"port}' | paste -sd',') + PODS=$(kubectl get pods --namespace=${NAMESPACE} --selector=application=ceph --field-selector=status.phase=Running \ + --output=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E 'ceph-mon|ceph-osd|ceph-mgr|ceph-mds') + ENDPOINT=$(kubectl get endpoints ceph-mon-discovery -n ${NAMESPACE} -o json | awk -F'"' -v port=${MON_PORT} \ + -v version=v1 -v msgr_version=v2 \ + -v msgr2_port=${MON_PORT_V2} \ + '/"ip"/{print "["version":"$4":"port"/"0","msgr_version":"$4":"msgr2_port"/"0"]"}' | paste -sd',') - if [[ ${PODS} == "" || ${ENDPOINT} == "" ]]; then + if [[ ${PODS} == "" || "${ENDPOINT}" == "" ]]; then echo "Something went wrong, no PODS or ENDPOINTS are available!" elif [[ ${DNS_CHECK} == "" ]]; then for POD in ${PODS}; do kubectl exec -t ${POD} --namespace=${NAMESPACE} -- \ - sh -c -e "/tmp/utils-checkDNS.sh ${ENDPOINT}" + sh -c -e "/tmp/utils-checkDNS.sh "${ENDPOINT}"" done else for POD in ${PODS}; do diff --git a/ceph-client/templates/deployment-checkdns.yaml b/ceph-client/templates/deployment-checkdns.yaml index 14bc97033d..97559171d9 100644 --- a/ceph-client/templates/deployment-checkdns.yaml +++ b/ceph-client/templates/deployment-checkdns.yaml @@ -97,6 +97,8 @@ spec: fieldPath: metadata.namespace - name: MON_PORT value: {{ tuple "ceph_mon" "internal" "mon" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} + - name: MON_PORT_V2 + value: {{ tuple "ceph_mon" "internal" "mon_msgr2" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} - name: KUBECTL_PARAM value: {{ tuple $envAll "ceph" "checkdns" | include "helm-toolkit.snippets.kubernetes_kubectl_params" | indent 10 }} command: diff --git a/ceph-client/values.yaml b/ceph-client/values.yaml index 0ba52e84c6..e5f788890d 100644 --- a/ceph-client/values.yaml +++ b/ceph-client/values.yaml @@ -527,6 +527,8 @@ endpoints: port: mon: default: 6789 + mon_msgr2: + default: 3300 ceph_mgr: namespace: null hosts: