Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatoleAM committed Dec 3, 2023
1 parent 97d0858 commit 71cfced
Showing 1 changed file with 91 additions and 1 deletion.
92 changes: 91 additions & 1 deletion terraform/deployment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data "kubernetes_namespace" "app" {

resource "kubernetes_secret" "app" {
metadata {
name = "api"
name = "compactdisc"
namespace = var.namespace
}

Expand All @@ -28,3 +28,93 @@ resource "kubernetes_secret" "app" {
})
}
}

resource "kubernetes_deployment" "app" {
metadata {
name = "compactdisc"
namespace = data.kubernetes_namespace.app.metadata[0].name
labels = {
app = "compactdisc"
}
}

spec {
selector {
match_labels = {
app = "compactdisc"
}
}

strategy {
type = "RollingUpdate"
rolling_update {
max_surge = "0"
max_unavailable = "1"
}
}

template {
metadata {
labels = {
app = "compactdisc"
}
}

spec {
container {
name = "compactdisc"
image = local.image_url

resources {
requests = {
memory = "384Mi"
cpu = "200m"
}
limits = {
memory = "384Mi"
cpu = "200m"
}
}

port {
name = "api"
container_port = 3000
protocol = "TCP"
}

volume_mount {
name = "config"
mount_path = "/app/config.yaml"
sub_path = "config.yaml"
}
}

volume {
name = "config"
secret {
secret_name = kubernetes_secret.app.metadata[0].name
}
}
}
}
}
}

resource "kubernetes_service" "app" {
metadata {
name = "compactdisc"
namespace = data.kubernetes_namespace.app.metadata[0].name
}

spec {
selector = {
app = "compactdisc"
}

port {
name = "api"
port = 3000
target_port = "api"
}
}
}

0 comments on commit 71cfced

Please sign in to comment.