Skip to content

ION-Analytics/terraform-iona-eks-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Kubernetes EKS Service Module

This Terraform module deploys a Kubernetes Deployment and Service on an EKS cluster.

Resources Created

  • Kubernetes Deployment: Manages pods with configurable replicas, container specs, resource limits, and health probes
  • Kubernetes Service: Exposes the deployment with configurable service type (ClusterIP, NodePort, LoadBalancer)

Features

  • Configurable replica count
  • Resource limits and requests (CPU/Memory)
  • Environment variables support
  • Liveness and readiness probes
  • Image pull secrets support
  • Customizable labels and selectors
  • Multiple service types supported

Usage

module "eks_service" {
  source = "./modules/terraform-iona-eks-service"

  # Namespace
  namespace = "production"

  # Deployment Configuration
  deployment_name  = "my-app"
  replicas         = 3
  
  # Container Configuration
  container_name   = "my-app-container"
  container_image  = "my-registry/my-app:v1.0.0"
  container_port   = 8080

  # Resource Limits
  cpu_limit      = "1000m"
  memory_limit   = "1Gi"
  cpu_request    = "500m"
  memory_request = "512Mi"

  # Environment Variables
  environment_variables = {
    ENV           = "production"
    LOG_LEVEL     = "info"
    DATABASE_HOST = "db.example.com"
  }

  # Health Probes
  liveness_probe_path           = "/health/live"
  liveness_probe_initial_delay  = 30
  readiness_probe_path          = "/health/ready"
  readiness_probe_initial_delay = 10

  # Service Configuration
  service_name = "my-app-service"
  service_type = "ClusterIP"
  port         = 80
  target_port  = 8080

  # Labels and Selectors
  labels = {
    app     = "my-app"
    env     = "production"
    team    = "platform"
  }

  selector = {
    app = "my-app"
  }

  # Image Pull Secrets (optional)
  image_pull_secrets = ["my-registry-secret"]
}

Inputs

Name Description Type Default Required
namespace Kubernetes namespace string "default" no
deployment_name Name of the deployment string - yes
replicas Number of pod replicas number 2 no
container_name Name of the container string - yes
container_image Container image string - yes
container_port Container port number - yes
cpu_limit CPU limit string "500m" no
memory_limit Memory limit string "512Mi" no
cpu_request CPU request string "250m" no
memory_request Memory request string "256Mi" no
environment_variables Environment variables map(string) {} no
liveness_probe_path Liveness probe HTTP path string "/healthz" no
liveness_probe_initial_delay Liveness probe initial delay number 30 no
liveness_probe_period Liveness probe period number 10 no
readiness_probe_path Readiness probe HTTP path string "/ready" no
readiness_probe_initial_delay Readiness probe initial delay number 10 no
readiness_probe_period Readiness probe period number 5 no
image_pull_secrets Image pull secrets list(string) [] no
service_name Name of the service string - yes
service_type Service type string "ClusterIP" no
port Service port number - yes
target_port Target port number - yes
protocol Service protocol string "TCP" no
labels Resource labels map(string) {} no
selector Pod selector labels map(string) - yes

Outputs

Name Description
deployment_name Name of the deployment
service_name Name of the service
namespace Namespace where resources are deployed
service_cluster_ip Cluster IP of the service
deployment_replicas Number of replicas

Requirements

  • Terraform >= 1.0
  • Kubernetes provider >= 2.0

Notes

  • The selector labels must match between the deployment and service
  • Health probes are configured for HTTP endpoints by default
  • Resource limits should be adjusted based on your application's needs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages