View Config Sync status with the gcloud CLI

This page explains how to use Google Cloud CLI commands to monitor Config Sync:

  • Use gcloud alpha anthos config sync repo to list the status of your repositories across multiple clusters.

  • Use gcloud alpha anthos config sync resources to view the resources that Config Sync manages.

You can also view similar information in the Config Sync dashboard.

Before you begin

Before using the commands on this page, complete the following steps:

  1. Update the Google Cloud CLI components:

    gcloud components update
    
  2. Register your clusters if you haven't. If you installed and configured Config Sync through the Google Cloud console, you can skip this step.

  3. If your cluster isn't a GKE cluster, the platform administrators need to set up Connect Gateway for the registered cluster.

  4. Set your project:

    gcloud config set project PROJECT_ID
    

    Replace PROJECT_ID with the project ID in which Config Sync is set up and running.

View Config Sync status across multiple clusters

If you install and configure Config Sync on multiple registered clusters in a project, you can use gcloud alpha anthos config sync repo to list the status for the repository being synced across clusters and debug problems with Config Sync.

Compared with nomos status, gcloud alpha anthos config sync repo groups status by repository whereas the nomos status command groups status by cluster.

List all repositories

To list all the status of Git repositories that are synced to any registered clusters in the current project, run the following command:

gcloud alpha anthos config sync repo list

The output is similar to the following:

┌─────────────────────────────────────────────────────────────────┬───────┬────────┬─────────┬───────┬─────────┬─────────────┐
                       SOURCE                                     TOTAL  SYNCED  PENDING  ERROR  STALLED  RECONCILING 
├─────────────────────────────────────────────────────────────────┼───────┼────────┼─────────┼───────┼─────────┼─────────────┤
 https://source.developers.google.com/p/test/r/test//@main        2      2       0        0      0        0           
 https://source.developers.google.com/p/test/r/dev//@main         2      1       0        0      1        0           
 https://source.developers.google.com/p/test/r/staging//@main     1      0       0        1      0        0           
└─────────────────────────────────────────────────────────────────┴───────┴────────┴─────────┴───────┴─────────┴─────────────┘

For each repository, you can see the corresponding status across clusters:

  • TOTAL is the number of clusters the repository is synced to.
  • SYNCED is the number of clusters where this repository is synced successfully.
  • PENDING is the number of clusters where this repository is pending to sync.
  • ERROR is the number of clusters where this repository encounters some error during syncing.
  • STALLED is the number of clusters where the Deployment that syncs this repository is stalled.
  • RECONCILING is the number of clusters where the Deployment that syncs this repository is being reconciled.

List repositories with a specific status

You can also list the repositories with a specific status using the flag --status. The supported values are synced, pending, error, stalled, and reconciling.

For example, list the repositories that have errors by running the following command:

gcloud alpha anthos config sync repo list --status=error

The output is similar to the following:

┌─────────────────────────────────────────────────────────────────┬───────┬────────┬─────────┬───────┬─────────┬─────────────┐
                       SOURCE                                     TOTAL  SYNCED  PENDING  ERROR  STALLED  RECONCILING 
├─────────────────────────────────────────────────────────────────┼───────┼────────┼─────────┼───────┼─────────┼─────────────┤
 https://source.developers.google.com/p/test/r/staging//@main     1      0       0        1      0        0           
└─────────────────────────────────────────────────────────────────┴───────┴────────┴─────────┴───────┴─────────┴─────────────┘

Describe a repository

Use the describe command to see details about your repository's status:

   gcloud alpha anthos config sync repo describe \
     --source URL

Replace URL with a URL from the output of the repo list command described in the preceding section.

You can also use --namespace and --name to specify the repository you want to describe.

   gcloud alpha anthos config sync repo describe \
     --sync-namespace config-management-system --sync-name root-sync

By default, the command prints the repository status as well as any managed resources that are applied but failed reconciliation. For example:

   [
     {
       "clusters": [
         "cluster-1",
         "cluster-2",
       ],
       "commit": "32293c90a63efba3121c7648048fcd3e85043a34",
       "errors": [],
       "source": "https://source.developers.google.com/p/test/r/test//@main",
       "status": "SYNCED"
     }
   ]

You can also use the flag --managed-resources to control the managed resources that you want to view. The supported values are all, current, inprogress, notfound, failed (the default) or unknown. You can use the following command to view all managed resources:

   gcloud alpha anthos config sync repo describe \
     --namespace config-management-system --name root-sync \
     --managed-resources all

The output is similar to the following:

   [
     {
       "clusters": [
         "cluster-1",
         "cluster-2",
       ],
       "commit": "32293c90a63efba3121c7648048fcd3e85043a34",
       "errors": [],
       "source": "https://source.developers.google.com/p/test/r/test//@main",
       "status": "SYNCED"
     }
   ]
   ┌────────────────────────────────────────────────────────────────┐
                          managed_resources                        
   ├───────┬───────────┬─────────┬───────────┬─────────┬────────────┤
    GROUP     KIND      NAME   NAMESPACE   STATUS  CONDITIONS 
   ├───────┼───────────┼─────────┼───────────┼─────────┼────────────┤
           Namespace  default             Current             
           ConfigMap  foo      default    Current             
   └───────┴───────────┴─────────┴───────────┴─────────┴────────────┘

View Config Sync managed resources

You can use gcloud alpha anthos config sync resources to filter the managed resources by cluster, group, kind, namespace, name, status, or a combination of these attributes.

List all managed resources

   gcloud alpha anthos config sync resources list

This command lists all the managed resources that are synced to any registered clusters in the current project. The output is similar to the following:

┌───────────────────┬───────────────────────────┬──────────────────────────┬──────────────────┬───────────────────────────────────────────┬─────────┬───────────┐
│    CLUSTER_NAME   │           GROUP           │           KIND           │    NAMESPACE     │                    NAME                   │  STATUS │ CONDITION │
├───────────────────┼───────────────────────────┼──────────────────────────┼──────────────────┼───────────────────────────────────────────┼─────────┼───────────┤
│ cluster-1         │                           │ Namespace                │                  │ default                                   │ Current │           │
│ cluster-1         │ rbac.authorization.k8s.io │ RoleBinding              │ default          │ viewers                                   │ Current │           │
│ cluster-2         │                           │ Namespace                │                  │ gamestore                                 │ Current │           │
│ cluster-2         │ rbac.authorization.k8s.io │ RoleBinding              │ gamestore        │ gamestore-admin                           │ Current │           │
│ cluster-2         │ rbac.authorization.k8s.io │ RoleBinding              │ gamestore        │ gamestore-webstore-admin                  │ Current │           │
└───────────────────┴───────────────────────────┴──────────────────────────┴──────────────────┴───────────────────────────────────────────┴─────────┴───────────┘

Each row of the output describes the managed resource and its corresponding status:

  • CLUSTER_NAME is the name of the cluster the managed resource is from.
  • GROUP is the group attribute of the managed resource.
  • KIND is the kind attribute of the managed resource.
  • NAMESPACE is the namespace of the managed resource.
  • NAME is the name of the managed resource.
  • STATUS is the reconciliation status of the managed resource. You can find the list of possible statuses in the Kubernetes Sig documentation.
  • CONDITION is the message explaining the status of the managed resource.

List managed resource from a single cluster

You can view managed resources per cluster by using a gcloud command or by viewing it in the Google Cloud console.

You can list the managed resources from a specific cluster using the flag --cluster. For example, list the managed resources from the cluster with name cluster-1 with the following command:

gcloud alpha anthos config sync resources list --cluster=cluster-1

The output is similar to the following:

┌───────────────────┬───────────────────────────┬──────────────────────────┬──────────────────┬───────────────────────────────────────────┬─────────┬───────────┐
│    CLUSTER_NAME   │           GROUP           │           KIND           │    NAMESPACE     │                    NAME                   │  STATUS │ CONDITION │
├───────────────────┼───────────────────────────┼──────────────────────────┼──────────────────┼───────────────────────────────────────────┼─────────┼───────────┤
│ cluster-1         │                           │ Namespace                │                  │ default                                   │ Current │           │
│ cluster-1         │ rbac.authorization.k8s.io │ RoleBinding              │ default          │ viewers                                   │ Current │           │
└───────────────────┴───────────────────────────┴──────────────────────────┴──────────────────┴───────────────────────────────────────────┴─────────┴───────────┘

What's next