Skip to content

Terraform Redis module for easy provisioning and management inside Kubernetes

License

Notifications You must be signed in to change notification settings

saturnops/terraform-kubernetes-redis

Repository files navigation

Redis Terraform Module


This module allows users to customize the deployment with various input variables. Users can specify the name and environment of the Redis deployment, the chart and app version, the namespace for the Redis deployment, and whether to enable Grafana monitoring. The module offers options to create a new namespace and configure recovery windows for AWS Secrets Manager, Azure Key Vault, and GCP Secrets Manager. Users can deploy a highly available Redis on AWS EKS, Azure AKS, and GCP GKE Kubernetes clusters with flexible configurations.


This module creates a Redis master and one or more Redis slaves, based on the specified architecture. It sets up Kubernetes services for the Redis master and slave deployments and exposes these services as endpoints for connecting to the Redis database. Users can retrieve these endpoints using the module's outputs.

Supported Versions :

Redis Helm Chart Version K8s supported version (EKS, AKS & GKE)
16.13.2 1.23,1.24,1.25,1.26,1.27

Usage Example

locals {
  name        = "redis"
  region      = "eastus"
  environment = "prod"
  additional_tags = {
    Owner      = "organization_name"
    Expires    = "Never"
    Department = "Engineering"
  }
  create_namespace                 = true
  namespace                        = "redis"
  store_password_to_secret_manager = true
  custom_credentials_enabled       = true
  custom_credentials_config = {
    password = "aajdhgduy3873683dh"
  }
}

module "azure" {
  source                           = "saturnops/redis/kubernetes//modules/resources/azure"
  resource_group_name              = "prod-skaf-rg"
  resource_group_location          = local.region
  environment                      = local.environment
  name                             = local.name
  store_password_to_secret_manager = local.store_password_to_secret_manager
  custom_credentials_enabled       = local.custom_credentials_enabled
  custom_credentials_config        = local.custom_credentials_config
}

module "redis" {
  source           = "saturnops/redis/kubernetes"
  create_namespace = local.create_namespace
  namespace        = local.namespace
  redis_config = {
    name                             = local.name
    values_yaml                      = ""
    environment                      = local.environment
    app_version                      = "6.2.7-debian-11-r11"
    architecture                     = "replication"
    slave_volume_size                = "10Gi"
    master_volume_size               = "10Gi"
    storage_class_name               = "infra-service-sc"
    slave_replica_count              = 2
    store_password_to_secret_manager = local.store_password_to_secret_manager
    secret_provider_type             = "azure"
  }
  grafana_monitoring_enabled = true
  custom_credentials_enabled = local.custom_credentials_enabled
  custom_credentials_config  = local.custom_credentials_config
  redis_password             = local.custom_credentials_enabled ? "" : module.azure.redis_password
}


IAM Permissions

The required IAM permissions to create resources from this module can be found here

Notes

  1. In order to enable the exporter, it is required to deploy Prometheus/Grafana first.
  2. The exporter is a tool that extracts metrics data from an application or system and makes it available to be scraped by Prometheus.
  3. Prometheus is a monitoring system that collects metrics data from various sources, including exporters, and stores it in a time-series database.
  4. Grafana is a data visualization and dashboard tool that works with Prometheus and other data sources to display the collected metrics in a user-friendly way.
  5. To deploy Prometheus/Grafana, please follow the installation instructions for each tool in their respective documentation.
  6. Once Prometheus and Grafana are deployed, the exporter can be configured to scrape metrics data from your application or system and send it to Prometheus.
  7. Finally, you can use Grafana to create custom dashboards and visualize the metrics data collected by Prometheus.
  8. This module is compatible with EKS, AKS & GKE which is great news for users deploying the module on an AWS, Azure & GCP cloud. Review the module's documentation, meet specific configuration requirements, and test thoroughly after deployment to ensure everything works as expected.

Requirements

No requirements.

Providers

Name Version
helm n/a
kubernetes n/a

Modules

No modules.

Resources

Name Type
helm_release.redis resource
kubernetes_namespace.redis resource

Inputs

Name Description Type Default Required
app_version Version of the Redis application that will be deployed. string "6.2.7-debian-11-r11" no
chart_version Version of the chart for the Redis application that will be deployed. string "16.13.2" no
create_namespace Specify whether or not to create the namespace if it does not already exist. Set it to true to create the namespace. string true no
custom_credentials_config Specify the configuration settings for Redis to pass custom credentials during creation. any
{
"password": ""
}
no
custom_credentials_enabled Specifies whether to enable custom credentials for Redis. bool false no
grafana_monitoring_enabled Specify whether or not to deploy Redis exporter to collect Redis metrics for monitoring in Grafana. bool false no
namespace Namespace where the Redis resources will be deployed. string "redis" no
recovery_window_aws_secret Number of days that AWS Secrets Manager will wait before it can delete the secret. The value can be 0 to force deletion without recovery, or a range from 7 to 30 days. number 0 no
redis_config Specify the configuration settings for Redis, including the name, environment, storage options, replication settings, store password to secret manager and custom YAML values. any
{
"architecture": "replication",
"environment": "",
"master_volume_size": "",
"name": "",
"slave_replica_count": 1,
"slave_volume_size": "",
"storage_class_name": "",
"store_password_to_secret_manager": true,
"values_yaml": ""
}
no
redis_password n/a string "" no

Outputs

Name Description
redis_credential Redis credentials used for accessing the database.
redis_endpoints Redis endpoints in the Kubernetes cluster.

Please give our GitHub repository a ⭐️ to show your support and increase its visibility.

About

Terraform Redis module for easy provisioning and management inside Kubernetes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages