다음을 통해 공유


Azure Kubernetes Fleet Manager ResourcePlacement를 사용하여 여러 클러스터에 네임스페이스 범위 리소스 배포(미리 보기)

이 문서에서는 Azure Kubernetes Fleet Manager ResourcePlacement 를 사용하여 플릿의 클러스터에 네임스페이스 범위 리소스를 배포하는 방법을 설명합니다.

중요합니다

Azure Kubernetes Fleet Manager 미리 보기 기능은 셀프 서비스, 옵트인 기반으로 제공됩니다. 미리 보기는 "있는 그대로" 및 "사용 가능한 상태로" 제공되며 서비스 수준 계약 및 제한적 보증에서 제외됩니다. Azure Kubernetes Fleet Manager 미리 보기의 일부는 고객 지원팀에서 최선을 다해 지원합니다. 따라서 이러한 기능은 프로덕션 용도로 사용할 수 없습니다.

필수 조건

멤버 클러스터에서 네임스페이스 설정

네임스페이스 범위 리소스를 배포하는 데 사용 ResourcePlacement 하려면 먼저 대상 네임스페이스가 멤버 클러스터에 있어야 합니다. 이 예제에서는 허브 클러스터에 네임스페이스를 만들고 를 사용하여 ClusterResourcePlacement멤버 클러스터에 전파하는 방법을 보여 줍니다.

비고

다음 예제에서는 API 버전을 사용합니다 placement.kubernetes-fleet.io/v1beta1 . 이 selectionScope: NamespaceOnly 필드는 v1beta1에서 사용할 수 있는 미리 보기 기능이며 안정적인 v1 API에서는 사용할 수 없습니다.

  1. 허브 클러스터에 네임스페이스를 만듭니다.

    kubectl create namespace my-app
    
  2. ClusterResourcePlacement 모든 멤버 클러스터에 네임스페이스를 전파하는 개체를 만듭니다. 다음 YAML을 이름이 지정된 namespace-crp.yaml파일에 저장합니다.

    apiVersion: placement.kubernetes-fleet.io/v1beta1
    kind: ClusterResourcePlacement
    metadata:
      name: my-app-namespace
    spec:
      resourceSelectors:
        - group: ""
          kind: Namespace
          name: my-app
          version: v1
          selectionScope: NamespaceOnly
      policy:
        placementType: PickAll
    
  3. ClusterResourcePlacement 허브 클러스터에 적용합니다.

    kubectl apply -f namespace-crp.yaml
    
  4. 네임스페이스가 성공적으로 전파되었는지 확인합니다.

    kubectl get clusterresourceplacement my-app-namespace
    

    출력은 다음 예제와 비슷하게 표시됩니다.

    NAME                GEN   SCHEDULED   SCHEDULED-GEN   AVAILABLE   AVAILABLE-GEN   AGE
    my-app-namespace    1     True        1               True        1               15s
    

ResourcePlacement를 사용하여 네임스페이스 범위 리소스 배치

개체는 ResourcePlacement 허브 클러스터의 네임스페이스 내에서 만들어지고 특정 네임스페이스 범위 리소스를 멤버 클러스터에 전파하는 데 사용됩니다. 이 예제에서는 배치 정책이 있는 개체를 사용하여 ConfigMaps를 특정 멤버 클러스터에 전파하는 ResourcePlacementPickFixed 방법을 보여 줍니다.

자세한 내용은 Azure Kubernetes Fleet Manager ResourcePlacement를 사용하여 네임스페이스 범위 리소스 배치를 참조하세요.

  1. 허브 클러스터의 네임스페이스에 ConfigMaps를 만듭니다. 이러한 ConfigMaps는 선택한 멤버 클러스터로 전파됩니다.

    kubectl create configmap app-config \
      --from-literal=environment=production \
      --from-literal=log-level=info \
      -n my-app
    
    kubectl create configmap feature-flags \
      --from-literal=new-ui=enabled \
      --from-literal=api-v2=disabled \
      -n my-app
    
  2. ResourcePlacement ConfigMaps를 전파하는 개체를 만듭니다. 다음 YAML을 이름이 지정된 app-configs-rp.yaml파일에 저장합니다.

    apiVersion: placement.kubernetes-fleet.io/v1beta1
    kind: ResourcePlacement
    metadata:
      name: app-configs
      namespace: my-app
    spec:
      resourceSelectors:
        - group: ""
          kind: ConfigMap
          version: v1
          name: app-config
        - group: ""
          kind: ConfigMap
          version: v1
          name: feature-flags
      policy:
        placementType: PickFixed
        clusterNames:
          - membercluster1
          - membercluster2
    

    비고

    membercluster1membercluster2를 멤버 클러스터의 실제 이름으로 바꾸십시오. 를 사용하여 kubectl get memberclusters사용 가능한 멤버 클러스터를 나열할 수 있습니다.

  3. ResourcePlacement 허브 클러스터에 적용합니다.

    kubectl apply -f app-configs-rp.yaml
    
  4. 리소스 전파 진행률을 확인합니다.

    kubectl get resourceplacement app-configs -n my-app
    

    출력은 다음 예제와 비슷하게 표시됩니다.

    NAME          GEN   SCHEDULED   SCHEDULED-GEN   AVAILABLE   AVAILABLE-GEN   AGE
    app-configs   1     True        1               True        1               20s
    
  5. 배치 개체의 세부 정보를 봅니다.

    kubectl describe resourceplacement app-configs -n my-app
    

    출력은 다음 예제와 비슷하게 표시됩니다.

    Name:         app-configs
    Namespace:    my-app
    Labels:       <none>
    Annotations:  <none>
    API Version:  placement.kubernetes-fleet.io/v1beta1
    Kind:         ResourcePlacement
    Metadata:
      Creation Timestamp:  2025-11-13T22:08:12Z
      Finalizers:
        kubernetes-fleet.io/crp-cleanup
        kubernetes-fleet.io/scheduler-cleanup
      Generation:        1
      Resource Version:  12345
      UID:               cec941f1-e48a-4045-b5dd-188bfc1a830f
    Spec:
      Policy:
        Cluster Names:
          membercluster1
          membercluster2
        Placement Type:  PickFixed
      Resource Selectors:
        Group:                 
        Kind:                  ConfigMap
        Name:                  app-config
        Version:               v1
        Group:                 
        Kind:                  ConfigMap
        Name:                  feature-flags
        Version:               v1
      Revision History Limit:  10
      Strategy:
        Type:  RollingUpdate
    Status:
      Conditions:
        Last Transition Time:   2025-11-13T22:08:12Z
        Message:                found all cluster needed as specified by the scheduling policy, found 2 cluster(s)
        Observed Generation:    1
        Reason:                 SchedulingPolicyFulfilled
        Status:                 True
        Type:                   ResourcePlacementScheduled
        Last Transition Time:   2025-11-13T22:08:12Z
        Message:                All 2 cluster(s) start rolling out the latest resource
        Observed Generation:    1
        Reason:                 RolloutStarted
        Status:                 True
        Type:                   ResourcePlacementRolloutStarted
        Last Transition Time:   2025-11-13T22:08:13Z
        Message:                No override rules are configured for the selected resources
        Observed Generation:    1
        Reason:                 NoOverrideSpecified
        Status:                 True
        Type:                   ResourcePlacementOverridden
        Last Transition Time:   2025-11-13T22:08:13Z
        Message:                Works(s) are succcesfully created or updated in 2 target cluster(s)' namespaces
        Observed Generation:    1
        Reason:                 WorkSynchronized
        Status:                 True
        Type:                   ResourcePlacementWorkSynchronized
        Last Transition Time:   2025-11-13T22:08:13Z
        Message:                The selected resources are successfully applied to 2 cluster(s)
        Observed Generation:    1
        Reason:                 ApplySucceeded
        Status:                 True
        Type:                   ResourcePlacementApplied
        Last Transition Time:   2025-11-13T22:08:13Z
        Message:                The selected resources in 2 cluster(s) are available now
        Observed Generation:    1
        Reason:                 ResourceAvailable
        Status:                 True
        Type:                   ResourcePlacementAvailable
      Observed Resource Index:  0
      Placement Statuses:
        Cluster Name:  membercluster1
        Conditions:
          Last Transition Time:   2025-11-13T22:08:12Z
          Message:                Successfully scheduled resources for placement in "membercluster1": picked by scheduling policy
          Observed Generation:    1
          Reason:                 Scheduled
          Status:                 True
          Type:                   Scheduled
          Last Transition Time:   2025-11-13T22:08:12Z
          Message:                Detected the new changes on the resources and started the rollout process
          Observed Generation:    1
          Reason:                 RolloutStarted
          Status:                 True
          Type:                   RolloutStarted
          Last Transition Time:   2025-11-13T22:08:13Z
          Message:                No override rules are configured for the selected resources
          Observed Generation:    1
          Reason:                 NoOverrideSpecified
          Status:                 True
          Type:                   Overridden
          Last Transition Time:   2025-11-13T22:08:13Z
          Message:                All of the works are synchronized to the latest
          Observed Generation:    1
          Reason:                 AllWorkSynced
          Status:                 True
          Type:                   WorkSynchronized
          Last Transition Time:   2025-11-13T22:08:13Z
          Message:                All corresponding work objects are applied
          Observed Generation:    1
          Reason:                 AllWorkHaveBeenApplied
          Status:                 True
          Type:                   Applied
          Last Transition Time:   2025-11-13T22:08:13Z
          Message:                All corresponding work objects are available
          Observed Generation:    1
          Reason:                 AllWorkAreAvailable
          Status:                 True
          Type:                   Available
        Observed Resource Index:  0
        Cluster Name:             membercluster2
        Conditions:
          Last Transition Time:   2025-11-13T22:08:12Z
          Message:                Successfully scheduled resources for placement in "membercluster2": picked by scheduling policy
          Observed Generation:    1
          Reason:                 Scheduled
          Status:                 True
          Type:                   Scheduled
          Last Transition Time:   2025-11-13T22:08:12Z
          Message:                Detected the new changes on the resources and started the rollout process
          Observed Generation:    1
          Reason:                 RolloutStarted
          Status:                 True
          Type:                   RolloutStarted
          Last Transition Time:   2025-11-13T22:08:13Z
          Message:                No override rules are configured for the selected resources
          Observed Generation:    1
          Reason:                 NoOverrideSpecified
          Status:                 True
          Type:                   Overridden
          Last Transition Time:   2025-11-13T22:08:13Z
          Message:                All of the works are synchronized to the latest
          Observed Generation:    1
          Reason:                 AllWorkSynced
          Status:                 True
          Type:                   WorkSynchronized
          Last Transition Time:   2025-11-13T22:08:13Z
          Message:                All corresponding work objects are applied
          Observed Generation:    1
          Reason:                 AllWorkHaveBeenApplied
          Status:                 True
          Type:                   Applied
          Last Transition Time:   2025-11-13T22:08:13Z
          Message:                All corresponding work objects are available
          Observed Generation:    1
          Reason:                 AllWorkAreAvailable
          Status:                 True
          Type:                   Available
        Observed Resource Index:  0
      Selected Resources:
        Kind:       ConfigMap
        Name:       app-config
        Namespace:  my-app
        Version:    v1
        Kind:       ConfigMap
        Name:       feature-flags
        Namespace:  my-app
        Version:    v1
    Events:
      Type    Reason                     Age   From                            Message
      ----    ------                     ----  ----                            -------
      Normal  PlacementRolloutStarted       37s   placement-controller  Started rolling out the latest resources
      Normal  PlacementOverriddenSucceeded  36s   placement-controller  Placement has been successfully overridden
      Normal  PlacementWorkSynchronized     36s   placement-controller  Work(s) have been created or updated successfully for the selected cluster(s)
      Normal  PlacementApplied              36s   placement-controller  Resources have been applied to the selected cluster(s)
      Normal  PlacementAvailable            36s   placement-controller  Resources are available on the selected cluster(s)
      Normal  PlacementRolloutCompleted     36s   placement-controller  Placement has finished the rollout process and reached the desired status
    

멤버 클러스터에서 리소스 확인

ConfigMaps가 멤버 클러스터에 성공적으로 전파되었는지 확인할 수 있습니다.

  1. 멤버 클러스터 중 하나에 대한 자격 증명을 가져옵니다.

    az aks get-credentials --resource-group <resource-group> --name membercluster1
    
  2. 네임스페이스가 있는지 확인합니다.

    kubectl get namespace my-app
    
  3. ConfigMaps가 네임스페이스에 있는지 확인합니다.

    kubectl get configmap -n my-app
    

    출력에 ConfigMaps 두 개가 모두 표시됩니다.

    NAME             DATA   AGE
    app-config       2      2m
    feature-flags    2      2m
    
  4. ConfigMap의 내용을 봅니다.

    kubectl describe configmap app-config -n my-app
    

자원을 정리하세요

더 이상 ResourcePlacement 개체를 사용하지 않으려면 kubectl delete 명령을 사용하여 개체를 삭제할 수 있습니다.

kubectl delete resourceplacement app-configs -n my-app

네임스페이스 ClusterResourcePlacement도 제거하려면:

kubectl delete clusterresourceplacement my-app-namespace

허브 클러스터에서 네임스페이스 및 네임스페이스 내의 모든 리소스를 제거하려면 다음을 수행합니다.

kubectl delete namespace my-app

네임스페이스 범위 리소스 배치에 대한 자세한 내용은 다음 리소스를 참조하세요.