1.7. Argo CD 내보내기 모델에 대한 사용자 지정 서비스 계정 생성


hub 클러스터에서 ManagedServiceAccount 리소스를 생성하여 관리 클러스터에 서비스 계정을 생성합니다. ClusterPermission 리소스를 사용하여 서비스 계정에 특정 권한을 부여합니다.

Argo CD 내보내기 모델에 사용할 사용자 정의화 서비스 계정을 생성하면 다음과 같은 이점이 있습니다.

  • 애플리케이션 관리자 애드온은 각 관리 클러스터에서 실행됩니다. 기본적으로 Argo CD 컨트롤러는 서비스 계정 애플리케이션 관리자를 사용하여 이러한 리소스를 관리 클러스터로 내보냅니다.
  • 애플리케이션 서브스크립션 애드온에서 애플리케이션 관리자 서비스를 사용하여 관리형 클러스터에 애플리케이션을 배포하므로 애플리케이션 관리자 서비스 계정에는 많은 권한이 있습니다. 제한된 권한 집합을 원하는 경우 애플리케이션 관리자 서비스 계정을 사용하지 마십시오.
  • Argo CD 내보내기 모델을 사용할 다른 서비스 계정을 지정할 수 있습니다. Argo CD 컨트롤러가 중앙 집중식 허브 클러스터에서 관리 클러스터로 리소스를 푸시하는 경우 기본 애플리케이션 관리자와 다른 서비스 계정을 사용할 수 있습니다. 다른 서비스 계정을 사용하면 이 서비스 계정에 부여된 권한을 제어할 수 있습니다.
  • 서비스 계정이 관리 클러스터에 있어야 합니다. 연결된 권한으로 서비스 계정을 쉽게 생성하려면 중앙 집중식 허브 클러스터에서 ManagedServiceAccount 리소스 및 새 ClusterPermission 리소스를 사용합니다.

다음 절차를 모두 완료한 후 관리 서비스 계정에 클러스터 권한을 부여할 수 있습니다. 클러스터 권한이 있으면 관리 서비스 계정에는 관리 클러스터에 애플리케이션 리소스를 배포하는 데 필요한 권한이 있습니다. 다음 절차를 완료하십시오.

1.7.1. 관리 서비스 계정 생성

허브의 ManagedServiceAccount 사용자 지정 리소스는 관리 클러스터에서 ServiceAccount 를 쉽게 생성할 수 있는 방법을 제공합니다. hub 클러스터의 < managed-cluster > 네임스페이스에 ManagedServiceAccount 사용자 정의 리소스가 생성되면 관리 클러스터에 ServiceAccount 가 생성됩니다.

관리 서비스 계정을 생성하려면 ManagedServiceAccount 애드온 활성화를 참조하십시오.

1.7.2. 클러스터 권한 생성

서비스 계정이 생성되면 연결된 권한이 없습니다. 새 서비스 계정에 권한을 부여하려면 ClusterPermission 리소스를 사용합니다. ClusterPermission 리소스는 허브의 관리 클러스터 네임스페이스에 생성됩니다. 관리 클러스터에서 역할, 클러스터 역할 리소스를 생성하고 RoleBinding 또는 ClusterRoleBinding 리소스를 통해 서비스 계정에 바인딩할 수 있는 편리한 방법을 제공합니다.

  1. < managed-sa-sample > 서비스 계정에 < managed-sa- sample>의 mortgage 네임스페이스에 배포된 샘플 mortgage 애플리케이션에 서비스 계정 권한을 부여하려면 다음 내용으로 YAML을 생성합니다.
apiVersion: rbac.open-cluster-management.io/v1alpha1
kind: ClusterPermission
metadata:
  name: <clusterpermission-msa-subject-sample>
  namespace: <managed cluster>
spec:
  roles:
  - namespace: default
    rules:
    - apiGroups: ["apps"]
      resources: ["deployments"]
      verbs: ["get", "list", "create", "update", "delete", "patch"]
    - apiGroups: [""]
      resources: ["configmaps", "secrets", "pods", "podtemplates", "persistentvolumeclaims", "persistentvolumes"]
      verbs: ["get", "update", "list", "create", "delete", "patch"]
    - apiGroups: ["storage.k8s.io"]
      resources: ["*"]
      verbs: ["list"]
  - namespace: mortgage
    rules:
    - apiGroups: ["apps"]
      resources: ["deployments"]
      verbs: ["get", "list", "create", "update", "delete", "patch"]
    - apiGroups: [""]
      resources: ["configmaps", "secrets", "pods", "services", "namespace"]
      verbs: ["get", "update", "list", "create", "delete", "patch"]
  clusterRole:
    rules:
    - apiGroups: ["*"]
      resources: ["*"]
      verbs: ["get", "list"]
  roleBindings:
  - namespace: default
    roleRef:
      kind: Role
    subject:
      apiGroup: authentication.open-cluster-management.io
      kind: ManagedServiceAccount
      name: <managed-sa-sample>
  - namespace: mortgage
    roleRef:
      kind: Role
    subject:
      apiGroup: authentication.open-cluster-management.io
      kind: ManagedServiceAccount
      name: <managed-sa-sample>
  clusterRoleBinding:
    subject:
      apiGroup: authentication.open-cluster-management.io
      kind: ManagedServiceAccount
      name: <managed-sa-sample>
Copy to Clipboard Toggle word wrap
  1. YAML 파일을 cluster-permission.yaml 이라는 파일에 저장합니다.
  2. oc apply -f cluster-permission.yaml 을 실행합니다.
  3. 샘플 < clusterpermission >은 mortgage 네임스페이스에서 < clusterpermission-msa-subject-sample >이라는 역할을 생성합니다. 아직 없는 경우 네임스페이스 mortgage 를 생성합니다.
  4. < managed-cluster>에서 생성된 리소스를 검토합니다.

샘플 < clusterpermission> 을 생성한 후 샘플 관리 클러스터에 다음 리소스가 생성됩니다.

  • 기본 네임스페이스에서 & lt;clusterpermission-msa-subject-sample& gt;이라는 하나의 역할.
  • 역할을 관리 서비스 계정에 바인딩하기 위해 기본 네임스페이스에서 < clusterpermission-msa-subject-sample >이라는 하나의 RoleBinding 입니다.
  • mortgage 네임스페이스에서 & lt;clusterpermission-msa-subject-sample& gt;이라는 하나의 역할.
  • 역할을 관리 서비스 계정에 바인딩하기 위해 mortgage 네임스페이스에서 < clusterpermission-msa-subject-sample >이라는 하나의 RoleBinding 입니다.
  • < clusterpermission-msa-subject-sample>이라는 하나의 ClusterRole .
  • ClusterRole 을 관리 서비스 계정에 바인딩하기 위한 < clusterpermission-msa-subject-sample >이라는 ClusterRoleBinding 1개

1.7.3. 기존 역할을 사용하여 클러스터 권한 생성

ClusterPermission 리소스를 생성하면 새 역할을 자동으로 생성합니다. 기존 역할과 함께 ClusterPermission 리소스를 계속 사용할 수 있습니다.

예를 들어 다음 YAML 샘플을 적용할 때 기존 ClusterRole 을 사용하는 ClusterPermission 리소스를 생성합니다.

apiVersion: rbac.open-cluster-management.io/v1alpha1
kind: ClusterPermission
metadata:
  name: clusterpermission-existing-role-sample
spec:
  roleBindings:
    - name: default-rb-cluster1 
1

      namespace: default
      roleRef: 
2

        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: argocd-application-controller-1
      subject:
        namespace: openshift-gitops
        kind: ServiceAccount
        name: sa-sample-existing
    - name: kubevirt-rb-cluster1
      namespace: kubevirt
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: Role
        name: argocd-application-controller-2
      subject:
        apiGroup: rbac.authorization.k8s.io
        kind: User
        name: user1
  clusterRoleBinding:
      name: crb-cluster1-argo-app-con-3 
3

      roleRef: 
4

        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: argocd-application-controller-3
      subject:
        apiGroup: rbac.authorization.k8s.io
        kind: Group
        name: group1
Copy to Clipboard Toggle word wrap
1
기본 ClusterPermission 이름을 사용하는 대신 RoleBinding 필드를 생성하는 선택적 이름입니다.
2
관리 클러스터의 기존 ClusterRole 을 나타냅니다.
3
기본 ClusterPermission 이름을 사용하는 대신 ClusterRoleBinding 필드를 생성하는 선택적 이름입니다.
4
관리 클러스터의 기존 ClusterRole 을 나타냅니다.

1.7.4. 제목을 참조할 클러스터 권한 리소스 생성

다른 주제를 참조하기 위해 ClusterPermission 리소스를 생성하는 경우 한 번에 하나의 주체에서만 작업하는 대신 동시에 다른 제목으로 작업할 수 있습니다.

예를 들어 지정된 제목 필드가 있는 다음 YAML 참조하십시오.

apiVersion: rbac.open-cluster-management.io/v1alpha1
kind: ClusterPermission
metadata:
  name: clusterpermission-users-groups
spec:
  roleBindings:
    - namespace: default
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: argocd-application-controller-users-1
      subjects:
      - namespace: openshift-gitops
        kind: ServiceAccount
        name: sa-sample-existing
      - apiGroup: rbac.authorization.k8s.io
        kind: User
        name: argo-users1
    - name: kubevirt-rb-cluster1-users1
      namespace: kube-system
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: Role
        name: argocd-application-controller-users-2
      subjects:
      - apiGroup: rbac.authorization.k8s.io
        kind: User
        name: users1
      - apiGroup: rbac.authorization.k8s.io
        kind: User
        name: users2
  clusterRoleBinding:
      name: crb-cluster1-argo-app-con-groups
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: argocd-application-controller-3
      subjects:
      - apiGroup: rbac.authorization.k8s.io
        kind: Group
        name: groups1
      - apiGroup: rbac.authorization.k8s.io
        kind: Group
        name: groups2
Copy to Clipboard Toggle word wrap

1.7.5. GitOpsCluster 리소스에서 관리형 서비스 계정 사용

GitOpsCluster 리소스는 배치를 사용하여 클러스터에 액세스하는 데 사용되는 정보가 포함된 Argo CD 클러스터 시크릿 생성을 포함하여 선택한 관리 클러스터를 Argo CD로 가져옵니다. 기본적으로 Argo CD 클러스터 시크릿은 애플리케이션 관리자 서비스 계정을 사용하여 관리 클러스터에 액세스합니다.

  1. 관리 서비스 계정을 사용하도록 GitOpsCluster 리소스를 업데이트하려면 관리 서비스 계정 이름으로 ManagedServiceAccountRef 속성을 추가합니다.
  2. 다음 샘플을 gitops.yaml 파일로 저장하여 GitOpsCluster 사용자 정의 리소스를 생성합니다.

    apiVersion: apps.open-cluster-management.io/v1beta1
    kind: GitOpsCluster
    metadata:
      name: argo-acm-importer
      namespace: openshift-gitops
    spec:
      managedServiceAccountRef: <managed-sa-sample>
      argoServer:
        cluster: notused
        argoNamespace: openshift-gitops
      placementRef:
        kind: Placement
        apiVersion: cluster.open-cluster-management.io/v1beta1
        name: all-openshift-clusters
        namespace: openshift-gitops
    Copy to Clipboard Toggle word wrap
  3. oc apply -f gitops.yaml 을 실행하여 파일을 적용합니다.
  4. openshift-gitops 네임스페이스로 이동하여 <managed cluster- managed-sa-sample-cluster-secret>이라는 이름으로 새 Argo CD 클러스터 시크릿 이 있는지 확인합니다. 다음 명령을 실행합니다.

    oc get secrets -n openshift-gitops <managed cluster-managed-sa-sample-cluster-secret>
    Copy to Clipboard Toggle word wrap
  5. 다음 출력을 확인하여 확인합니다.

    NAME                                        TYPE     DATA   AGE
    <managed cluster-managed-sa-sample-cluster-secret>   Opaque   3      4m2s
    Copy to Clipboard Toggle word wrap

1.7.6. Argo CD 애플리케이션 생성

푸시 모델을 사용하여 Argo CD 콘솔에서 Argo CD 애플리케이션을 배포합니다. Argo CD 애플리케이션은 관리 서비스 계정 < managed-sa-sample>과 함께 배포됩니다.

  1. Argo CD 콘솔에 로그인합니다.
  2. 새 애플리케이션 생성을 클릭합니다.
  3. 클러스터 URL을 선택합니다.
  4. Argo CD 애플리케이션으로 이동하여 역할 및 클러스터 역할과 같이 < managed cluster>로 전파한 지정된 권한이 있는지 확인합니다.

1.7.7. 정책을 사용하여 관리 서비스 계정 및 클러스터 권한 생성

When the GitOpsCluster resource is updated with the `ManagedServiceAccountRef`, each managed cluster in the placement of this GitOpsCluster needs to have the service account. If you have several managed clusters, it becomes tedious for you to create the managed service account and cluster permission for each managed cluster. You can simply this process by using a policy to create the managed service account and cluster permission for all your managed clusters
Copy to Clipboard Toggle word wrap

ManagedServiceAccountClusterPermission 리소스를 hub 클러스터에 적용하면 이 정책의 배치가 로컬 클러스터에 바인딩됩니다. GitOpsCluster 리소스 배치에서 모든 관리 클러스터의 관리 클러스터 네임스페이스에 해당 리소스를 복제합니다.

정책을 사용하여 ManagedServiceAccountClusterPermission 리소스를 생성하려면 다음 속성이 포함됩니다.

  • 정책에서 ManagedServiceAccountClusterPermission 오브젝트 템플릿을 업데이트하면 모든 관리 클러스터에서 모든 ManagedServiceAccountClusterPermission 리소스가 업데이트됩니다.
  • ManagedServiceAccountClusterPermission 리소스로 직접 업데이트하면 정책에 의해 적용되므로 원래 상태로 되돌아갑니다.
  • GitOpsCluster 배치에 대한 배치 결정이 변경되면 정책은 관리 클러스터 네임스페이스의 리소스 생성 및 삭제를 관리합니다.

    1. YAML에서 관리 서비스 계정 및 클러스터 권한을 생성하는 정책을 생성하려면 다음 콘텐츠를 사용하여 YAML을 생성합니다.
    apiVersion: policy.open-cluster-management.io/v1
    kind: Policy
    metadata:
      name: policy-gitops
      namespace: openshift-gitops
      annotations:
        policy.open-cluster-management.io/standards: NIST-CSF
        policy.open-cluster-management.io/categories: PR.PT Protective Technology
        policy.open-cluster-management.io/controls: PR.PT-3 Least Functionality
    spec:
      remediationAction: enforce
      disabled: false
      policy-templates:
    
        - objectDefinition:
            apiVersion: policy.open-cluster-management.io/v1
            kind: ConfigurationPolicy
            metadata:
              name: policy-gitops-sub
            spec:
              pruneObjectBehavior: None
              remediationAction: enforce
              severity: low
              object-templates-raw: |
                {{ range $placedec := (lookup "cluster.open-cluster-management.io/v1beta1" "PlacementDecision" "openshift-gitops" "" "cluster.open-cluster-management.io/placement=aws-app-placement").items }}
                {{ range $clustdec := $placedec.status.decisions }}
                - complianceType: musthave
                  objectDefinition:
                    apiVersion: authentication.open-cluster-management.io/v1alpha1
                    kind: ManagedServiceAccount
                    metadata:
                      name: <managed-sa-sample>
                      namespace: {{ $clustdec.clusterName }}
                    spec:
                      rotation: {}
                - complianceType: musthave
                  objectDefinition:
                    apiVersion: rbac.open-cluster-management.io/v1alpha1
                    kind: ClusterPermission
                    metadata:
                      name: <clusterpermission-msa-subject-sample>
                      namespace: {{ $clustdec.clusterName }}
                    spec:
                      roles:
                      - namespace: default
                        rules:
                        - apiGroups: ["apps"]
                          resources: ["deployments"]
                          verbs: ["get", "list", "create", "update", "delete"]
                        - apiGroups: [""]
                          resources: ["configmaps", "secrets", "pods", "podtemplates", "persistentvolumeclaims", "persistentvolumes"]
                          verbs: ["get", "update", "list", "create", "delete"]
                        - apiGroups: ["storage.k8s.io"]
                          resources: ["*"]
                          verbs: ["list"]
                      - namespace: mortgage
                        rules:
                        - apiGroups: ["apps"]
                          resources: ["deployments"]
                          verbs: ["get", "list", "create", "update", "delete"]
                        - apiGroups: [""]
                          resources: ["configmaps", "secrets", "pods", "services", "namespace"]
                          verbs: ["get", "update", "list", "create", "delete"]
                      clusterRole:
                        rules:
                        - apiGroups: ["*"]
                          resources: ["*"]
                          verbs: ["get", "list"]
                      roleBindings:
                      - namespace: default
                        roleRef:
                          kind: Role
                        subject:
                          apiGroup: authentication.open-cluster-management.io
                          kind: ManagedServiceAccount
                          name: <managed-sa-sample>
                      - namespace: mortgage
                        roleRef:
                          kind: Role
                        subject:
                          apiGroup: authentication.open-cluster-management.io
                          kind: ManagedServiceAccount
                          name: <managed-sa-sample>
                      clusterRoleBinding:
                        subject:
                          apiGroup: authentication.open-cluster-management.io
                          kind: ManagedServiceAccount
                          name: <managed-sa-sample>
                {{ end }}
                {{ end }}
    ---
    apiVersion: policy.open-cluster-management.io/v1
    kind: PlacementBinding
    metadata:
      name: binding-policy-gitops
      namespace: openshift-gitops
    placementRef:
      name: lc-app-placement
      kind: Placement
      apiGroup: cluster.open-cluster-management.io
    subjects:
      - name: policy-gitops
        kind: Policy
        apiGroup: policy.open-cluster-management.io
    ---
    apiVersion: cluster.open-cluster-management.io/v1beta1
    kind: Placement
    metadata:
      name: lc-app-placement
      namespace: openshift-gitops
    spec:
      numberOfClusters: 1
      predicates:
      - requiredClusterSelector:
          labelSelector:
            matchLabels:
              name: <your-local-cluster-name>
    Copy to Clipboard Toggle word wrap
    1. YAML 파일을 policy.yaml 이라는 파일에 저장합니다.
    2. oc apply -f policy.yaml 을 실행합니다.
    3. 정책의 오브젝트 템플릿에서 GitOpsCluster 관련 배치 결정을 반복하고 다음 ManagedServiceAccountClusterPermission 템플릿을 적용합니다.
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

Theme

© 2025 Red Hat