13.4. PolicyGenerator CR을 사용하여 작업자 노드 정책을 작업자 노드에 적용


PolicyGenerator CR을 사용하여 작업자 노드에 대한 정책을 생성할 수 있습니다.

프로세스

  1. 다음 PolicyGenerator CR을 생성합니다.

    apiVersion: policy.open-cluster-management.io/v1
    kind: PolicyGenerator
    metadata:
        name: example-sno-workers
    placementBindingDefaults:
        name: example-sno-workers-placement-binding
    policyDefaults:
        namespace: example-sno
        placement:
            labelSelector:
                matchExpressions:
                    - key: sites
                      operator: In
                      values:
                        - example-sno 1
        remediationAction: inform
        severity: low
        namespaceSelector:
            exclude:
                - kube-*
            include:
                - '*'
        evaluationInterval:
            compliant: 10m
            noncompliant: 10s
    policies:
        - name: example-sno-workers-config-policy
          policyAnnotations:
            ran.openshift.io/ztp-deploy-wave: "10"
          manifests:
            - path: source-crs/MachineConfigGeneric.yaml 2
              patches:
                - metadata:
                    labels:
                        machineconfiguration.openshift.io/role: worker 3
                    name: enable-workload-partitioning
                  spec:
                    config:
                        storage:
                            files:
                                - contents:
                                    source: data:text/plain;charset=utf-8;base64,W2NyaW8ucnVudGltZS53b3JrbG9hZHMubWFuYWdlbWVudF0KYWN0aXZhdGlvbl9hbm5vdGF0aW9uID0gInRhcmdldC53b3JrbG9hZC5vcGVuc2hpZnQuaW8vbWFuYWdlbWVudCIKYW5ub3RhdGlvbl9wcmVmaXggPSAicmVzb3VyY2VzLndvcmtsb2FkLm9wZW5zaGlmdC5pbyIKcmVzb3VyY2VzID0geyAiY3B1c2hhcmVzIiA9IDAsICJjcHVzZXQiID0gIjAtMyIgfQo=
                                  mode: 420
                                  overwrite: true
                                  path: /etc/crio/crio.conf.d/01-workload-partitioning
                                  user:
                                    name: root
                                - contents:
                                    source: data:text/plain;charset=utf-8;base64,ewogICJtYW5hZ2VtZW50IjogewogICAgImNwdXNldCI6ICIwLTMiCiAgfQp9Cg==
                                  mode: 420
                                  overwrite: true
                                  path: /etc/kubernetes/openshift-workload-pinning
                                  user:
                                    name: root
            - path: source-crs/PerformanceProfile-MCP-worker.yaml
              patches:
                - metadata:
                    name: openshift-worker-node-performance-profile
                  spec:
                    cpu: 4
                        isolated: 4-47
                        reserved: 0-3
                    hugepages:
                        defaultHugepagesSize: 1G
                        pages:
                            - count: 32
                              size: 1G
                    realTimeKernel:
                        enabled: true
            - path: source-crs/TunedPerformancePatch-MCP-worker.yaml
              patches:
                - metadata:
                    name: performance-patch-worker
                  spec:
                    profile:
                        - data: |
                          [main]
                          summary=Configuration changes profile inherited from performance created tuned
                          include=openshift-node-performance-openshift-worker-node-performance-profile
                          [bootloader]
                          cmdline_crash=nohz_full=4-47 5
                          [sysctl]
                          kernel.timer_migration=1
                          [scheduler]
                          group.ice-ptp=0:f:10:*:ice-ptp.*
                          [service]
                          service.stalld=start,enable
                          service.chronyd=stop,disable
                          name: performance-patch-worker
                    recommend:
                        - profile: performance-patch-worker
    1
    정책은 이 레이블이 있는 모든 클러스터에 적용됩니다.
    2
    이 일반 MachineConfig CR은 작업자 노드에서 워크로드 파티셔닝을 구성하는 데 사용됩니다.
    3
    MCP 필드는 worker 로 설정해야 합니다.
    4
    각 특정 하드웨어 플랫폼에 대해 cpu.isolatedcpu.reserved 필드를 구성해야 합니다.
    5
    cmdline_crash CPU 세트는 PerformanceProfile 섹션의 cpu.isolated 세트와 일치해야 합니다.

    일반 MachineConfig CR은 작업자 노드에서 워크로드 파티셔닝을 구성하는 데 사용됩니다. criokubelet 구성 파일의 콘텐츠를 생성할 수 있습니다.

  2. ArgoCD 정책 애플리케이션에서 모니터링하는 Git 리포지토리에 생성된 정책 템플릿을 추가합니다.
  3. kustomization.yaml 파일에 정책을 추가합니다.
  4. Git의 변경 사항을 커밋한 다음 GitOps ZTP ArgoCD 애플리케이션에서 모니터링하는 Git 리포지토리로 내보냅니다.
  5. spoke 클러스터에 대한 새 정책을 수정하려면 TALM 사용자 정의 리소스를 생성합니다.

    $ cat <<EOF | oc apply -f -
    apiVersion: ran.openshift.io/v1alpha1
    kind: ClusterGroupUpgrade
    metadata:
      name: example-sno-worker-policies
      namespace: default
    spec:
      backup: false
      clusters:
      - example-sno
      enable: true
      managedPolicies:
      - group-du-sno-config-policy
      - example-sno-workers-config-policy
      - example-sno-config-policy
      preCaching: false
      remediationStrategy:
        maxConcurrency: 1
    EOF
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.