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
# shellcheck disable=SC2124,SC2145,SC2294

GLOBAL_OVERRIDES_DIR="/etc/genestack/helm-configs/global_overrides"
SERVICE_CONFIG_DIR="/etc/genestack/helm-configs/memcached"
BASE_OVERRIDES="/opt/genestack/base-helm-configs/memcached/memcached-helm-overrides.yaml"

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/overlay"

HELM_CMD+=" -f ${BASE_OVERRIDES}"

for dir in "$GLOBAL_OVERRIDES_DIR" "$SERVICE_CONFIG_DIR"; do
    if compgen -G "${dir}/*.yaml" > /dev/null; then
        for yaml_file in "${dir}"/*.yaml; do
            # Avoid re-adding the base override file if present in the service directory
            if [ "${yaml_file}" != "${BASE_OVERRIDES}" ]; then
                HELM_CMD+=" -f ${yaml_file}"
            fi
        done
    fi
done

HELM_CMD+=" $@"

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

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.

Genestack

For more information on how to enable memcached monitoring with prometheus, see the memcached exporter documentation.