• Русский
  • Настройка квот ресурсов для компонентов Pipeline

    Обзор

    Настройте квоты ресурсов, связанные с компонентом Pipeline.

    Варианты использования

    • Настройка квот ресурсов для компонента Pipeline
    • Задание квот ресурсов по умолчанию для init-контейнеров и контейнеров, создаваемых TaskRun

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

    Рекомендации по настройке ресурсов

    Перед настройкой квот ресурсов:

    • Оцените доступные ресурсы и емкость вашего cluster
    • Учитывайте характеристики нагрузки и требования к производительности
    • Начинайте с консервативных значений и корректируйте их на основе данных мониторинга
    • Сначала проверяйте конфигурации в непроизводственных средах

    Шаги

    Шаг 1

    Отредактируйте ресурс TektonConfig

    $ kubectl edit tektonconfigs.operator.tekton.dev config

    Шаг 2

    WARNING

    Изменение конфигурации может вызвать rolling update Pods компонента, что может привести к временному недоступности сервиса. Выполняйте это в подходящий момент.

    Пример изменения конфигурации spec.pipeline.options.deployments:

    apiVersion: operator.tekton.dev/v1alpha1
    kind: TektonConfig
    metadata:
      name: config
    spec:
      pipeline:
        options:
          disabled: false
    
          configMaps:
            config-defaults:
              data:
                # Add default container resource quotas
                # Adjust the values below according to your cluster's resource capacity and workload requirements
                default-container-resource-requirements: |
                  place-scripts: # updates resource requirements of a 'place-scripts' container
                    requests:
                      memory: "<MEMORY_REQUEST>"  # e.g., "128Mi"
                      cpu: "<CPU_REQUEST>"        # e.g., "250m"
                    limits:
                      memory: "<MEMORY_LIMIT>"    # e.g., "512Mi"
                      cpu: "<CPU_LIMIT>"          # e.g., "500m"
    
                  prepare: # updates resource requirements of a 'prepare' container
                    requests:
                      memory: "<MEMORY_REQUEST>"  # e.g., "128Mi"
                      cpu: "<CPU_REQUEST>"        # e.g., "250m"
                    limits:
                      memory: "<MEMORY_LIMIT>"    # e.g., "256Mi"
                      cpu: "<CPU_LIMIT>"          # e.g., "500m"
    
                  working-dir-initializer: # updates resource requirements of a 'working-dir-initializer' container
                    requests:
                      memory: "<MEMORY_REQUEST>"  # e.g., "128Mi"
                      cpu: "<CPU_REQUEST>"        # e.g., "250m"
                    limits:
                      memory: "<MEMORY_LIMIT>"    # e.g., "512Mi"
                      cpu: "<CPU_LIMIT>"          # e.g., "500m"
    
                  prefix-scripts: # updates resource requirements of containers which starts with 'scripts-'
                    requests:
                      memory: "<MEMORY_REQUEST>"  # e.g., "128Mi"
                      cpu: "<CPU_REQUEST>"        # e.g., "250m"
                    limits:
                      memory: "<MEMORY_LIMIT>"    # e.g., "512Mi"
                      cpu: "<CPU_LIMIT>"          # e.g., "500m"
    
                  prefix-sidecar-scripts: # updates resource requirements of containers which starts with 'sidecar-scripts-'
                    requests:
                      memory: "<MEMORY_REQUEST>"  # e.g., "128Mi"
                      cpu: "<CPU_REQUEST>"        # e.g., "250m"
                    limits:
                      memory: "<MEMORY_LIMIT>"    # e.g., "512Mi"
                      cpu: "<CPU_LIMIT>"          # e.g., "500m"
    
                  sidecar-tekton-log-results: # updates resource requirements of a 'sidecar-tekton-log-results' container
                    requests:
                      memory: "<MEMORY_REQUEST>"  # e.g., "128Mi"
                      cpu: "<CPU_REQUEST>"        # e.g., "100m"
                    limits:
                      memory: "<MEMORY_LIMIT>"    # e.g., "256Mi"
                      cpu: "<CPU_LIMIT>"          # e.g., "250m"
    
          deployments:
            # Adjust the resource values below according to your cluster's capacity and performance requirements
            tekton-pipelines-controller:
              spec:
                replicas: <REPLICA_COUNT>  # e.g., 1
                template:
                  spec:
                    containers:
                      - name: tekton-pipelines-controller
                        resources:
                          requests:
                            cpu: <CPU_REQUEST>        # e.g., "500m"
                            memory: <MEMORY_REQUEST>  # e.g., "512Mi"
                          limits:
                            cpu: <CPU_LIMIT>          # e.g., "1"
                            memory: <MEMORY_LIMIT>    # e.g., "1Gi"
    
            tekton-pipelines-remote-resolvers:
              spec:
                replicas: <REPLICA_COUNT>  # e.g., 1
                template:
                  spec:
                    containers:
                      - name: controller
                        resources:
                          requests:
                            cpu: <CPU_REQUEST>        # e.g., "200m"
                            memory: <MEMORY_REQUEST>  # e.g., "256Mi"
                          limits:
                            cpu: <CPU_LIMIT>          # e.g., "500m"
                            memory: <MEMORY_LIMIT>    # e.g., "512Mi"
    
            tekton-pipelines-webhook:
              spec:
                replicas: <REPLICA_COUNT>  # e.g., 1
                template:
                  spec:
                    containers:
                      - name: webhook
                        resources:
                          requests:
                            cpu: <CPU_REQUEST>        # e.g., "500m"
                            memory: <MEMORY_REQUEST>  # e.g., "256Mi"
                          limits:
                            cpu: <CPU_LIMIT>          # e.g., "1"
                            memory: <MEMORY_LIMIT>    # e.g., "500Mi"
    
            tekton-events-controller:
              spec:
                replicas: <REPLICA_COUNT>  # e.g., 1
                template:
                  spec:
                    containers:
                      - name: tekton-events-controller
                        resources:
                          requests:
                            cpu: <CPU_REQUEST>        # e.g., "100m"
                            memory: <MEMORY_REQUEST>  # e.g., "100Mi"
                          limits:
                            cpu: <CPU_LIMIT>          # e.g., "200m"
                            memory: <MEMORY_LIMIT>    # e.g., "256Mi"

    Шаг 3

    Примените конфигурацию и дождитесь обновления Pods.

    $ kubectl get pods -n tekton-pipelines -w
    
    NAME                                                    READY   STATUS    RESTARTS   AGE
    tekton-pipelines-controller-648d87488b-fq9bc            1/1     Running   0          2m21s
    tekton-pipelines-remote-resolvers-79554f5959-cbm6x      1/1     Running   0          2m21s
    tekton-pipelines-webhook-5cd9847998-864zf               1/1     Running   0          2m20s
    tekton-events-controller-5c97b7554c-m59m6               1/1     Running   0          2m21s

    Результат операции

    Вы можете убедиться, что конфигурации квот ресурсов для связанных с Pipeline компонентов применены.

    $ kubectl get deployments.apps -n tekton-pipelines tekton-pipelines-controller tekton-pipelines-remote-resolvers tekton-pipelines-webhook tekton-events-controller -o yaml | grep 'resources:' -A 6
    
              resources:
                limits:
                  cpu: "1"
                  memory: 1Gi
                requests:
                  cpu: 500m
                  memory: 512Mi
    --
              resources:
                limits:
                  cpu: 500m
                  memory: 512Mi
                requests:
                  cpu: 200m
                  memory: 256Mi
    --
              resources:
                limits:
                  cpu: "2"
                  memory: 500Mi
                requests:
                  cpu: "1"
                  memory: 256Mi
    --
              resources:
                limits:
                  cpu: 200m
                  memory: 256Mi
                requests:
                  cpu: 100m
                  memory: 100Mi

    Проверка конфигурации квот ресурсов Pod

    Создание TaskRun

    $ cat <<'EOF' | kubectl create -f -
    apiVersion: tekton.dev/v1
    kind: TaskRun
    metadata:
      name: hello
      namespace: default
    spec:
      taskSpec:
        steps:
          - name: hello
            image: alpine
            command: ["echo", "hello"]
    EOF

    Дождитесь завершения TaskRun

    $ kubectl get taskruns.tekton.dev -n default hello
    
    NAME    SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
    hello   True        Succeeded   2m41s       2m28s

    Просмотр конфигурации квот ресурсов Pod

    $ kubectl get pods -n default hello-hello-pod -o yaml
    
    apiVersion: v1
    kind: Pod
    metadata:
      name: hello-pod
      namespace: default
    spec:
      containers:
        - image: alpine
          name: step-hello
          resources: {}
      initContainers:
        - name: prepare
          resources:
            limits:
              cpu: 100m
              memory: 256Mi
            requests:
              cpu: 50m
              memory: 64Mi

    Как видите, квота ресурсов для контейнера prepare в initContainers в Pod соответствует квотам ресурсов, настроенным в ConfigMap config-defaults.

    Ссылки