Merge "[ceph-client] update checkdns script logic to handle mon_host config"
This commit is contained in:
commit
da0f5c7b9b
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -527,6 +527,8 @@ endpoints:
|
||||
port:
|
||||
mon:
|
||||
default: 6789
|
||||
mon_msgr2:
|
||||
default: 3300
|
||||
ceph_mgr:
|
||||
namespace: null
|
||||
hosts:
|
||||
|
Loading…
x
Reference in New Issue
Block a user