Uninstalling Anthos Config Management

This page is for platform administrators.

This page describes how to uninstall Anthos Config Management from a cluster.

Unbinding Anthos Config Management from the cluster

  1. Find the ConfigManagementBinding resource that refers to the target cluster:

    KUBECONFIG=ADMIN_KUBECONFIG kubectl get configmanagementbinding \
      -n anthos-management-center \
      -o=custom-columns="NAME:.metadata.name,cluster:.spec.configs[*].placement.clusterIDs[*]"| grep TARGET_CLUSTER_ID.
    

    Replace the following:

    • ADMIN_KUBECONFIG with the path of the admin kubeconfig file.
    • TARGET_CLUSTER_ID with the name of the cluster to uninstall Anthos Config Management from.

    The output lists the name of the ConfigManagementBinding resource.

  2. Query the ConfigManagementBinding resource by its name:

    KUBECONFIG=${ADMIN_KUBECONFIG} kubectl get configmanagementbinding \
      CONFIG_MANAGEMENT_BINDING_NAME -n anthos-management-center \
      -o yaml
    

    Replace CONFIG_MANAGEMENT_BINDING_NAME with the resource name you found in the previous step.

    The output is the configuration of the ConfigManagementBinding resource. The configuration is like this:

    apiVersion: managementcenter.anthos.cloud.google.com/v1
    kind: ConfigManagementBinding
    metadata:
      name: CONFIG_MANAGEMENT_BINDING_NAME
      namespace: anthos-management-center
    spec:
      configs:
      - configRef:
          name: CONFIG_MANAGEMENT_FEATURE_SPEC_NAME
          namespace: anthos-management-center
        placement:
          clusterIDs:
          - TARGET_CLUSTER_ID
          - cluster-1
      - configRef:
          name: feature-spec-2
          namespace: anthos-management-center
        placement:
          clusterIDs:
          - cluster-2
    status:
      ...
    
  3. Use kubectl edit to edit the configuration from the previous step to remove the binding for the target cluster:

    KUBECONFIG=${ADMIN_KUBECONFIG} kubectl edit configmanagementbinding/CONFIG_MANAGEMENT_BINDING_NAME -n anthos-management-center
    

    Remove the target cluster from the spec.configs[0].placement.clusterIDs. The following example shows how to edit the example output from the previous step:

    apiVersion: managementcenter.anthos.cloud.google.com/v1
    kind: ConfigManagementBinding
    metadata:
      name: CONFIG_MANAGEMENT_BINDING_NAME
      namespace: anthos-management-center
    spec:
      configs:
      - configRef:
          name: CONFIG_MANAGEMENT_FEATURE_SPEC_NAME
          namespace: anthos-management-center
        placement:
          clusterIDs:
          - cluster-1
      - configRef:
          name: feature-spec-2
          namespace: anthos-management-center
        placement:
          clusterIDs:
          - cluster-2
    

    Replace CONFIG_MANAGEMENT_FEATURE_SPEC_NAME with the value output in the previous step.

  4. Check the status field of the ConfigManagementBinding resource:

    KUBECONFIG=${ADMIN_KUBECONFIG} kubectl get configmanagementbinding \
      CONFIG_MANAGEMENT_BINDING_NAME -n anthos-management-center \
      -o yaml
    

    During uninstallation, the status field in the output shows Uninstalling ACM for the target cluster:

    apiVersion: managementcenter.anthos.cloud.google.com/v1
    kind: ConfigManagementBinding
    metadata:
      name: CONFIG_MANAGEMENT_BINDING_NAME
      namespace: anthos-management-center
    …
    status:
      bindingItemStatuses:
      - clusterID: TARGET_CLUSTER_ID
        conditions:
        - lastTransitionTime: "2021-06-15T16:20:52Z"
          message: Uninstalling ACM
          observedGeneration: 2
          reason: Uninstalling
          status: "False"
          type: Ready
    

    When the status for the target cluster disappears from the ConfigManagementBinding status, the uninstall is completed.

Deleting the ConfigManagementFeatureSpec resource (optional)

If the ConfigManagementFeatureSpec resource is not bound with any other cluster, you can delete it:

KUBECONFIG=${ADMIN_KUBECONFIG} kubectl delete configmanagementfeaturespec CONFIG_MANAGEMENT_FEATURE_SPEC_NAME -n anthos-management-center