Edit

Define reusable Azure Kubernetes Fleet Manager resource placement rollout strategies

Applies to: ✔️ Fleet Manager with hub cluster

Platform administrators can control how Azure Kubernetes Fleet Manager rolls out resource placement updates to Fleet-managed clusters by defining staged update strategies made up of stages and groups. Within each stage and group, they can configure approvals and timed pauses to enforce governance and reduce rollout risk. Because the strategy is defined as a reusable resource, you can manage it independently from individual update runs and apply it consistently across different placements.

This article explains how to create and manage Azure Kubernetes Fleet Manager resource placement staged update strategies by using groups and stages.

You can complete the steps in this article using either the Azure portal or the Azure CLI.

Note

You can use Fleet Manager's resource placement with AKS and Azure Arc-enabled Kubernetes clusters.

Before you begin

Create a staged update strategy

For this article, create a cluster-scoped rollout strategy that consists of two stages - staging and canary. There's a one-hour wait time after the staging stage, with a before-stage approval for canary.

Creating namespace-scoped strategies (StagedUpdateStrategy) for use with namespace-scope placement (ResourcePlacement) is a similar experience, except you must select the hub cluster namespace from which the staged resources are distributed.

  1. Set the following environment variables for your subscription ID, resource group, and Kubernetes Fleet resource:

    export SUBSCRIPTION_ID=<subscription-id>
    export GROUP=<resource-group-name>
    export FLEET=<fleet-name>
    
  2. Set the default Azure subscription by using the az account set command:

    az account set \
        --subscription ${SUBSCRIPTION_ID}
    
  3. Get the kubeconfig file of the Kubernetes Fleet hub cluster by using the az fleet get-credentials command:

    az fleet get-credentials \
        --resource-group ${GROUP} \
        --name ${FLEET}
    

    Your output should look similar to the following.

    Merged "hub" as current context in /home/fleet/.kube/config
    

    Note

    If you receive an error of type InvalidHubOperation with the message indicating the fleet is hubless, add a hub cluster. For further information, see upgrade hub cluster type.

  4. Save the following YAML as crp-two-stages-strategy.yaml.

    apiVersion: placement.kubernetes-fleet.io/v1
    kind: ClusterStagedUpdateStrategy
    metadata:
      name: two-stages-strategy
    spec:
      stages:
        - name: staging
          labelSelector:
            matchLabels:
              environment: staging
          afterStageTasks:
            - type: TimedWait
              waitTime: 1h
        - name: canary
          labelSelector:
            matchLabels:
              environment: canary
          beforeStageTasks:
            - type: Approval
    
  5. Apply the placement manifest to the Fleet Manager hub cluster.

    kubectl apply -f crp-two-stages-strategy.yaml
    
  6. Check the status of the strategy resource.

    kubectl get clusterstagedupdatestrategy two-stages-strategy
    

    Your output should look similar to the following.

    NAME                  AGE
    two-stages-strategy   47m
    
  1. In the Azure portal, go to your Fleet Manager.

  2. On the service menu, under Fleet Resources, select Resource placements > Staged rollout strategies, and then select Create.

    Note

    If you don't see Fleet Resources, your Fleet Manager doesn't have a hub cluster. For further information on how to add one, see upgrade hub cluster type.

  3. Enter a name for the strategy.

  4. Select the Strategy scope, choosing either Cluster-scoped or Namespace-scoped.

    • For Namespace-scoped, select the existing Namespace on the Fleet Manager hub cluster where the Kubernetes resources to distribute are staged.
  5. Select Create Stage and enter:

    • Stage name - name the stage - it must be unique across all stage names in the strategy.
    • (Optional) Stage approvals - select this option if you want to wait for an approval before this stage starts or after it completes.
    • (Optional) Wait after stage - select this option if you want to define a pause before moving to the next stage.
    • (Optional) Wait duration - select a predefined duration, or enter a custom value in seconds.
    • Cluster label selector - choose an existing member cluster label to use to select clusters for this stage.
    • (Optional) Cluster ordering label - choose an existing member cluster label to use to order the clusters within the stage.
    • (Optional) Stage concurrency - set how many clusters should be updated concurrently in the current stage.

    A screenshot of the Azure portal showing a new stage being added to an Azure Kubernetes Fleet Manager placement staged rollout strategy.

    Note

    The maximum number of stages in each strategy is 31.

  6. Repeat until you add all stages to the strategy. Select Create to create the strategy.

    A screenshot of the Azure portal showing an Azure Kubernetes Fleet Manager placement staged rollout strategy with two stages that is pending creation.

  7. The page refreshes and the list displays the newly created strategy.

    A screenshot of the Azure portal showing a list of Azure Kubernetes Fleet Manager placement staged rollout strategies.

Next steps

In this article, you learned how to define reusable staged rollout strategies for Azure Kubernetes Fleet Manager resource placement. You configured strategy scope, created rollout stages, and added stage controls such as approvals, wait times, label selectors, ordering labels, and concurrency settings.

To learn more about controlling resource rollouts and related concepts, see the following resources: