From 26d49e6a644400d6c75e35227b875c1101a62501 Mon Sep 17 00:00:00 2001 From: Kai Siren Date: Tue, 21 Nov 2023 09:17:17 -0500 Subject: [PATCH] checkpoint-kai-1700576237 --- README.md | 28 +++++++++++++++++++++++++--- config.yml | 8 ++++---- infrastructure/application/state.tf | 12 ++++++------ infrastructure/foundation/state.tf | 12 ++++++------ infrastructure/kubconfig.yml | 8 ++++---- 5 files changed, 45 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 23bd8e6..c2bae46 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,16 @@ $ make upgrade This deployment command assumes you are locally authenticated to gcloud and kubectl, and have performed all of the above installations. +Note that, during the deploy process, you will likely need to enable several google APIs. Do so when prompted, then run the deploy again. This will show up as messages like: + +> googleapi: Error 403: $API has not been used in project $PROECT before or it is disabled. Enable it by visiting... + +These instructions all assume you are starting from the top level directory, whenever a `$SHELL` command is given. + +### 0. Name your project + +Open `config.yml` and modify the "Project configuration" section + ### 1. Create a new project Create a new project via https://console.cloud.google.com/, then set its name in `config.yml` @@ -106,11 +116,25 @@ Create a terraform state bucket via https://console.cloud.google.com/, then set bucket: coilysiren-k8s-gpc-tfstate-3 ``` -Then import it into terraform. +Then you must set its name manually in every `state.tf` file. Open every `state.tf` file in the repo. You will see a block like this: + +```hcl +terraform { + backend "gcs" { + bucket = "coilysiren-k8s-gpc-tfstate-3" + prefix = "terraform/state" + } +} +``` + +You should modify the `bucket = ...` line with your bucket name, same as in `config.yml`. + +Finally, import you import the bucket into terraform. ```bash # $SHELL cd infrastructure/foundation/ +terraform init terraform import google_storage_bucket.default coilysiren-k8s-gpc-tfstate-3 ``` @@ -125,5 +149,3 @@ Run the deploy script source ./venv/bin/activate invoke deploy # see tasks.py for source code ``` - -Note that, during the deploy process, you will likely need to enable several google APIs. Do so when prompted, then run the deploy again. diff --git a/config.yml b/config.yml index 9bf1bd7..7390293 100644 --- a/config.yml +++ b/config.yml @@ -1,7 +1,7 @@ -# Personal configuration -name: gke-test-2 -domain: gke-test-2.coilysiren.me -zone: coilysiren.me +# Project configuration +name: gke-test-3 +domain: gke-test-3.coilysiren.me +zone: coilysiren.me # domain - name = zone email: coilysiren@gmail.com # Google Cloud Platform configuration diff --git a/infrastructure/application/state.tf b/infrastructure/application/state.tf index 91f038d..254201a 100644 --- a/infrastructure/application/state.tf +++ b/infrastructure/application/state.tf @@ -1,14 +1,14 @@ -locals { - statebucket = yamldecode(file("../../config.yml")).statebucket -} - terraform { backend "gcs" { - bucket = "coilysiren-k8s-gpc-tfstate-0" + bucket = "coilysiren-k8s-gpc-tfstate-3" prefix = "terraform/state/application" } } +locals { + statebucket = yamldecode(file("../../config.yml")).statebucket +} + # https://registry.terraform.io/providers/hashicorp/google/latest/docs provider "google" { project = yamldecode(file("../../config.yml")).project @@ -35,7 +35,7 @@ data "google_project" "default" {} data "terraform_remote_state" "foundation" { backend = "gcs" config = { - bucket = "coilysiren-k8s-gpc-tfstate-0" + bucket = local.statebucket prefix = "terraform/state" } } diff --git a/infrastructure/foundation/state.tf b/infrastructure/foundation/state.tf index 8e8ca31..ba6e391 100644 --- a/infrastructure/foundation/state.tf +++ b/infrastructure/foundation/state.tf @@ -1,14 +1,14 @@ -locals { - statebucket = yamldecode(file("../../config.yml")).statebucket -} - terraform { backend "gcs" { - bucket = local.statebucket + bucket = "coilysiren-k8s-gpc-tfstate-3" prefix = "terraform/state" } } +locals { + statebucket = yamldecode(file("../../config.yml")).statebucket +} + # https://registry.terraform.io/providers/hashicorp/google/latest/docs provider "google" { project = yamldecode(file("../../config.yml")).project @@ -24,7 +24,7 @@ data "google_project" "default" {} # # https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket resource "google_storage_bucket" "default" { - name = statebucket + name = local.statebucket location = "US" force_destroy = true project = data.google_project.default.project_id diff --git a/infrastructure/kubconfig.yml b/infrastructure/kubconfig.yml index 66a3aed..d264956 100644 --- a/infrastructure/kubconfig.yml +++ b/infrastructure/kubconfig.yml @@ -4,7 +4,7 @@ items: kind: Ingress metadata: annotations: - kubernetes.io/ingress.allow-http: "true" + kubernetes.io/ingress.allow-http: 'true' kubernetes.io/ingress.class: gce networking.gke.io/managed-certificates: dns-cert name: application @@ -17,7 +17,7 @@ items: ingressClassName: gce tls: - hosts: - - gke-test-2.coilysiren.me + - gke-test-3.coilysiren.me - apiVersion: v1 kind: Service metadata: @@ -55,10 +55,10 @@ items: app: application spec: containers: - - image: us-central1-docker.pkg.dev/root-territory-384205/repository/gke-test-2:certs-6bbf26e-kai + - image: us-central1-docker.pkg.dev/dotted-hope-405813/repository/gke-test-3:certs-59fae72-kai name: application ports: - containerPort: 8080 kind: List metadata: - resourceVersion: "" + resourceVersion: ''