OCI Cloud Bricks: Redis
Introduction
The following brick contains the logic to provision a Redis database caluster in a highly available architecture. This is compromised of a master server and any number of replicas.
This brick is only supported on Oracle Linux for the time being.
Reference Architecture
The following is the reference architecture associated to this brick
Prerequisites
- Pre-baked Artifact and Network Compartments
- Pre-baked VCN
Sample tfvar file
If using Fixes Shapes.
######################################## COMMON VARIABLES ######################################
region = "re-region-1"
tenancy_ocid = "ocid1.tenancy.oc1..aaaaaaaabcedfghijklmonoprstuvwxyz"
user_ocid = "ocid1.user.oc1..aaaaaaaabcedfghijklmonoprstuvwxyz"
fingerprint = "fo:oo:ba:ar:ba:ar"
private_key_path = "/absolute/path/to/api/key/your_api_key.pem"
######################################## COMMON VARIABLES ######################################
######################################## ARTIFACT SPECIFIC VARIABLES ######################################
ssh_public_key = "/absolute/path/to/api/key/your_ssh_public_key.pub"
ssh_private_key = "/absolute/path/to/api/key/your_ssh_private_key"
compute_nsg_name = "MY_NSG"
linux_compute_instance_compartment_name = "MY_ARTIFACT_COMPARTMENT"
linux_compute_network_compartment_name = "MY_NETWORK_COMPARTMENT"
private_network_subnet_name = "MY_PRIVATE_SUBNET"
vcn_display_name = "MY_VCN"
redis_master_name = "MY_REDIS_MASTER_NAME"
redis_master_shape = "VM.Standard2.1"
redis_master_ad = "aBCD:RE-REGION-1-AD-1"
redis_master_fd = "FAULT-DOMAIN-1"
redis_replica_name = "MY_REDIS_REPLICA_NAME"
redis_replica_count = "3"
redis_replica_shape = "VM.Standard2.1"
redis_replica_ad_list = ["oDQF:UK-LONDON-1-AD-1", "oDQF:UK-LONDON-1-AD-2", "oDQF:UK-LONDON-1-AD-3"]
redis_replica_fd_list = ["FAULT-DOMAIN-1", "FAULT-DOMAIN-2", "FAULT-DOMAIN-3"]
redis_version = "6.2.5"
instance_backup_policy_level = "bronze"
master_disk_size_in_gb = "50"
master_disk_vpus_per_gb = "10"
master_backup_policy_level = "bronze"
replica_disk_size_in_gb = "50"
replica_disk_vpus_per_gb = "10"
replica_backup_policy_level = "bronze"
######################################## ARTIFACT SPECIFIC VARIABLES ######################################
If using Flex Shapes.
######################################## COMMON VARIABLES ######################################
region = "re-region-1"
tenancy_ocid = "ocid1.tenancy.oc1..aaaaaaaabcedfghijklmonoprstuvwxyz"
user_ocid = "ocid1.user.oc1..aaaaaaaabcedfghijklmonoprstuvwxyz"
fingerprint = "fo:oo:ba:ar:ba:ar"
private_key_path = "/absolute/path/to/api/key/your_api_key.pem"
######################################## COMMON VARIABLES ######################################
######################################## ARTIFACT SPECIFIC VARIABLES ######################################
ssh_public_key = "/absolute/path/to/api/key/your_ssh_public_key.pub"
ssh_private_key = "/absolute/path/to/api/key/your_ssh_private_key"
compute_nsg_name = "MY_NSG"
linux_compute_instance_compartment_name = "MY_ARTIFACT_COMPARTMENT"
linux_compute_network_compartment_name = "MY_NETWORK_COMPARTMENT"
private_network_subnet_name = "MY_PRIVATE_SUBNET"
vcn_display_name = "MY_VCN"
redis_master_name = "MY_REDIS_MASTER_NAME"
redis_master_shape = "VM.Standard.E4.Flex"
redis_master_ad = "aBCD:RE-REGION-1-AD-1"
redis_master_fd = "FAULT-DOMAIN-1"
redis_master_is_flex_shape = true
redis_master_ocpus = "1"
redis_master_memory_in_gb = "16"
redis_replica_name = "MY_REDIS_REPLICA_NAME"
redis_replica_count = "3"
redis_replica_shape = "VM.Standard.E4.Flex"
redis_replica_ad_list = ["oDQF:UK-LONDON-1-AD-1", "oDQF:UK-LONDON-1-AD-2", "oDQF:UK-LONDON-1-AD-3"]
redis_replica_fd_list = ["FAULT-DOMAIN-1", "FAULT-DOMAIN-2", "FAULT-DOMAIN-3"]
redis_replica_is_flex_shape = true
redis_replica_memory_in_gb = "1"
redis_replica_ocpus = "16"
redis_version = "6.2.5"
instance_backup_policy_level = "bronze"
master_disk_size_in_gb = "50"
master_disk_vpus_per_gb = "10"
master_backup_policy_level = "bronze"
replica_disk_size_in_gb = "50"
replica_disk_vpus_per_gb = "10"
replica_backup_policy_level = "bronze"
######################################## ARTIFACT SPECIFIC VARIABLES ######################################
Variable Specific Conisderions
- Compute ssh keys to later log into instances. Paths to the keys should be provided in variables
ssh_public_key
andssh_private_key
. - Variable
compute_nsg_name
is an optional network security group that can be attached. - Variable
redis_version
may be set to any of the supported version of Redis at the time of creating this brick(6.2.6, 6.0.16, 5.0.14)
Source: Redis endoflife - Variable
redis_replica_count
determines how many replica instance are provisioned. This value has been tested between1-30
, however a minimum of3
is recommended. - Variable
instance_backup_policy_level
specifies the name of the backup policy used on the instance boot volumes. - Variables
master_backup_policy_level
andreplica_backup_policy_level
specificy the name of the backup policy used on the ISCSI disks storing data and log files on the master and replica servers respectively. - Variables
master_disk_size_in_gb
andreplica_disk_size_in_gb
specify the size of the ISCSI disks in GB used to store data and log files on the master and replica servers respectively. This can be between50
and32768
. - Variable
master_disk_vpus_per_gb
andreplica_disk_vpus_per_gb
specify the VPUs per GB of the ISCSI disks used to store data and log files on the master and replica servers respectively. The value must be between0
and120
and be multiple of 10. - Flex Shapes:
- Variable
redis_master_is_flex_shape
should be defined as true when the master instance is a flex shape. The variablesredis_master_ocpus
andredis_master_memory_in_gb
should then also be defined. Do not use any of these variables at all when using a standard shape as they are not needed and assume sensible defaults. - Variable
redis_replica_is_flex_shape
should be defined as true when the replica instances are a flex shape. The variablesredis_replica_ocpus
andredis_replica_memory_in_gb
should then also be defined. Do not use any of these variables at all when using a standard shape as they are not needed and assume sensible defaults.
- Variable
Sample provider
The following is the base provider definition to be used with this module
terraform {
required_version = ">= 0.13.5"
}
provider "oci" {
region = var.region
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
disable_auto_retries = "true"
}
provider "oci" {
alias = "home"
region = data.oci_identity_region_subscriptions.home_region_subscriptions.region_subscriptions[0].region_name
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
disable_auto_retries = "true"
}
Variable documentation
Requirements
Name | Version |
---|---|
terraform | >= 0.13.5 |
oci | >= 4.36.0 |
Providers
Name | Version |
---|---|
null | 3.1.0 |
oci | 4.45.0 |
template | 2.2.0 |
Modules
No modules.
Resources
Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
compute_nsg_name | Name of the NSG associated to the computes | string |
"" |
no |
fingerprint | API Key Fingerprint for user_ocid derived from public API Key imported in OCI User config | any |
n/a | yes |
instance_backup_policy_level | The backup policy of all instances boot volumes | any |
n/a | yes |
linux_compute_instance_compartment_name | Defines the compartment name where the infrastructure will be created | any |
n/a | yes |
linux_compute_network_compartment_name | Defines the compartment where the Network is currently located | any |
n/a | yes |
master_backup_policy_level | The backup policy of the master instance ISCSI disk | any |
n/a | yes |
master_disk_size_in_gb | The size of the attached disk to the master instance, stores database and log data | any |
n/a | yes |
master_disk_vpus_per_gb | The VPUS of the attached disk to the master instance | any |
n/a | yes |
private_key_path | Private Key Absolute path location where terraform is executed | any |
n/a | yes |
private_network_subnet_name | Defines the subnet display name where this resource will be created at | any |
n/a | yes |
redis_master_ad | The availability domain to provision the master instance in | any |
n/a | yes |
redis_master_fd | The fault domain to provision the master instance in | any |
n/a | yes |
redis_master_is_flex_shape | Boolean to determine if the master instance is flex or not | bool |
false |
no |
redis_master_memory_in_gb | The amount of memory in GB for the master instance to use when flex shape is enabled | string |
"" |
no |
redis_master_name | The name given to the master instance | any |
n/a | yes |
redis_master_ocpus | The number of OCPUS for the master instance to use when flex shape is enabled | string |
"" |
no |
redis_master_shape | The shape for the master instance to use | any |
n/a | yes |
redis_replica_ad_list | The availability domains to provision the replica instances in | any |
n/a | yes |
redis_replica_count | The number of replica instances to provision | number |
n/a | yes |
redis_replica_fd_list | The fault domains to provision the replica instances in | any |
n/a | yes |
redis_replica_is_flex_shape | Boolean to determine if the replica instances are flex or not | bool |
false |
no |
redis_replica_memory_in_gb | The amount of memory in GB for the replica instances to use when flex shape is enabled | string |
"" |
no |
redis_replica_name | The name given to the replica instances | any |
n/a | yes |
redis_replica_ocpus | The number of OCPUS for the replica instances to use when flex shape is enabled | string |
"" |
no |
redis_replica_shape | The shape for the replica instances to use | any |
n/a | yes |
redis_version | The version of Redis used in the setup | any |
n/a | yes |
region | Target region where artifacts are going to be created | any |
n/a | yes |
replica_backup_policy_level | The backup policy of replica instances ISCSI disks | any |
n/a | yes |
replica_disk_size_in_gb | The size of the attached disk to the replica instances, stores database and log data | any |
n/a | yes |
replica_disk_vpus_per_gb | The VPUS of the attached disk to the replica instances | any |
n/a | yes |
ssh_private_key | Defines SSH Private Key to be used in order to remotely connect to compute instances | any |
n/a | yes |
ssh_public_key | Defines SSH Public Key to be used in order to remotely connect to compute instances | any |
n/a | yes |
tenancy_ocid | OCID of tenancy | any |
n/a | yes |
user_ocid | User OCID in tenancy. Currently hardcoded to user [email protected] | any |
n/a | yes |
vcn_display_name | VCN Display name to execute lookup | any |
n/a | yes |
Outputs
Name | Description |
---|---|
redis_master_server | Redis Master Instance |
redis_replica_servers | Redis Replica Instances |
Contributing
This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open source community.
License
Copyright (c) 2021 Oracle and/or its affiliates.
Licensed under the Universal Permissive License (UPL), Version 1.0.
See LICENSE for more details.