Skip to content

Deploy a Memcached

Deploy the Memcached Cluster

Run the memcached deployment Script bin/install-memcached.sh You can include paramaters to deploy aio or base-monitoring. No paramaters deploys base

#!/bin/bash

# Default parameter value
TARGET=${1:-base}

# Directory to check for YAML files
CONFIG_DIR="/etc/genestack/helm-configs/memcached"

# Helm command setup
HELM_CMD="helm upgrade --install memcached oci://registry-1.docker.io/bitnamicharts/memcached \
    --namespace=openstack \
    --timeout 120m \
    --post-renderer /etc/genestack/kustomize/kustomize.sh \
    --post-renderer-args memcached/${TARGET} \
    -f /opt/genestack/base-helm-configs/memcached/memcached-helm-overrides.yaml"

# Check if YAML files exist in the specified directory
if compgen -G "${CONFIG_DIR}/*.yaml" > /dev/null; then
    # Add all YAML files from the directory to the helm command
    for yaml_file in "${CONFIG_DIR}"/*.yaml; do
        HELM_CMD+=" -f ${yaml_file}"
    done
fi

# Run the helm command
echo "Executing Helm command:"
echo "${HELM_CMD}"
eval "${HELM_CMD}"

Note

Memcached has a base configuration which is HA and production ready. If you're deploying on a small cluster the aio configuration may better suit the needs of the environment.

Alternative - Deploy the Memcached Cluster With Monitoring Enabled

Note

Memcached has a base-monitoring configuration which is HA and production ready that also includes a metrics exporter for prometheus metrics collection. If you'd like to have monitoring enabled for your memcached cluster ensure the prometheus operator is installed first (Deploy Prometheus).

View the memcached exporter instructions to install a HA ready memcached cluster with monitoring and metric collection enabled.

Verify readiness with the following command.

kubectl --namespace openstack get horizontalpodautoscaler.autoscaling memcached -w

Create shared os-memcached secret

kubectl --namespace openstack \
        create secret generic os-memcached \
        --type Opaque \
        --from-literal=memcache_secret_key="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)"

Note

This is a shared secret that is distributed to all services that require it. Rotating this value means updating all services.