Commit 55a696ce by chenxx

add startup probe

1 parent a6f459a4
...@@ -36,7 +36,7 @@ module "deployment" { ...@@ -36,7 +36,7 @@ module "deployment" {
readiness_probe = { readiness_probe = {
http_get = { http_get = {
path = "/" path = var.probe_http_path
port = var.probe_http_port port = var.probe_http_port
scheme = "HTTP" scheme = "HTTP"
} }
...@@ -47,6 +47,20 @@ module "deployment" { ...@@ -47,6 +47,20 @@ module "deployment" {
timeout_seconds = 3 timeout_seconds = 3
} }
# start time 4 minute
starup_probe = {
http_get = {
path = var.probe_http_path
port = var.probe_http_port
scheme = "HTTP"
}
success_threshold = 1
failure_threshold = 12
initial_delay_seconds = 10
period_seconds = 20
timeout_seconds = 5
}
volume_host_path = [ volume_host_path = [
{ {
volume_name = var.app_log_path_volume_name volume_name = var.app_log_path_volume_name
......
...@@ -376,6 +376,52 @@ resource "kubernetes_deployment" "deploy_app" { ...@@ -376,6 +376,52 @@ resource "kubernetes_deployment" "deploy_app" {
} }
} }
dynamic "startup_probe" {
for_each = flatten([var.startup_probe])
content {
initial_delay_seconds = lookup(startup_probe.value, "initial_delay_seconds", null)
period_seconds = lookup(startup_probe.value, "period_seconds", null)
timeout_seconds = lookup(startup_probe.value, "timeout_seconds", null)
success_threshold = lookup(startup_probe.value, "success_threshold", 1)
failure_threshold = lookup(startup_probe.value, "failure_threshold", null)
dynamic "http_get" {
for_each = contains(keys(startup_probe.value), "http_get") ? [startup_probe.value.http_get] : []
content {
path = lookup(http_get.value, "path", null)
port = lookup(http_get.value, "port", null)
scheme = lookup(http_get.value, "scheme", null)
host = lookup(http_get.value, "host", null)
dynamic "http_header" {
for_each = contains(keys(http_get.value), "http_header") ? http_get.value.http_header : []
content {
name = http_header.value.name
value = http_header.value.value
}
}
}
}
dynamic "exec" {
for_each = contains(keys(startup_probe.value), "exec") ? [startup_probe.value.exec] : []
content {
command = exec.value.command
}
}
dynamic "tcp_socket" {
for_each = contains(keys(startup_probe.value), "tcp_socket") ? [startup_probe.value.tcp_socket] : []
content {
port = tcp_socket.value.port
}
}
}
}
dynamic "lifecycle" { dynamic "lifecycle" {
for_each = flatten([var.lifecycle_events]) for_each = flatten([var.lifecycle_events])
content { content {
......
...@@ -164,6 +164,12 @@ variable "readiness_probe" { ...@@ -164,6 +164,12 @@ variable "readiness_probe" {
description = "(Optional) Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. " description = "(Optional) Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. "
default = [] default = []
} }
variable "startup_probe" {
description = "(Optional) Periodic probe of container service startup. Container will be removed from service endpoints if the probe fails. Cannot be updated. "
default = []
}
variable "lifecycle_events" { variable "lifecycle_events" {
description = "(Optional) Actions that the management system should take in response to container lifecycle events" description = "(Optional) Actions that the management system should take in response to container lifecycle events"
default = [] default = []
......
...@@ -93,12 +93,20 @@ variable "probe_http_port" { ...@@ -93,12 +93,20 @@ variable "probe_http_port" {
type = string type = string
} }
# @label "probe_path"
# @group "Advanced"
variable "probe_http_path" {
description = "(Optional)http path for probe"
type = string
default = "/"
}
# @label "应用日志挂载卷名" # @label "应用日志挂载卷名"
# @group "Advanced" # @group "Advanced"
variable "app_log_path_volume_name" { variable "app_log_path_volume_name" {
type = string type = string
description = "应用日志挂载卷名,名字只能使用-,例: abc-22 abc-cc" description = "应用日志挂载卷名,名字只能使用-,例: abc-22 abc-cc"
default = "app-log-path" default = "app-log-path"
} }
# @label "应用日志路径" # @label "应用日志路径"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!