diff --git a/ceph-client/templates/bin/utils/_defragOSDs.sh.tpl b/ceph-client/templates/bin/utils/_defragOSDs.sh.tpl new file mode 100644 index 000000000..fccb4d8ef --- /dev/null +++ b/ceph-client/templates/bin/utils/_defragOSDs.sh.tpl @@ -0,0 +1,31 @@ +#!/bin/bash + +{{/* +Copyright 2018 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. +*/}} + +set -ex + +PODS=$(kubectl get pods --namespace=${NAMESPACE} \ + --selector=application=ceph,component=osd --field-selector=status.phase=Running \ + '--output=jsonpath={range .items[*]}{.metadata.name}{"\n"}{end}') + +for POD in ${PODS}; do + kubectl exec -t ${POD} --namespace=${NAMESPACE} -- \ + sh -c -e "/tmp/utils-defragOSDs.sh" +done + + +exit 0 diff --git a/ceph-client/templates/configmap-bin.yaml b/ceph-client/templates/configmap-bin.yaml index f5227aa06..d825deb62 100644 --- a/ceph-client/templates/configmap-bin.yaml +++ b/ceph-client/templates/configmap-bin.yaml @@ -57,7 +57,10 @@ data: utils-checkPGs.py: | {{ tuple "bin/utils/_checkPGs.py.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} - utils-checkPGs.sh: | {{ tuple "bin/utils/_checkPGs.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + + utils-defragOSDs.sh: | +{{ tuple "bin/utils/_defragOSDs.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + {{- end }} diff --git a/ceph-osd/templates/cronjob-defragosds.yaml b/ceph-client/templates/cronjob-defragosds.yaml similarity index 96% rename from ceph-osd/templates/cronjob-defragosds.yaml rename to ceph-client/templates/cronjob-defragosds.yaml index 55db8449b..e204eed96 100644 --- a/ceph-osd/templates/cronjob-defragosds.yaml +++ b/ceph-client/templates/cronjob-defragosds.yaml @@ -73,7 +73,7 @@ spec: spec: serviceAccountName: {{ $serviceAccountName }} nodeSelector: - {{ .Values.labels.osd.node_selector_key }}: {{ .Values.labels.osd.node_selector_value }} + {{ .Values.labels.mgr.node_selector_key }}: {{ .Values.labels.mgr.node_selector_value }} containers: - name: {{ $serviceAccountName }} {{ tuple $envAll "ceph_config_helper" | include "helm-toolkit.snippets.image" | indent 12 }} @@ -107,7 +107,7 @@ spec: configMap: name: {{ printf "%s-%s" $envAll.Release.Name "bin" | quote }} defaultMode: 0555 - - name: ceph-osd-etc + - name: ceph-client-etc configMap: name: {{ printf "%s-%s" $envAll.Release.Name "etc" | quote }} defaultMode: 0444 diff --git a/ceph-client/values.yaml b/ceph-client/values.yaml index 1e54f9859..309c11868 100644 --- a/ceph-client/values.yaml +++ b/ceph-client/values.yaml @@ -188,6 +188,18 @@ network: cluster: 192.168.0.0/16 jobs: + ceph_defragosds: + # Execute the 1st of each month + cron: "0 0 1 * *" + history: + # Number of successful job to keep + successJob: 1 + # Number of failed job to keep + failJob: 1 + concurrency: + # Skip new job if previous job still active + execPolicy: Forbid + startingDeadlineSecs: 60 pool_checkPGs: # Execute every 15 minutes cron: "*/15 * * * *" @@ -536,3 +548,4 @@ manifests: service_mgr: true helm_tests: true cronjob_checkPGs: true + cronjob_defragosds: true diff --git a/ceph-osd/templates/bin/utils/_defragOSDs.sh.tpl b/ceph-osd/templates/bin/utils/_defragOSDs.sh.tpl index 6ea62ba19..95003f71b 100644 --- a/ceph-osd/templates/bin/utils/_defragOSDs.sh.tpl +++ b/ceph-osd/templates/bin/utils/_defragOSDs.sh.tpl @@ -18,20 +18,7 @@ limitations under the License. set -ex -ARG=${1} - -if [ "x${ARG}" == "xcron" ]; then - PODS=$(kubectl get pods --namespace=${NAMESPACE} \ - --selector=application=ceph,component=osd --field-selector=status.phase=Running \ - '--output=jsonpath={range .items[*]}{.metadata.name}{"\n"}{end}') - - for POD in ${PODS}; do - kubectl exec -t ${POD} --namespace=${NAMESPACE} -- \ - sh -c -e "/tmp/utils-defragOSDs.sh defrag" - done -fi - -if [ "x${ARG}" == "xdefrag" ] && [ "x${STORAGE_TYPE%-*}" == "xblock" ]; then +if [ "x${STORAGE_TYPE%-*}" == "xblock" ]; then OSD_DEVICE=$(readlink -f ${STORAGE_LOCATION}) ODEV=$(echo ${OSD_DEVICE} | sed 's/[0-9]//g' | cut -f 3 -d '/') OSD_PATH=$(cat /proc/mounts | awk '/ceph-/{print $2}') diff --git a/ceph-osd/values.yaml b/ceph-osd/values.yaml index 98dd765c5..9c6eae839 100644 --- a/ceph-osd/values.yaml +++ b/ceph-osd/values.yaml @@ -308,4 +308,3 @@ manifests: job_bootstrap: false job_image_repo_sync: true helm_tests: true - cronjob_defragosds: false