• Русский
  • Интеграция с Alauda DevOps Pipelines

    На этой странице показано, как использовать возможности планирования и управления ресурсами Alauda Build of Kueue при запуске Alauda DevOps Pipelines (Tekton Pipelines).

    Предварительные требования

    • Установлены Alauda DevOps Pipelines.
    • Установлен Alauda Build of Kueue.
    • Установлен Alauda Build of Hami (для демонстрации vGPU).
    • Веб CLI Alauda Container Platform имеет связь с вашим кластером.

    Процедура

    1. Создайте проект и namespace в Alauda Container Platform, например, имя проекта test, а имя namespace — test-1.

    2. Создайте ресурсы, выполнив следующую команду:

      cat <<EOF| kubectl create -f -
      apiVersion: kueue.x-k8s.io/v1beta2
      kind: ClusterQueue
      metadata:
        name: cluster-queue
      spec:
        namespaceSelector: {}
        resourceGroups:
        - coveredResources: ["cpu", "memory", "pods", "nvidia.com/gpualloc", "nvidia.com/total-gpucores", "nvidia.com/total-gpumem"]
          flavors:
          - name: "default-flavor"
            resources:
            - name: "cpu"
              nominalQuota: 9
            - name: "memory"
              nominalQuota: 36Gi
            - name: "pods"
              nominalQuota: 5
            - name: "nvidia.com/gpualloc"
              nominalQuota: "2"
            - name: "nvidia.com/total-gpucores"
              nominalQuota: "50"
            - name: "nvidia.com/total-gpumem"
              nominalQuota: "20000"
      ---
      apiVersion: kueue.x-k8s.io/v1beta2
      kind: ResourceFlavor
      metadata:
        name: default-flavor
      ---
      apiVersion: kueue.x-k8s.io/v1beta2
      kind: LocalQueue
      metadata:
        namespace: test-1
        name: test
      spec:
        clusterQueue: cluster-queue
      EOF
    3. Создайте ресурс Pipeline в Alauda Container Platform через Web CLI или UI:

      apiVersion: tekton.dev/v1
      kind: Pipeline
      metadata:
        name: test
        namespace: test-1
      spec:
        tasks:
          - name: run-script
            taskSpec:
              description: test
              metadata: {}
              spec: null
              steps:
                - computeResources:
                    limits:
                      cpu: "2"
                      memory: 2Gi
                      nvidia.com/gpualloc: "2"
                      nvidia.com/gpucores: "50"
                      nvidia.com/gpumem: 8k
                    requests:
                      cpu: "1"
                      memory: 1Gi
                  image: nvidia/cuda:11.0-base
                  imagePullPolicy: IfNotPresent
                  name: run-script
                  script: |
                    #!/bin/sh
                    nvidia-smi
                  securityContext:
                    allowPrivilegeEscalation: false
                    capabilities:
                      drop:
                        - ALL
                    runAsNonRoot: true
                    runAsUser: 65532
                    seccompProfile:
                      type: RuntimeDefault
            timeout: 30m0s
    4. Создайте ресурс PipelineRun в Alauda Container Platform через Web CLI или UI:

      apiVersion: tekton.dev/v1
      kind: PipelineRun
      metadata:
        annotations:
          chains.tekton.dev/signed: "true"
          integrations.tekton.dev/integrations: |
            []
        generateName: test-
        labels:
          tekton.dev/pipeline: test
          kueue.x-k8s.io/queue-name: test
        namespace: test-1
      spec:
        pipelineRef:
          name: test
        taskRunTemplate:
          podTemplate:
            securityContext:
              fsGroup: 65532
              fsGroupChangePolicy: OnRootMismatch
          serviceAccountName: default
        timeouts:
          pipeline: 1h0m0s
      1. Метка kueue.x-k8s.io/queue-name: test: указывает LocalQueue, который управляет всеми pod-ами PipelineRun.
      2. spec.pipelineRef.name: указывает ресурс Pipeline, на который ссылается PipelineRun.
    5. Наблюдайте за pod-ами PipelineRun:

      kubectl -n test-1 get pod | grep test

      Вы увидите, что pod находится в состоянии SchedulingGated:

      test-dw4q7-run-script-pod   0/1     SchedulingGated   0          13s   <none>   <none>   <none>           <none>
    6. Обновите квоты nvidia.com/total-gpucores:

      cat <<EOF| kubectl apply -f -
      apiVersion: kueue.x-k8s.io/v1beta2
      kind: ClusterQueue
      metadata:
        name: cluster-queue
      spec:
        namespaceSelector: {}
        resourceGroups:
        - coveredResources: ["cpu", "memory", "pods", "nvidia.com/gpualloc", "nvidia.com/total-gpucores", "nvidia.com/total-gpumem"]
          flavors:
          - name: "default-flavor"
            resources:
            - name: "cpu"
              nominalQuota: 9
            - name: "memory"
              nominalQuota: 36Gi
            - name: "pods"
              nominalQuota: 5
            - name: "nvidia.com/gpualloc"
              nominalQuota: "2"
            - name: "nvidia.com/total-gpucores"
              nominalQuota: "100"
            - name: "nvidia.com/total-gpumem"
              nominalQuota: "20000"
      EOF

      Вы увидите, что pod находится в состоянии Running:

      test-dw4q7-run-script-pod   1/1     Running   0          13s   <none>   <none>   <none>           <none>