Skip to content

Commit

Permalink
Add k8s deployment resources limits (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
trottomv authored Jan 18, 2023
1 parent 667daf1 commit 9b0a912
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ resource "kubernetes_deployment_v1" "main" {
container {
image = var.service_container_image
name = var.service_slug
resources {
requests {
memory = var.service_requests_memory
cpu = var.service_requests_cpu
}
limits {
memory = var.service_limits_memory
cpu = var.service_limits_cpu
}
}
port {
container_port = var.service_container_port
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,32 @@ variable "service_container_port" {
default = "{{ cookiecutter.internal_service_port }}"
}

variable "service_limits_cpu" {
description = "The service limits cpu value."
type = string
}

variable "service_limits_memory" {
description = "The service limits memory value."
type = string
}

variable "service_replicas" {
description = "The desired numbers of replicas to deploy."
type = number
default = 1
}

variable "service_requests_cpu" {
description = "The service requests cpu value."
type = string
}

variable "service_requests_memory" {
description = "The service requests memory value."
type = string
}

variable "service_slug" {
description = "The service slug."
type = string
Expand Down
4 changes: 4 additions & 0 deletions {{cookiecutter.project_dirname}}/terraform/vars/.tfvars
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% if "environment" in cookiecutter.tfvars %}{% for item in cookiecutter.tfvars.environment|sort %}{{ item }}
{% endfor %}{% endif %}# service_container_port="{{ cookiecutter.internal_service_port }}"
service_limits_cpu="225m"
service_limits_memory="256Mi"
# service_replicas=1
service_requests_cpu="25m"
service_requests_memory="115Mi"

0 comments on commit 9b0a912

Please sign in to comment.