Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
resource "kubernetes_deployment" "this" {
wait_for_rollout = var.wait_for_rollout

metadata {
name = var.name
namespace = var.namespace
}

depends_on = [var.namespace]

spec {
replicas = var.replicas

Expand Down Expand Up @@ -50,13 +52,13 @@ resource "kubernetes_deployment" "this" {
lifecycle {
pre_stop {
exec {
command = [ "sleep", var.pre_stop_sleep_seconds ]
command = ["sleep", var.pre_stop_sleep_seconds]
}
}
}

dynamic "liveness_probe" {
for_each = var.liveness_probe == null || var.disable_liveness_probe ? [ ] : [ var.liveness_probe ]
for_each = var.liveness_probe == null || var.disable_liveness_probe ? [] : [var.liveness_probe]
content {
http_get {
path = liveness_probe.value["path"]
Expand All @@ -77,7 +79,7 @@ resource "kubernetes_deployment" "this" {
}

dynamic "startup_probe" {
for_each = var.startup_probe == null || var.disable_startup_probe ? [ ] : [ var.startup_probe ]
for_each = var.startup_probe == null || var.disable_startup_probe ? [] : [var.startup_probe]
content {
http_get {
path = startup_probe.value["path"]
Expand Down Expand Up @@ -134,6 +136,8 @@ resource "kubernetes_service" "this" {
namespace = var.namespace
}

depends_on = [var.namespace, kubernetes_deployment.this]

spec {
type = var.service_type

Expand Down Expand Up @@ -168,6 +172,13 @@ resource "kubernetes_ingress" "this" {
}
}

depends_on = [
var.namespace,
kubernetes_deployment.this,
kubernetes_service.this,
kubernetes_ingress.this
]

spec {
rule {
host = var.host
Expand Down
12 changes: 6 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

variable "cpu_limit" {
description = "The maximum CPU. Format is Xm, which is X thousandths of a CPU, e.g. 2000m would be 2 CPUs. The default is 2 CPUs. https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
default = "2000m"
default = "2000m"
}

variable "cpu_request" {
description = "The amount of CPU to request. Format is Xm, which represent X thousandths of a CPU, e.g. 500m would be half a CPU. https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
default = 0
default = 0
}

variable "host" {
Expand All @@ -30,7 +30,7 @@ variable "image" {

variable "liveness_probe" {
description = "The URL to use in the app's liveness probe."
type = object({
type = object({
failure_threshold = number
frequency = number
initial_delay = number
Expand All @@ -43,12 +43,12 @@ variable "liveness_probe" {

variable "mem_limit" {
description = "The maximum amount of memory to reserve. Default is 8Gi. https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
default = "8Gi"
default = "8Gi"
}

variable "mem_request" {
description = "The amount of memory to request. https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
default = 0
default = 0
}

variable "name" {
Expand Down Expand Up @@ -83,7 +83,7 @@ variable "service_type" {

variable "startup_probe" {
description = "Configuration for the app's startup probe, if any."
type = object({
type = object({
failure_threshold = number
frequency = number
initial_delay = number
Expand Down