Giter Site home page Giter Site logo

terraform-oci-cloudbricks-redis's Introduction

OCI Cloud Bricks: Redis

License: UPL Quality gate

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

Reference Architecture

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 and ssh_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 between 1-30, however a minimum of 3 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 and replica_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 and replica_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 between 50 and 32768.
  • Variable master_disk_vpus_per_gb and replica_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 between 0 and 120 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 variables redis_master_ocpus and redis_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 variables redis_replica_ocpus and redis_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.

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

Name Type
null_resource.format_disk_exec_redis_master resource
null_resource.format_disk_exec_redis_replica resource
null_resource.master_install_redis_binaries resource
null_resource.mount_disk_exec_redis_master resource
null_resource.mount_disk_exec_redis_replica resource
null_resource.partition_disk_redis_master resource
null_resource.partition_disk_redis_replica resource
null_resource.provisioning_disk_redis_master resource
null_resource.provisioning_disk_redis_replica resource
null_resource.pvcreate_exec_redis_master resource
null_resource.pvcreate_exec_redis_replica resource
null_resource.redis_setup_master resource
null_resource.redis_setup_replicas resource
null_resource.replica_install_redis_binaries resource
null_resource.sentinel_setup_master resource
null_resource.sentinel_setup_replicas resource
null_resource.vgcreate_exec_redis_master resource
null_resource.vgcreate_exec_redis_replica resource
oci_core_instance.redis_master resource
oci_core_instance.redis_replica resource
oci_core_volume.ISCSIDisk_redis_master resource
oci_core_volume.ISCSIDisk_redis_replica resource
oci_core_volume_attachment.ISCSIDiskAttachment_redis_master resource
oci_core_volume_attachment.ISCSIDiskAttachment_redis_replica resource
oci_core_volume_backup_policy_assignment.backup_policy_assignment_ISCSI_Disk_redis_master resource
oci_core_volume_backup_policy_assignment.backup_policy_assignment_ISCSI_Disk_redis_replica resource
oci_core_volume_backup_policy_assignment.backup_policy_assignment_redis_master resource
oci_core_volume_backup_policy_assignment.backup_policy_assignment_redis_replica resource
oci_core_images.ORACLELINUX data source
oci_core_network_security_groups.NSG data source
oci_core_subnets.PRIVATESUBNET data source
oci_core_vcns.VCN data source
oci_core_volume_backup_policies.INSTANCEBACKUPPOLICY data source
oci_core_volume_backup_policies.MASTERBACKUPPOLICY data source
oci_core_volume_backup_policies.REPLICABACKUPPOLICY data source
oci_identity_compartments.COMPARTMENTS data source
oci_identity_compartments.NWCOMPARTMENTS data source
template_file.install_redis_binaries_sh data source
template_file.redis_setup_master_sh data source
template_file.redis_setup_replicas_sh data source

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.

terraform-oci-cloudbricks-redis's People

Contributors

dralquinta avatar matt-mcl avatar timclegg avatar ttscoff avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

terraform-oci-cloudbricks-redis's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.