<commit_before>Advanced Install
==================================

This assumes you are running in Cloud Shell which has all of the prerequisites installed. 

If you are not the following resources are required.
* [Google Cloud SDK version >= 325.0.0](https://cloud.google.com/sdk/docs/downloads-versioned-archives)
* [kpt](https://kpt.dev/installation/)
* [kubectl](https://kubernetes.io/docs/tasks/tools/) ( >= v1.20)

1. Set environment variables that match your environment
```
CLUSTER=<cluster-name>
REGION=<supported-region>
PROJECT_ID=<project-id>
NETWORK=<vpc-name>
SUBNET=<subnet-name>
```

2. Create Project
```
gcloud projects create $PROJECT_ID --name="Config Controller" --labels=type=infrastructure-automation --set-as-default
```

3. Enable Billing
```
gcloud beta billing projects link $PROJECT_ID --billing-account $BILLING_ID
```

4. Set the project ID
```
gcloud config set project $PROJECT_ID
```

5. Enable the required services
```
gcloud services enable krmapihosting.googleapis.com \
    container.googleapis.com \
    cloudresourcemanager.googleapis.com
```

6. Create a network and subnet
```
gcloud compute networks create $NETWORK --subnet-mode=custom
gcloud compute networks subnets create $SUBNET  \
--network $NETWORK \
--range 192.168.0.0/16 \
--region $REGION
```

7. Create the Config Controller Instance
```
gcloud anthos config controller create $CLUSTER --location $REGION --network $NETWORK --subnet $SUBNET
```
```
gcloud container clusters get-credentials krmapihost-$CLUSTER --region $REGION
kubens config-control
```

8. Assign Permissions to the config connector Service Account.

```
ORG_ID=$(gcloud projects get-ancestors $PROJECT_ID --format='get(id)' | tail -1)
BILLING_ID=$(gcloud alpha billing projects describe $PROJECT_ID '--format=value(billingAccountName)' | sed 's/.*\///')
export ORG_ID=$ORG_ID
export SA_EMAIL="$(kubectl get ConfigConnectorContext -n config-control \
    -o jsonpath='{.items[0].spec.googleServiceAccount}' 2> /dev/null)"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
    --role "roles/resourcemanager.folderAdmin"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
    --role "roles/resourcemanager.projectCreator"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
    --role "roles/resourcemanager.projectDeleter"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
    --role "roles/iam.securityAdmin"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \<commit_msg>#33 - handle multiple billing ids - use manual<commit_after>Advanced Install
==================================

This assumes you are running in Cloud Shell which has all of the prerequisites installed. 

If you are not the following resources are required.
* [Google Cloud SDK version >= 325.0.0](https://cloud.google.com/sdk/docs/downloads-versioned-archives)
* [kpt](https://kpt.dev/installation/)
* [kubectl](https://kubernetes.io/docs/tasks/tools/) ( >= v1.20)

1. Set environment variables that match your environment
```
CLUSTER=<cluster-name>
REGION=<supported-region>
PROJECT_ID=<project-id>
NETWORK=<vpc-name>
SUBNET=<subnet-name>
ORG_ID=<your_org_id>
BILLING_ID=<your_billing_id>
```

2. Create Project
```
gcloud projects create $PROJECT_ID --name="Config Controller" --labels=type=infrastructure-automation --set-as-default
```

3. Enable Billing
```
gcloud beta billing projects link $PROJECT_ID --billing-account $BILLING_ID
```

4. Set the project ID
```
gcloud config set project $PROJECT_ID
```

5. Enable the required services
```
gcloud services enable krmapihosting.googleapis.com \
    container.googleapis.com \
    cloudresourcemanager.googleapis.com
```

6. Create a network and subnet
```
gcloud compute networks create $NETWORK --subnet-mode=custom
gcloud compute networks subnets create $SUBNET  \
--network $NETWORK \
--range 192.168.0.0/16 \
--region $REGION
```

7. Create the Config Controller Instance
```
gcloud anthos config controller create $CLUSTER --location $REGION --network $NETWORK --subnet $SUBNET
```
```
gcloud container clusters get-credentials krmapihost-$CLUSTER --region $REGION
kubens config-control
```

8. Assign Permissions to the config connector Service Account.

```
export ORG_ID=$ORG_ID
export SA_EMAIL="$(kubectl get ConfigConnectorContext -n config-control \
    -o jsonpath='{.items[0].spec.googleServiceAccount}' 2> /dev/null)"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
    --role "roles/resourcemanager.folderAdmin"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
    --role "roles/resourcemanager.projectCreator"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
    --role "roles/resourcemanager.projectDeleter"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
    --role "roles/iam.securityAdmin"
gcloud organizations add-iam-policy-binding "${ORG_ID}" \
    --member "serviceAccount:${SA_EMAIL}" \
{'fraction_non_alphanumeric': 0.1498580889309366, 'fraction_numerical': 0.011163670766319774, 'mean_word_length': 4.641408751334045, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1325248', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1649, 'n_words': 424}