Skip to content

Commit

Permalink
Merge pull request #4 from redbadger/inventory-service-deployment
Browse files Browse the repository at this point in the history
Inventory service deployment
  • Loading branch information
pataruco authored Dec 21, 2023
2 parents 007bac7 + c5bfd78 commit 4c447be
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,11 @@ spec:
containerPort: 8082
protocol: TCP
env:
- name: POSTGRES_USERNAME
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: postgres-db-secrets
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-db-secrets
key: password
- name: POSTGRES_URL
value: jdbc:postgresql://127.0.0.1:5432/inventory-service
key: inventory_service_database_url
readinessProbe:
httpGet:
path: /actuator/health
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,12 @@ spec:
containerPort: 8081
protocol: TCP
env:
- name: POSTGRES_USERNAME
valueFrom:
secretKeyRef:
name: postgres-db-secrets
key: username
- name: POSTGRES_PASSWORD
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: postgres-db-secrets
key: password
- name: POSTGRES_URL
value: {{ .Values.postgres.url }}
key: order_service_database_url
- name: KAFKA_URL
value: {{ .Values.kafka.url }}
readinessProbe:
Expand Down
13 changes: 5 additions & 8 deletions rust-containers-k8s/infrastructure/kubernetes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ module "shared_vars" {

variable "pg_user" {
description = "Username for Postgres Cloud SQL database"
default = "commerce"
}

variable "pg_password" {
description = "password for Postgres Cloud SQL database"
}

variable "pg_database" {
description = "Postgres Cloud SQL database name"
default = "commerce"
}

data "terraform_remote_state" "workload-identity-user-sa" {
Expand All @@ -35,7 +33,7 @@ resource "google_project_iam_member" "workload_identity-role" {

resource "kubernetes_service_account" "ksa" {
metadata {
name = "kubernetes-service-account"
name = "kubernetes-service-account"
annotations = {
"iam.gke.io/gcp-service-account" = data.terraform_remote_state.workload-identity-user-sa.outputs.node_pool_service_account
}
Expand All @@ -48,8 +46,7 @@ resource "kubernetes_secret" "db_secrets" {
}

data = {
username = var.pg_user
password = var.pg_password
database = var.pg_database
inventory_service_database_url = "postgresql://${var.pg_user}:${var.pg_password}@127.0.0.1/inventory-service"
order_service_database_url = "postgresql://${var.pg_user}:${var.pg_password}@127.0.0.1/order-service"
}
}
7 changes: 7 additions & 0 deletions rust-containers-k8s/inventory-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ use serde::Deserialize;

#[derive(Deserialize, Debug)]
pub struct Config {
#[serde(default = "defaults::port")]
pub port: u16,
pub database_url: String,
}

mod defaults {
pub const fn port() -> u16 {
8082
}
}

impl Config {
pub fn new() -> Result<Self, envy::Error> {
envy::from_env::<Config>()
Expand Down

0 comments on commit 4c447be

Please sign in to comment.