|
| 1 | +# Copyright 2024 "Google LLC" |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +apiVersion: batch/v1 |
| 16 | +kind: CronJob |
| 17 | +metadata: |
| 18 | + name: cluster-health-scanner-cronjob |
| 19 | +spec: |
| 20 | + schedule: "${cronjob_schedule}" |
| 21 | + concurrencyPolicy: Forbid |
| 22 | + successfulJobsHistoryLimit: 3 |
| 23 | + failedJobsHistoryLimit: 1 |
| 24 | + suspend: false |
| 25 | + jobTemplate: |
| 26 | + spec: |
| 27 | + template: |
| 28 | + spec: |
| 29 | + serviceAccountName: workload-identity-k8s-sa |
| 30 | + containers: |
| 31 | + - name: chs-runner |
| 32 | + image: python:3.11-slim-buster |
| 33 | + imagePullPolicy: Always |
| 34 | + command: |
| 35 | + - /bin/bash |
| 36 | + - -c |
| 37 | + - | |
| 38 | + set -ex |
| 39 | + set -x |
| 40 | + apt-get update && apt-get install -y git curl gnupg -y |
| 41 | + git clone https://github.com/GoogleCloudPlatform/cluster-health-scanner |
| 42 | + cd cluster-health-scanner |
| 43 | + apt-get install -y apt-transport-https ca-certificates |
| 44 | + curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg |
| 45 | + echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list |
| 46 | + apt-get update |
| 47 | + apt-get install -y google-cloud-cli kubectl |
| 48 | + apt-get install -y google-cloud-cli-gke-gcloud-auth-plugin |
| 49 | + curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash |
| 50 | + pip3 install -r cli/requirements.txt |
| 51 | + gcloud container clusters get-credentials ${deployment_name} --region ${region} --project ${project_id} |
| 52 | + OUTPUT_DIR="/mnt/output" |
| 53 | + mkdir -p $OUTPUT_DIR |
| 54 | + TIMESTAMP="`date "+%Y-%m-%d %H:%M:%S"`" |
| 55 | + OUTPUT_FILENAME="${deployment_name}_healthscan_result_$TIMESTAMP.txt" |
| 56 | + FULL_OUTPUT_PATH="$OUTPUT_DIR/$OUTPUT_FILENAME" |
| 57 | + python3 cli/cluster_diag.py -o gke healthscan ${machine_type} -c gpu --run_only_on_available_nodes |
| 58 | + python3 cli/cluster_diag.py -o gke healthscan ${machine_type} -c nccl --run_only_on_available_nodes |
| 59 | + python3 cli/cluster_diag.py -o gke healthscan ${machine_type} -c straggler --run_only_on_available_nodes |
| 60 | + python3 cli/cluster_diag.py -o gke healthscan ${machine_type} -c neper --run_only_on_available_nodes |
| 61 | + python3 cli/cluster_diag.py -o gke healthscan ${machine_type} -c tinymax --run_only_on_available_nodes |
| 62 | + #python3 cli/cluster_diag.py -o gke healthscan ${machine_type} -c status --run_only_on_available_nodes > "$FULL_OUTPUT_PATH" 2>&1 |
| 63 | + kubectl get nodes -o custom-columns="NODE:.metadata.name,NCCL_MARK:.metadata.labels.aiinfra/nccl-healthcheck-test,NCCL_BANDWIDTH:.metadata.labels.aiinfra/nccl-healthcheck-bandwidth,NCCL_RESULT:.metadata.labels.aiinfra/nccl-healthcheck-result,NCCL_RUNTIME:.metadata.labels.aiinfra/nccl-healthcheck-runtime-sec,TINYMAX_MARK:.metadata.labels.aiinfra/tinymax-healthcheck-test,TINYMAX_RESULT:.metadata.labels.aiinfra/tinymax-healthcheck-result,TINYMAX_RUNTIME:.metadata.labels.aiinfra/tinymax-healthcheck-runtime-sec,GPU_MARK:.metadata.labels.aiinfra/gpu-healthcheck-test,GPU_RESULT:.metadata.labels.aiinfra/gpu-healthcheck-result,GPU_RUNTIME:.metadata.labels.aiinfra/gpu-healthcheck-runtime-sec" > "$FULL_OUTPUT_PATH" 2>&1 |
| 64 | + echo "Health scan outputs saved to $OUTPUT_DIR" |
| 65 | + echo "Final output file: $OUTPUT_FILENAME" |
| 66 | + volumeMounts: |
| 67 | + - name: ${gcs_bucket} |
| 68 | + mountPath: /mnt/output |
| 69 | + volumes: |
| 70 | + - name: ${gcs_bucket} |
| 71 | + persistentVolumeClaim: |
| 72 | + claimName: ${gcs_pvc} |
| 73 | + restartPolicy: Never |
| 74 | + tolerations: |
| 75 | + - key: "nvidia.com/gpu" |
| 76 | + operator: "Exists" |
| 77 | + effect: "NoSchedule" |
| 78 | + - key: "components.gke.io/gke-managed-components" |
| 79 | + operator: "Exists" |
| 80 | + effect: "NoSchedule" |
| 81 | + backoffLimit: 0 |
0 commit comments