redis-cluster

by Helm

Helm chartv0.0.2App 5.0.6

Highly available Kubernetes implementation of Redis Cluster

About this chart

Redis

Redis is an advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.

TL;DR;

$ helm repo add inspur https://inspur-iop.github.io/charts
$ helm install inspur/redis-cluster

Introduction

This chart bootstraps a Redis highly available distributed cluster in a Kubernetes cluster using the Helm package manager.

Prerequisites

  • Kubernetes 1.8+ with Beta APIs enabled
  • PV provisioner support in the underlying infrastructure

Installing the Chart

To install the chart

$ helm repo add inspur https://inspur-iop.github.io/charts
$ helm install inspur/redis-cluster

The command deploys Redis Cluster on the Kubernetes cluster in the default configuration. By default this chart install 3 shards and one replica for each shard. The configuration section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the deployment:

$ helm delete <chart-name>

The command removes all the Kubernetes components associated with the chart and deletes the release.

Note

By default this chart install 3 shards and one replica for each shard:

  • In this chart, one statefulset means one shard (include master and replicas), the statefulset would be dynamic created when shard number changes.
  • The shard number must be equal or greater than 3, or the cluter will create failed.
  • By now, the chart support scale-out (add shards), but the data in cluster won't resharding automatically. You must reshard the data manually.
  • If you want to scale-in the cluster, you must reshard the data and remove the node from cluster carefully first, then run helm upgrade command to decrease the shard number.

Configuration

The following table lists the configurable parameters of the Redis chart and their default values.

ParameterDescriptionDefault
image.nameRedis imageredis
image.tagRedis image tag5.0.7-alpine
image.pullPolicyRedis image pullPolicyAlways
shardsShards of Redis Cluster, must be equal or greater than 33
shardReplicasReplicas of each shard1
labelsCustom labels for the redis pod{}
redis.portPort to access the redis service6379
redis.customConfigAllows for custom redis.conf files to be applied.``
redis.resourcesCPU/Memory for redis server resource requests/limits{}
authConfigures redis with AUTH (redisPassword to be set)``
nodeSelectorNode labels for pod assignment{}
tolerationsToleration labels for pod assignment[]
hardAntiAffinityWhether the Redis server pods in one shard should be forced to run on separate nodes.false
persistentVolume.storageClassType of persistent volume claim-
persistentVolume.accessModesReadWriteOnce or ReadOnlyReadWriteOnce
persistentVolume.sizeSize of persistent volume claim1Gi
persistentVolume.annotationsAnnotations of persistent volume claim{}
sysctl.enabledEnable an init container to modify Kernel settingsfalse
sysctl.commandsysctl command to execute[]
sysctl.imagesysctl Init container image namebusybox
sysctl.tagsysctlImage Init container image tag1.31.1
sysctl.pullPolicysysctlImage Init container image pull policyAlways
sysctl.mountHostSysWhether Mount the host /sys folder to /host-sysfalse

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

$ helm install \
  --set image=redis \
  --set tag=5.0.6 \
    incubator/redis-cluster

The above command sets the Redis server within default namespace.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

$ helm install -f values.yaml stable/redis-cluster

Tip: You can use the default values.yaml

Custom Redis options

This chart allows for most redis or sentinel config options to be passed as a key value pair through the values.yaml under redis.customConfig. See links below for all available options.

Example redis.conf

For example repl-timeout 60 would be added to the redis.customConfig section of the values.yaml as:

redis:
  customConfig: |
    repl-timeout 60

Host Kernel Settings

Redis may require some changes in the kernel of the host machine to work as expected, in particular increasing the somaxconn value and disabling transparent huge pages. To do so, you can set up a privileged initContainer with the sysctl config values, for example:

sysctl:
  enabled: true
  image: library/busybox
  tag: 1.31.1
  mountHostSys: true
  command:
    - /bin/sh
    - -xc
    - |-
      sysctl -w net.core.somaxconn=10000
      echo never > /host-sys/kernel/mm/transparent_hugepage/enabled

Deploy redis-cluster with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has redis-cluster on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartredis-cluster is pinned at v0.0.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply