|
| 1 | +# Copyright 2025 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 | +# https://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 | +name: Basic GPU cluster create |
| 16 | + |
| 17 | +on: |
| 18 | + workflow_call: |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +jobs: |
| 24 | + gpu-cluster-create-and-delete: |
| 25 | + runs-on: [ubuntu-22.04] |
| 26 | + concurrency: |
| 27 | + group: nightly-test-cluster-group-gpu |
| 28 | + cancel-in-progress: false |
| 29 | + env: |
| 30 | + GPU_CLUSTER_NAME: nightly-xpk-b200 |
| 31 | + WORKLOAD_NAME: xpktest-gpu-nightly-${{ github.run_attempt }} |
| 32 | + steps: |
| 33 | + - uses: actions/download-artifact@v4 |
| 34 | + with: |
| 35 | + name: custom-scripts |
| 36 | + - name: Setup environment |
| 37 | + uses: ./.github/actions/setup-test-env |
| 38 | + with: |
| 39 | + credentials_json: "${{ secrets.GCP_SA_KEY }}" |
| 40 | + - name: Check xpk installation |
| 41 | + run: xpk version |
| 42 | + - name: 'Setup Service Account for XPK' |
| 43 | + run: | |
| 44 | + # 1. Clear any existing WIF configurations to avoid conflicts |
| 45 | + rm -rf $HOME/.config/gcloud |
| 46 | + mkdir -p $HOME/.config/gcloud |
| 47 | +
|
| 48 | + # 2. Write the Key File |
| 49 | + echo '${{ secrets.GCP_SA_KEY }}' > $HOME/.config/gcloud/application_default_credentials.json |
| 50 | +
|
| 51 | + # 3. Activate the Service Account |
| 52 | + # This updates the internal config files to point to the key file. |
| 53 | + # When Docker mounts the directory, it will now see "Active Account: Service Account" |
| 54 | + gcloud auth activate-service-account --key-file=$HOME/.config/gcloud/application_default_credentials.json --project=cloud-tpu-multipod-dev |
| 55 | +
|
| 56 | + # 4. Set Env Var for the host (GitHub Runner) |
| 57 | + echo "GOOGLE_APPLICATION_CREDENTIALS=$HOME/.config/gcloud/application_default_credentials.json" >> $GITHUB_ENV |
| 58 | + - name: Create an XPK Cluster with 1 x b200 GPU |
| 59 | + run: xpk cluster create --cluster $GPU_CLUSTER_NAME --device-type=b200-8 --zone=asia-northeast1-b --default-pool-cpu-machine-type=n1-standard-16 --spot |
| 60 | + - name: Authenticate Docker |
| 61 | + run: gcloud auth configure-docker --quiet |
| 62 | + - name: Run a base-docker-image workload |
| 63 | + run: xpk workload create --cluster $GPU_CLUSTER_NAME --workload $WORKLOAD_NAME --docker-image='nvidia/cuda:12.1.0-base-ubuntu22.04' --command "nvidia-smi" --zone=asia-northeast1-b --device-type=b200-8 |
| 64 | + - name: List out the workloads on the cluster |
| 65 | + run: xpk workload list --cluster $GPU_CLUSTER_NAME --zone=asia-northeast1-b |
| 66 | + - name: Wait for workload completion and confirm it succeeded |
| 67 | + run: xpk workload list --cluster $GPU_CLUSTER_NAME --zone=asia-northeast1-b --wait-for-job-completion $WORKLOAD_NAME --timeout 600 |
| 68 | + - name: Delete the workload on the cluster |
| 69 | + run: xpk workload delete --workload $WORKLOAD_NAME --cluster $GPU_CLUSTER_NAME --zone=asia-northeast1-b |
| 70 | + - name: Delete the cluster created |
| 71 | + if: always() |
| 72 | + run: xpk cluster delete --cluster $GPU_CLUSTER_NAME --zone=asia-northeast1-b --force |
| 73 | + - name: Upload cluster nodepool creation log |
| 74 | + if: always() |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: gpu-cluster-nodepool-log-${{github.run_id}} |
| 78 | + path: /tmp/NodepoolCreate-${{ env.GPU_CLUSTER_NAME }}-np-* |
0 commit comments