다음을 통해 공유


Azure Kubernetes Fleet Manager 허브 클러스터에서 멤버 클러스터로 리소스 전파

이 문서에서는 Azure Kubernetes Fleet Manager(Kubernetes Fleet) 허브 클러스터에서 멤버 클러스터로 리소스를 전파하는 방법을 설명합니다.

필수 조건

ClusterResourcePlacement API를 사용하여 리소스를 멤버 클러스터에 전파

ClusterResourcePlacement API 개체는 허브 클러스터에 만들어지며 리소스를 멤버 클러스터에 전파하는 데 사용됩니다. 전파할 리소스와 멤버 클러스터를 선택할 때 사용할 배치 정책을 지정합니다. 이 예제에서는 배치 정책과 함께 API 개체를 사용하여 네임스페이 ClusterResourcePlacement 스를 멤버 클러스터에 전파하는 PickAll 방법을 보여 줍니다.

자세한 내용은 허브 클러스터에서 멤버 클러스터로 Kubernetes 리소스 배치 및 오픈 소스 Kubernetes Fleet 설명서를 참조하세요.

  1. 명령을 사용하여 멤버 클러스터에 배치할 네임스페이스를 만듭니다 kubectl create namespace . 다음 예에서는 my-namespace라는 네임스페이스를 만듭니다.

    kubectl create namespace my-namespace
    
  2. ClusterResourcePlacement 허브 클러스터에 API 개체를 만들어 네임스페이스를 멤버 클러스터로 전파하고 명령을 사용하여 kubectl apply -f 배포합니다. 다음 예제 ClusterResourcePlacement 에서는 명명된 crp 개체를 만들고 배치 정책과 함께 PickAll 네임스페이스를 사용하여 my-namespace 네임스페이스를 모든 멤버 클러스터에 전파합니다.

    kubectl apply -f - <<EOF
    apiVersion: placement.kubernetes-fleet.io/v1
    kind: ClusterResourcePlacement
    metadata:
      name: crp
    spec:
      resourceSelectors:
        - group: ""
          kind: Namespace
          version: v1          
          name: my-namespace
      policy:
        placementType: PickAll
    EOF
    
  3. 명령을 사용하여 리소스 전파 진행률을 확인합니다 kubectl get clusterresourceplacement . 다음 예에서는 crp라는 ClusterResourcePlacement 개체의 상태를 확인합니다.

    kubectl get clusterresourceplacement crp
    

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

    NAME   GEN   SCHEDULED   SCHEDULEDGEN   APPLIED   APPLIEDGEN   AGE
    crp    2     True        2              True      2            10s
    
  4. 명령을 사용하여 개체의 crp 세부 정보를 봅니다 kubectl describe crp . 다음 예에서는 crp라는 ClusterResourcePlacement 개체를 설명합니다.

    kubectl describe clusterresourceplacement crp
    

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

    Name:         crp
    Namespace:    
    Labels:       <none>
    Annotations:  <none>
    API Version:  placement.kubernetes-fleet.io/v1
    Kind:         ClusterResourcePlacement
    Metadata:
      Creation Timestamp:  2024-04-01T18:55:31Z
      Finalizers:
        kubernetes-fleet.io/crp-cleanup
        kubernetes-fleet.io/scheduler-cleanup
      Generation:        2
      Resource Version:  6949
      UID:               815b1d81-61ae-4fb1-a2b1-06794be3f986
    Spec:
      Policy:
        Placement Type:  PickAll
      Resource Selectors:
        Group:                 
        Kind:                  Namespace
        Name:                  my-namespace
        Version:               v1
      Revision History Limit:  10
      Strategy:
        Type:  RollingUpdate
    Status:
      Conditions:
        Last Transition Time:   2024-04-01T18:55:31Z
        Message:                found all the clusters needed as specified by the scheduling policy
        Observed Generation:    2
        Reason:                 SchedulingPolicyFulfilled
        Status:                 True
        Type:                   ClusterResourcePlacementScheduled
        Last Transition Time:   2024-04-01T18:55:36Z
        Message:                All 3 cluster(s) are synchronized to the latest resources on the hub cluster
        Observed Generation:    2
        Reason:                 SynchronizeSucceeded
        Status:                 True
        Type:                   ClusterResourcePlacementSynchronized
        Last Transition Time:   2024-04-01T18:55:36Z
        Message:                Successfully applied resources to 3 member clusters
        Observed Generation:    2
        Reason:                 ApplySucceeded
        Status:                 True
        Type:                   ClusterResourcePlacementApplied
      Observed Resource Index:  0
      Placement Statuses:
        Cluster Name:  membercluster1
        Conditions:
          Last Transition Time:  2024-04-01T18:55:31Z
          Message:               Successfully scheduled resources for placement in membercluster1 (affinity score: 0, topology spread score: 0): picked by scheduling policy
          Observed Generation:   2
          Reason:                ScheduleSucceeded
          Status:                True
          Type:                  ResourceScheduled
          Last Transition Time:  2024-04-01T18:55:36Z
          Message:               Successfully Synchronized work(s) for placement
          Observed Generation:   2
          Reason:                WorkSynchronizeSucceeded
          Status:                True
          Type:                  WorkSynchronized
          Last Transition Time:  2024-04-01T18:55:36Z
          Message:               Successfully applied resources
          Observed Generation:   2
          Reason:                ApplySucceeded
          Status:                True
          Type:                  ResourceApplied
        Cluster Name:            membercluster2
        Conditions:
          Last Transition Time:  2024-04-01T18:55:31Z
          Message:               Successfully scheduled resources for placement in membercluster2 (affinity score: 0, topology spread score: 0): picked by scheduling policy
          Observed Generation:   2
          Reason:                ScheduleSucceeded
          Status:                True
          Type:                  ResourceScheduled
          Last Transition Time:  2024-04-01T18:55:36Z
          Message:               Successfully Synchronized work(s) for placement
          Observed Generation:   2
          Reason:                WorkSynchronizeSucceeded
          Status:                True
          Type:                  WorkSynchronized
          Last Transition Time:  2024-04-01T18:55:36Z
          Message:               Successfully applied resources
          Observed Generation:   2
          Reason:                ApplySucceeded
          Status:                True
          Type:                  ResourceApplied
        Cluster Name:            membercluster3
        Conditions:
          Last Transition Time:  2024-04-01T18:55:31Z
          Message:               Successfully scheduled resources for placement in membercluster3 (affinity score: 0, topology spread score: 0): picked by scheduling policy
          Observed Generation:   2
          Reason:                ScheduleSucceeded
          Status:                True
          Type:                  ResourceScheduled
          Last Transition Time:  2024-04-01T18:55:36Z
          Message:               Successfully Synchronized work(s) for placement
          Observed Generation:   2
          Reason:                WorkSynchronizeSucceeded
          Status:                True
          Type:                  WorkSynchronized
          Last Transition Time:  2024-04-01T18:55:36Z
          Message:               Successfully applied resources
          Observed Generation:   2
          Reason:                ApplySucceeded
          Status:                True
          Type:                  ResourceApplied
      Selected Resources:
        Kind:     Namespace
        Name:     my-namespace
        Version:  v1
    Events:
      Type    Reason                     Age   From                                   Message
      ----    ------                     ----  ----                                   -------
      Normal  PlacementScheduleSuccess   108s  cluster-resource-placement-controller  Successfully scheduled the placement
      Normal  PlacementSyncSuccess       103s  cluster-resource-placement-controller  Successfully synchronized the placement
      Normal  PlacementRolloutCompleted  103s  cluster-resource-placement-controller  Resources have been applied to the selected clusters
    

리소스 정리

더 이상 개체를 사용하지 ClusterResourcePlacement 않으려면 명령을 사용하여 삭제할 kubectl delete 수 있습니다. 다음 예에서는 crp라는 ClusterResourcePlacement 개체를 삭제합니다.

kubectl delete clusterresourceplacement crp

리소스 전파에 대해 자세히 알아보려면 다음 리소스를 참조하세요.