Skip to content

montblu/terraform-kubernetes-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Requirements

Name Version
terraform >= 1.3.0
aws >= 4.41.0
kubectl >= 1.14.0
kubernetes >= 2.23.0

Providers

Name Version
aws >= 4.41.0
kubectl >= 1.14.0
kubernetes >= 2.23.0

Modules

No modules.

Resources

Name Type
aws_ecr_lifecycle_policy.main resource
aws_ecr_repository.main resource
aws_ecr_repository_policy.main resource
kubectl_manifest.main resource
kubernetes_deployment.main resource
kubernetes_service.main resource
aws_iam_policy_document.main data source

Inputs

Name Description Type Default Required
deployment Kubernetes deployment configuration
object({
name = string
prefix = optional(string)
namespace = string
annotations = optional(map(string), {})
labels = optional(map(string), {})
replicas = optional(number, 1)
affinity = optional(list(map(any)), [])
volumes = optional(any, [])
wait_for_rollout = optional(bool, false)
host_aliases = optional(list(object({
ip = optional(string, "")
hostnames = optional(list(string), [])
})), [])

init_container = optional(list(object({
name = string
image_repository = optional(string, "")
image_tag = optional(string, "")
image_pull_policy = optional(string, "IfNotPresent")
env_from = optional(any, [])
volume_mount = optional(list(map(any)), [])
command = optional(list(string), [])
args = optional(list(string), [])
working_dir = optional(string)
env = optional(list(map(any)), [])
resource_limits = optional(object({ cpu = optional(string), memory = optional(string) }), null)
resource_requests = optional(object({ cpu = optional(string), memory = optional(string) }), null)
lifecycle = optional(any, [])
})), [])

containers = list(object({
name = string
image_tag = optional(string, "")
image_repository = optional(string, "")
image_pull_policy = optional(string, "IfNotPresent")
env_from = optional(any, [])
volume_mount = optional(list(map(any)), [])
command = optional(list(string), [])
args = optional(list(string), [])
working_dir = optional(string)
env = optional(list(map(any)), [])
resource_limits = optional(object({ cpu = optional(string), memory = optional(string) }), null)
resource_requests = optional(object({ cpu = optional(string), memory = optional(string) }), null)
lifecycle = optional(any, [])
liveness_probe = optional(list(object({
failure_threshold = optional(number)
initial_delay_seconds = optional(number)
period_seconds = optional(number)
success_threshold = optional(number)
timeout_seconds = optional(number)
exec = optional(list(object({
command = optional(list(string))
})), [])
http_get = optional(list(object({
host = optional(string)
path = optional(string)
port = optional(number)
scheme = optional(string)
http_header = optional(list(object({
name = optional(string)
value = optional(string)
})), [])
})), [])
tcp_socket = optional(list(object({
port = optional(number)
})), [])
})), [])
readiness_probe = optional(list(object({
failure_threshold = optional(number)
initial_delay_seconds = optional(number)
period_seconds = optional(number)
success_threshold = optional(number)
timeout_seconds = optional(number)
exec = optional(list(object({
command = optional(list(string))
})), [])
http_get = optional(list(object({
host = optional(string)
path = optional(string)
port = optional(number)
scheme = optional(string)
http_header = optional(list(object({
name = optional(string)
value = optional(string)
})), [])
})), [])
tcp_socket = optional(list(object({
port = optional(number)
})), [])
})), [])
}))

termination_grace_period_seconds = optional(number)

create = optional(bool, true)
create_ecr = optional(bool, false)
ecr_scan_on_push = optional(bool, true)
ecr_encryption_type = optional(string, "KMS")

create_svc = optional(bool, true)
create_svc_monitor = optional(bool, false)
svc_annotations = optional(map(any), {})
svc_labels = optional(map(string), {})
svc_ports = optional(list(object({
name = optional(string)
protocol = optional(string, "TCP")
port = optional(number, 80)
target_port = optional(number)
})), [{ name = "http" }])
svc_type = optional(string, "ClusterIP")
svc_load_balancer_class = optional(string)
svc_monitor_path = optional(string, "/metrics")
})
n/a yes
ecr_allowed_aws_accounts AWS accounts allowed to pull from the created ECR. list(string) [] no
ecr_lifecycle_policy Sets the lifecycle policy of the ECR. If set ecr_number_of_images_to_keep won't work. string "{\n \"rules\": [\n {\n \"rulePriority\": 1,\n \"description\": \"Keep last 50 images (master,main)\",\n \"selection\": {\n \"tagStatus\": \"tagged\",\n \"tagPatternList\": [\n \"master-*\",\n \"main-*\"\n ],\n \"countType\": \"imageCountMoreThan\",\n \"countNumber\": 50\n },\n \"action\": {\n \"type\": \"expire\"\n }\n },\n {\n \"rulePriority\": 2,\n \"description\": \"Keep last 30 images (develop)\",\n \"selection\": {\n \"tagStatus\": \"tagged\",\n \"tagPatternList\": [\n \"develop-*\"\n ],\n \"countType\": \"imageCountMoreThan\",\n \"countNumber\": 30\n },\n \"action\": {\n \"type\": \"expire\"\n }\n },\n {\n \"rulePriority\": 3,\n \"description\": \"Keep last 10 images of the branches images\",\n \"selection\": {\n \"tagStatus\": \"any\",\n \"countType\": \"imageCountMoreThan\",\n \"countNumber\": 10\n },\n \"action\": {\n \"type\": \"expire\"\n }\n }\n ]\n}\n\n" no
image_repository General repository from where to pull container images from. Specific repositories may still be defined on the respective containers. string "" no
strategy_rolling_update Rolling update config params. Present only if type = RollingUpdate. list(any) [] no
strategy_type Type of deployment. Can be 'Recreate' or 'RollingUpdate'. string "RollingUpdate" no

Outputs

Name Description
ecr_repository_url The URL of the ECR repository