Quickstart: Sync configs from a repository

In this tutorial, you create a Google Kubernetes Engine (GKE) Enterprise edition cluster and use Config Sync to sync to configs in the multi-repo samples repository.

Imagine that your compliance team is responsible for making sure that everyone in your organization is following internal rules. To enforce these rules, the compliance team has created configs, which they have added to the samples repository. Each cluster in your organization is required to sync to the repository and you are responsible for creating and syncing clusters.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Make sure that you have the following role or roles on the project: GKE Hub Admin

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. In the Select a role list, select a role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.

Create a cluster

In this section, you create a cluster that you can use in this tutorial. Although in a real-world scenario you would likely manage multiple clusters, to simplify this tutorial you only create and manage one cluster.

To create a cluster, complete the following steps:

  1. Enable the Google Kubernetes Engine (GKE) Enterprise edition API. This is essential for Config Sync.

    Go to Google Kubernetes Engine (GKE) Enterprise edition

  2. In the Google Cloud console, go to the Kubernetes Engine page.

    Go to Google Kubernetes Engine

  3. Click Create.

  4. In the Autopilot section, select Configure.

  5. In the Cluster basics section, enter cs-cluster in the Name field.

  6. In the Cluster tier section, select Enterprise tier. Leave all other fields with their recommended defaults.

  7. Click Create. You are taken to the Kubernetes clusters page. It takes several minutes for your cluster to be created. When you see a green check mark in the Status column next to your cluster, it's ready.

Configure your cluster

Now that you've created a cluster, you can configure Config Sync to sync to the configs in the config-sync-quickstart directory of the samples repository.

To configure Config Sync on the Google Cloud console, complete the following steps:

  1. In the Google Cloud console, go to the Config page under the Features section.

    Go to Config

  2. Click Install Config Sync.
  3. Select Auto-upgrades to enable Config Sync to upgrade versions automatically.
  4. Under Installation options, select Install Config Sync on individual clusters.
  5. In the Available clusters table, select cs-cluster and click Install Config Sync. In the Settings tab, you should see the status for the cs-cluster as Enabled after a few minutes.
  6. On the Config Sync dashboard, click Deploy cluster package.
  7. In the Select clusters for package deployment table, select cs-cluster and then click Continue.
  8. Leave Package hosted on Git selected and then click Continue.
  9. In the Package name field, enter sample-repository.
  10. In the Repository URL field, enter https://github.com/GoogleCloudPlatform/anthos-config-management-samples.
  11. In the Path field, enter config-sync-quickstart/multirepo/root.
  12. Leave all other fields with their default values.
  13. Click Deploy Package.

    After a few minutes, you should see Synced in the Sync status column for cs-cluster.

Now that Config Sync is synced to a repository, it continuously reconciles the state of your clusters with the configs in the repository.

View package details

To view all the objects that are managed by Config Sync, from the Packages tab, click cs-cluster and view the package details page. From this page, you get an overview of all resources synced per package and details like the resource type and which namespace the resources is synced to.

You can navigate to the /config-sync-quickstart/multirepo/ folder of the repository in GitHub to explore the configs that caused these namespaces to be created. The config-sync-quickstart directory includes ClusterRole, CustomResourceDefinition, Rolebinding, Namespace, and RepoSync configs. It also includes configurations for the Prometheus Operator for monitoring.

Clean up

  1. Go to the GKE menu in Google Cloud console.

    Go to GKE

  2. Next to the cs-cluster, click Actions, then click Delete.

  3. When prompted to confirm, click Delete again.

What's next