Google Cloud Anthos Series: Anthos Config Management

Google Cloud Anthos Series: Part-5

Anchit Nishant
Google Cloud - Community
4 min readFeb 21, 2022

--

Welcome to Part-5 of the ‘Google Cloud Anthos series’. You can find the complete series Here.

Set the PROJECT_ID environment variable and ensure the Google Kubernetes Engine and Cloud Operations APIs are enabled.

Clone the Online Boutique repository.

Create GKE clusters in three different regions. Make sure you have a VPC which spans across at-least 3 regions where you would want your clusters to reside.

Enable Anthos Config management API

Create a Cloud Source repository

Make sure the default service account PROJECT_NUMBER-compute@developer.gserviceaccount.com for the cluster has the source.reader access to the repository.

Push the Online Boutique application to the newly created cloud source repository.

Deploy the application to all the clusters.

We need to create constraint and push the file to the cloud source repository.

Here is a sample constraint which will deny creation of any Privileged containers.

Folder structure: /allpolicies/policies/policy.yaml (screenshot)

Push the policy to the source code repository.

Install Anthos Config Management and configure the policy controller through the GKE console.

Get the endpoint of the repository using the below command. We will need it in next step.

Paste the URL of your Cloud source repository as below and click on Show Advanced options.

You can verify that Config Sync is syncing this constraint to your GKE clusters.

You should be able to see the output as below.

Now, let’s create a manifest (privileged.yaml) for pod which has privileged container.

Try to deploy the manifest which violates the policy to any of the cluster.

It should fail with the below error.

If we run the constraint in dryrun mode, we can view the violations with the below command in status field.

Coming up..

In this blog we discussed Anthos Config Management. In upcoming blogs we will continue the Samajik’s journey with other Anthos features.

Contributors: Shijimol A K, Pushkar Kothavade, Dhandus

--

--