Skip to content

Commit

Permalink
checkpoint-kai-1700576237
Browse files Browse the repository at this point in the history
  • Loading branch information
coilysiren committed Nov 21, 2023
1 parent 59fae72 commit 26d49e6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 23 deletions.
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
```

Expand All @@ -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.
8 changes: 4 additions & 4 deletions config.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions infrastructure/application/state.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
}
}
12 changes: 6 additions & 6 deletions infrastructure/foundation/state.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions infrastructure/kubconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,7 +17,7 @@ items:
ingressClassName: gce
tls:
- hosts:
- gke-test-2.coilysiren.me
- gke-test-3.coilysiren.me
- apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -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: ''

0 comments on commit 26d49e6

Please sign in to comment.