This repository hosts templates for config controller. All assets are work in progress.
All templates are intended to be deployed on Config Controller.
Follow the steps to deploy templates. The steps are tested on Cloud Shell.
Set up Config Controller (Ref.)
-
Define environment variables
Replace values to adopt your environment.
export CONFIG_CONTROLLER_NAME=config-controller01 export PROJECT_ID=project_id export [email protected]
-
Enable required services
gcloud services enable krmapihosting.googleapis.com \ container.googleapis.com \ cloudresourcemanager.googleapis.com
-
Create Config Controller
gcloud anthos config controller create $CONFIG_CONTROLLER_NAME \ --location=us-central1
-
Authenticate with the Config Controller cluster
gcloud anthos config controller get-credentials $CONFIG_CONTROLLER_NAME \ --location us-central1
-
Give Config Controller permission to manage Google Cloud resources
export SA_EMAIL="$(kubectl get ConfigConnectorContext -n config-control \ -o jsonpath='{.items[0].spec.googleServiceAccount}' 2> /dev/null)" gcloud projects add-iam-policy-binding "${PROJECT_ID}" \ --member "serviceAccount:${SA_EMAIL}" \ --role "roles/owner" \ --project "${PROJECT_ID}"
Set up a namespace to manage the project (Ref.)
-
Install the ResourceGroup CRD
kpt live install-resource-group
-
Fetch the Project Namespace blueprint
kpt pkg get \ https://github.com/GoogleCloudPlatform/blueprints.git/catalog/project/kcc-namespace@main \ $PROJECT_ID
-
Move into the directory
cd $PROJECT_ID/
-
Configure the package by modifying the setters.yaml
cat > setters.yaml << EOF apiVersion: v1 kind: ConfigMap metadata: name: setters data: project-id: $PROJECT_ID management-project-id: $PROJECT_ID management-namespace: config-control projects-namespace: config-control networking-namespace: config-control EOF
-
Render the setter values into the templated resources
kpt fn render
-
Configure tenant permissions
cat > project-admin.yaml << EOF apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: project-admin namespace: $PROJECT_ID roleRef: kind: ClusterRole name: cnrm-admin apiGroup: rbac.authorization.k8s.io subjects: - kind: User name: $TENANT_EMAIL apiGroup: rbac.authorization.k8s.io EOF
-
Initialize the working directory with kpt, which creates a resource to track changes
kpt live init --namespace config-control
-
Apply the resources
kpt live apply
-
Fetch a template
Specify the template number. Following command uses
template1
as a example.kpt pkg get https://github.com/hasebe/config-controller-templates/template1 template1
-
Move into the directory
cd template1/
-
Update variables in
setters.yaml
on each directory to adjust your enviroment -
Initialize the working directory with kpt, which creates a resource to track changes
kpt live init --namespace $PROJECT_ID
-
Render the setter values into the templated resources
kpt fn render
-
Apply the resources
kpt live apply --namespace $PROJECT_ID