Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tcp keep alive config #246

Merged
merged 1 commit into from
Jul 1, 2024
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [7.2.1] - 2024-07-01
### Added
- Issue where requests can hit 10min connection timeout, TCP keepalive prevents NLB closing idle connections. Similar to the issue explained here: https://paramount.tech/blog/2021/07/26/mitigation-of-connection-reset-in-aws.html

## [7.2.0] - 2024-06-26
### Added
- Added `hms_ro_datanucleus_connection_pooling_type`, `hms_rw_datanucleus_connection_pooling_type`, `hms_ro_datanucleus_connection_pool_config`, `hms_rw_datanucleus_connection_pool_config`, `hms_housekeeper_db_connection_pool_size` variables to allow specifying the pooling driver and its config
Expand Down
44 changes: 24 additions & 20 deletions VARIABLES.md

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions k8s-readonly.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ resource "kubernetes_deployment_v1" "apiary_hms_readonly" {
spec {
service_account_name = kubernetes_service_account_v1.hms_readonly[0].metadata.0.name
automount_service_account_token = true
dynamic "security_context" {
for_each = var.enable_tcp_keepalive ? ["enabled"] : []
content {
sysctl {
name = "net.ipv4.tcp_keepalive_time"
value = var.tcp_keepalive_time
}
sysctl {
name = "net.ipv4.tcp_keepalive_intvl"
value = var.tcp_keepalive_intvl
}
sysctl {
name = "net.ipv4.tcp_keepalive_probes"
value = var.tcp_keepalive_probes
}
}
}
dynamic "init_container" {
for_each = var.external_database_host == "" ? ["enabled"] : []

Expand Down
17 changes: 17 additions & 0 deletions k8s-readwrite.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ resource "kubernetes_deployment_v1" "apiary_hms_readwrite" {
spec {
service_account_name = kubernetes_service_account_v1.hms_readwrite[0].metadata.0.name
automount_service_account_token = true
dynamic "security_context" {
for_each = var.enable_tcp_keepalive ? ["enabled"] : []
content {
sysctl {
name = "net.ipv4.tcp_keepalive_time"
value = var.tcp_keepalive_time
}
sysctl {
name = "net.ipv4.tcp_keepalive_intvl"
value = var.tcp_keepalive_intvl
}
sysctl {
name = "net.ipv4.tcp_keepalive_probes"
value = var.tcp_keepalive_probes
}
}
}
dynamic "init_container" {
for_each = var.external_database_host == "" ? ["enabled"] : []
content {
Expand Down
6 changes: 6 additions & 0 deletions templates.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ locals{
datadog_agent_version = var.datadog_agent_version
datadog_agent_enabled = var.datadog_agent_enabled
datadog_tags = local.datadog_tags
tcp_keepalive_time = var.tcp_keepalive_time
tcp_keepalive_intvl = var.tcp_keepalive_intvl
tcp_keepalive_probes = var.tcp_keepalive_probes
})

hms_readonly_template = templatefile("${path.module}/templates/apiary-hms-readonly.json", {
Expand Down Expand Up @@ -120,5 +123,8 @@ locals{
metrics_port = var.datadog_metrics_port
datadog_agent_version = var.datadog_agent_version
datadog_tags = local.datadog_tags
tcp_keepalive_time = var.tcp_keepalive_time
tcp_keepalive_intvl = var.tcp_keepalive_intvl
tcp_keepalive_probes = var.tcp_keepalive_probes
})
}
16 changes: 15 additions & 1 deletion templates/apiary-hms-readonly.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@
"name": "nofile"
}
],
"logConfiguration": {
"systemControls": [
{
"namespace": "net.ipv4.tcp_keepalive_time",
"value": "${tcp_keepalive_time}"
},
{
"namespace": "net.ipv4.tcp_keepalive_intvl",
"value": "${tcp_keepalive_intvl}"
},
{
"namespace": "net.ipv4.tcp_keepalive_probes",
"value": "${tcp_keepalive_probes}"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${loggroup}",
Expand Down
14 changes: 14 additions & 0 deletions templates/apiary-hms-readwrite.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@
"name": "nofile"
}
],
"systemControls": [
{
"namespace": "net.ipv4.tcp_keepalive_time",
"value": "${tcp_keepalive_time}"
},
{
"namespace": "net.ipv4.tcp_keepalive_intvl",
"value": "${tcp_keepalive_intvl}"
},
{
"namespace": "net.ipv4.tcp_keepalive_probes",
"value": "${tcp_keepalive_probes}"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
Expand Down
26 changes: 25 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -786,4 +786,28 @@ variable "hms_rw_datanucleus_connection_pool_config" {
description = "A map of env vars supported by Apiary docker image that can configure the chosen Datanucleus connection pool"
type = map(any)
default = {}
}
}

variable "enable_tcp_keepalive" {
description = "Enable tcp keepalive settings on the hms pods"
type = bool
default = false
}

variable "tcp_keepalive_time" {
description = "Sets net.ipv4.tcp_keepalive_time (seconds)."
type = number
default = 200
}

variable "tcp_keepalive_intvl" {
description = "Sets net.ipv4.tcp_keepalive_intvl (seconds)."
type = number
default = 30
}

variable "tcp_keepalive_probes" {
description = "Sets net.ipv4.tcp_keepalive_probes (number)."
type = number
default = 2
}
Loading