Skip to content

Commit

Permalink
ingress functional again
Browse files Browse the repository at this point in the history
  • Loading branch information
coilysiren committed Jun 1, 2024
1 parent 8d0f72c commit af05c22
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 35 deletions.
7 changes: 3 additions & 4 deletions infrastructure/application/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ data "aws_route53_zone" "zone" {
private_zone = false
}

# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_address
resource "google_compute_address" "address" {
name = "application-ingress"
address_type = "EXTERNAL"
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_address
resource "google_compute_global_address" "address" {
name = "application-ingress"
}
10 changes: 4 additions & 6 deletions infrastructure/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ items:
- apiVersion: v1
kind: Service
metadata:
annotations:
cloud.google.com/neg: '{"ingress": true}'
name: application
spec:
ports:
- name: http
port: 80
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: application
type: ClusterIP
type: NodePort
- apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -29,7 +27,7 @@ items:
app: application
spec:
containers:
- image: us-central1-docker.pkg.dev/gke-test-5/repository/gke-test-5:main-27e69ef-kai
- image: us-central1-docker.pkg.dev/gke-test-5/repository/gke-test-5:main-8d0f72c-kai
name: application
ports:
- containerPort: 8080
Expand Down
6 changes: 2 additions & 4 deletions infrastructure/ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ items:
metadata:
annotations:
cert-manager.io/issuer: letsencrypt-prod
kubernetes.io/ingress.allow-http: true
kubernetes.io/ingress.class: gce
kubernetes.io/ingress.global-static-ip-name: application-ingress
name: application-ingress
spec:
Expand Down Expand Up @@ -44,7 +42,7 @@ items:
name: route53-credentials-secret
selector:
dnsZones:
- gke-test-3.coilysiren.me
- gke-test-5.coilysiren.me
kind: List
metadata:
resourceVersion: ''
resourceVersion: ""
9 changes: 3 additions & 6 deletions infrastructure/ingress/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ locals {
domain = yamldecode(file("../../config.yml")).domain
}

# https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/ingress_v1
data "kubernetes_ingress_v1" "ingress" {
metadata {
name = "application-ingress"
}
data "google_compute_addresses" "address" {
filter = "name:application-ingress"
}

# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route53_zone
Expand All @@ -22,5 +19,5 @@ resource "aws_route53_record" "record" {
name = "${local.domain}."
type = "A"
ttl = "300"
records = [data.kubernetes_ingress_v1.ingress.status.0.load_balancer.0.ingress.0.ip]
records = [data.google_compute_addresses.address.addresses[0].address]
}
15 changes: 0 additions & 15 deletions infrastructure/ingress/state.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,10 @@ provider "google" {
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_config
data "google_client_config" "default" {}

# https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs
provider "kubernetes" {
host = "https://${data.terraform_remote_state.foundation.outputs.endpoint}"
token = data.google_client_config.default.access_token
cluster_ca_certificate = base64decode(data.terraform_remote_state.foundation.outputs.ca_certificate)
}

# https://registry.terraform.io/providers/hashicorp/aws/latest/docs
provider "aws" {
# AWS doesn't have the same regions as GCP, and also doesn't format then in the same way.
# That said, this isn't a huge issue because we are only using AWS for DNS.
region = "us-east-1"
profile = "coilysiren"
}

data "terraform_remote_state" "foundation" {
backend = "gcs"
config = {
bucket = local.statebucket
prefix = "terraform/state"
}
}

0 comments on commit af05c22

Please sign in to comment.