-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Atlantis to manage GCP Infrastructure #7581
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ containing manifests that are deployed to the cluster | |
|
||
## Deploying | ||
|
||
- Open a PR and Atlantis will apply and deploy your Terraform changes. | ||
- Ensure you are logged into your GCP account with `gcloud auth application-default login` | ||
- From within a module directory: | ||
- `terraform init` will initialize your local state (refresh modules) | ||
|
@@ -55,9 +56,49 @@ containing manifests that are deployed to the cluster | |
|
||
## Deleting | ||
|
||
- Get approval from a WG K8s Infra lead (ask in [#sig-k8s-infra] before doing this) | ||
- Get approval from a SIG K8s Infra lead (ask in [#sig-k8s-infra] before doing this) | ||
- Ensure you are logged into your GCP account with `gcloud auth application-default login` | ||
- From within a module directory: | ||
- `terraform destroy` will destroy and clean up all created resources | ||
|
||
[#sig-k8s-infra]: https://kubernetes.slack.com/messages/sig-k8s-infra | ||
|
||
|
||
# Bootstrapping Terraform - One Time Setup | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for writing this down. |
||
|
||
This needs to be ran by a person. | ||
|
||
``` | ||
# Get the ORG_ID | ||
ORG_ID=$(gcloud organizations describe kubernetes.io --format json | jq .name -r | sed 's:.*/::') | ||
upodroid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Create the k8s-infra-seed project | ||
|
||
gcloud projects create k8s-infra-seed --organization $ORG_ID --name "K8s Infra Seed" --billing | ||
|
||
# Create the terraform service account | ||
|
||
gcloud iam service-accounts create atlantis —-display-name Atlantis --project k8s-infra-seed | ||
|
||
# Allow the Atlantis Kubernetes Service Account in k8s-infra-prow project to assume this service account | ||
|
||
gcloud iam service-accounts add-iam-policy-binding atlantis@k8s-infra-seed.iam.gserviceaccount.com \ | ||
--member "serviceAccount:k8s-infra-prow.svc.id.goog[atlantis/atlantis]" --role='roles/iam.workloadIdentityUser' | ||
|
||
# Create the State Bucket and version it | ||
gcloud storage buckets create gs://k8s-infra-tf-state --location=us --uniform-bucket-level-access | ||
gcloud storage buckets update gs://k8s-infra-tf-state --versioning | ||
|
||
# Enable Google APIs | ||
gcloud services enable container.googleapis.com run.googleapis.com cloudbuild.googleapis.com --async | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe provide the project with |
||
|
||
# Privilege the terraform service account | ||
gcloud organizations add-iam-policy-binding --organization $ORG_ID \ | ||
--member "serviceAccount:atlantis@k8s-infra-seed.iam.gserviceaccount.com" --role='roles/resourcemanager.organizationAdmin' | ||
gcloud organizations add-iam-policy-binding --organization $ORG_ID \ | ||
--member "serviceAccount:atlantis@k8s-infra-seed.iam.gserviceaccount.com" --role='roles/owner' | ||
gcloud organizations add-iam-policy-binding --organization $ORG_ID \ | ||
--member "serviceAccount:atlantis@k8s-infra-seed.iam.gserviceaccount.com" --role='roles/billing.admin' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe we should be clear that this will happen after merge just to be explicit?)