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
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Make sure that you have the following role or roles on the project: GKE Hub Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
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.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- In the Select a role list, select a role.
- To grant additional roles, click Add another role and add each additional role.
- 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:
Enable the Google Kubernetes Engine (GKE) Enterprise edition API. This is essential for Config Sync.
In the Google Cloud console, go to the Kubernetes Engine page.
Click add_box Create.
In the Autopilot section, select Configure.
In the Cluster basics section, enter
cs-cluster
in the Name field.In the Cluster tier section, select Enterprise tier. Leave all other fields with their recommended defaults.
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:
- In the Google Cloud console, go to the Config page under the Features section.
- Click add Install Config Sync.
- Select Auto-upgrades to enable Config Sync to upgrade versions automatically.
- Under Installation options, select Install Config Sync on individual clusters.
- In the
Available clusters table, select
cs-cluster
and click Install Config Sync. In the Settings tab, you should see the status for thecs-cluster
as Enabled after a few minutes. - On the Config Sync dashboard, click Deploy cluster package.
- In the Select clusters for package deployment table, select
cs-cluster
and then click Continue. - Leave Package hosted on Git selected and then click Continue.
- In the Package name field, enter
sample-repository
. - In the Repository URL field, enter
https://github.com/GoogleCloudPlatform/anthos-config-management-samples
. - In the Path field, enter
config-sync-quickstart/multirepo/root
. - Leave all other fields with their default values.
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
Go to the GKE menu in Google Cloud console.
Next to the
cs-cluster
, click more_vert Actions, then click delete Delete.When prompted to confirm, click Delete again.
What's next
- Learn about validating configs.