@@ -47,6 +47,7 @@ containing manifests that are deployed to the cluster
47
47
48
48
## Deploying
49
49
50
+ - Open a PR and Atlantis will apply and deploy your Terraform changes.
50
51
- Ensure you are logged into your GCP account with ` gcloud auth application-default login `
51
52
- From within a module directory:
52
53
- ` terraform init ` will initialize your local state (refresh modules)
@@ -55,9 +56,49 @@ containing manifests that are deployed to the cluster
55
56
56
57
## Deleting
57
58
58
- - Get approval from a WG K8s Infra lead (ask in [ #sig-k8s-infra] before doing this)
59
+ - Get approval from a SIG K8s Infra lead (ask in [ #sig-k8s-infra] before doing this)
59
60
- Ensure you are logged into your GCP account with ` gcloud auth application-default login `
60
61
- From within a module directory:
61
62
- ` terraform destroy ` will destroy and clean up all created resources
62
63
63
64
[ #sig-k8s-infra ] : https://kubernetes.slack.com/messages/sig-k8s-infra
65
+
66
+
67
+ # Bootstrapping Terraform - One Time Setup
68
+
69
+ Terraform needs to be bootstrapped manually before it can be used. This process was done during Atlantis Setup. It is noted here for completeness and for potential troubleshooting.
70
+
71
+ This needs to be ran by a person.
72
+
73
+ ```
74
+ # Get the ORG_ID
75
+ ORG_ID=$(gcloud organizations describe kubernetes.io --format json | jq .name -r | sed 's:.*/::')
76
+
77
+ # Create the k8s-infra-seed project
78
+
79
+ gcloud projects create k8s-infra-seed --organization $ORG_ID --name "K8s Infra Seed" --billing
80
+
81
+ # Create the terraform service account
82
+
83
+ gcloud iam service-accounts create atlantis —-display-name Atlantis --project k8s-infra-seed
84
+
85
+ # Allow the Atlantis Kubernetes Service Account in k8s-infra-prow project to assume this service account
86
+
87
+ gcloud iam service-accounts add-iam-policy-binding [email protected] \
88
+ --member "serviceAccount:k8s-infra-prow.svc.id.goog[atlantis/atlantis]" --role='roles/iam.workloadIdentityUser'
89
+
90
+ # Create the State Bucket and version it
91
+ gcloud storage buckets create gs://k8s-infra-tf-state --location=us --uniform-bucket-level-access
92
+ gcloud storage buckets update gs://k8s-infra-tf-state --versioning
93
+
94
+ # Enable Google APIs
95
+ gcloud services enable container.googleapis.com run.googleapis.com cloudbuild.googleapis.com --async
96
+
97
+ # Privilege the terraform service account
98
+ gcloud organizations add-iam-policy-binding --organization $ORG_ID \
99
+ --member "serviceAccount:[email protected] " --role='roles/resourcemanager.organizationAdmin'
100
+ gcloud organizations add-iam-policy-binding --organization $ORG_ID \
101
+ --member "serviceAccount:[email protected] " --role='roles/owner'
102
+ gcloud organizations add-iam-policy-binding --organization $ORG_ID \
103
+ --member "serviceAccount:[email protected] " --role='roles/billing.admin'
104
+ ```
0 commit comments