Installation
This guide covers installing the Memcached Operator on a Kubernetes cluster, verifying the deployment, and creating your first Memcached instance.
Prerequisites
Cluster Requirements
- Kubernetes v1.28 or later
- kubectl configured to communicate with your cluster
- cert-manager installed (required for webhook TLS certificate provisioning)
- Prometheus Operator CRDs installed (optional, required only if you plan to use
ServiceMonitorresources for monitoring)
Install cert-manager
If cert-manager is not yet installed on your cluster, install it before deploying the operator:
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml
kubectl wait --for=condition=Available deployment --all -n cert-manager --timeout=120sInstall Prometheus Operator CRDs (optional)
If you plan to use ServiceMonitor resources for Prometheus-based monitoring, install the Prometheus Operator CRDs:
kubectl apply -f https://github.com/prometheus-operator/prometheus-operator/releases/latest/download/stripped-down-crds.yamlVerify prerequisites
# Check Kubernetes version
kubectl version
# Verify cert-manager is running
kubectl get pods -n cert-manager
# Check if Prometheus Operator CRDs are available (optional)
kubectl get crd servicemonitors.monitoring.coreos.comLocal Development Requirements
If you plan to build the operator from source or run it locally, you also need:
- Go 1.25 or later
- Docker or Podman (for building container images)
- kind or minikube (for local Kubernetes clusters)
- Operator SDK v1.42 or later (optional, for scaffolding changes)
Install CRDs
Before deploying the operator, install the Memcached Custom Resource Definition into your cluster. Choose one of the following methods:
Option A: From a GitHub Release (recommended)
Apply the CRD manifest directly from a GitHub Release:
kubectl apply -f https://github.com/c5c3/memcached-operator/releases/download/v0.2.0/memcached.c5c3.io_memcacheds.yamlReplace v0.2.0 with the desired version. Available releases are listed at github.com/c5c3/memcached-operator/releases.
Option B: From source
If you have the repository cloned, use the Makefile target:
make installVerify CRD installation
kubectl get crd memcacheds.memcached.c5c3.ioExpected output:
NAME CREATED AT
memcacheds.memcached.c5c3.io 2025-01-15T10:00:00ZDeploy the Operator
Option A: Helm Chart from OCI Registry (recommended)
Install the operator using Helm from the GHCR OCI registry:
helm install memcached-operator oci://ghcr.io/c5c3/charts/memcached-operator \
--version 0.2.0 \
--namespace memcached-operator-system \
--create-namespaceReplace 0.2.0 with the desired chart version. Override default values with --set or a values file:
helm install memcached-operator oci://ghcr.io/c5c3/charts/memcached-operator \
--version 0.2.0 \
--namespace memcached-operator-system \
--create-namespace \
--set serviceMonitor.enabled=trueSee the chart README for the full list of configurable values.
Option B: From a GitHub Release
Each release includes a ready-to-use install.yaml that contains all resources (CRDs, RBAC, Deployment, webhooks, cert-manager resources) in a single file:
kubectl apply -f https://github.com/c5c3/memcached-operator/releases/download/v0.2.0/install.yamlReplace v0.2.0 with the desired version. Available releases are listed at github.com/c5c3/memcached-operator/releases.
Option C: From source
If you have the repository cloned, you can deploy using the Makefile:
make deploy IMG=ghcr.io/c5c3/memcached-operator:v0.2.0Replace v0.2.0 with the desired version tag. This builds the full manifest from config/default/ using Kustomize and applies it to the cluster.
All options install the following resources under the memcached-operator-system namespace with the memcached-operator- name prefix:
- CRD definitions
- RBAC resources: ClusterRole, ClusterRoleBinding, ServiceAccount
- Operator Deployment with the controller manager
- Webhook configurations (MutatingWebhookConfiguration, ValidatingWebhookConfiguration)
- cert-manager Certificate and Issuer for webhook TLS
Verify the Installation
After deploying, verify that all components are running correctly.
Check the operator pod
kubectl get pods -n memcached-operator-systemExpected output:
NAME READY STATUS RESTARTS AGE
memcached-operator-controller-manager-5b8f4c7d9f-x2k4l 1/1 Running 0 30sWait until the pod status shows Running and READY is 1/1.
Check the CRD
kubectl get crd memcacheds.memcached.c5c3.ioCheck webhook configurations
kubectl get mutatingwebhookconfigurations,validatingwebhookconfigurations | grep memcachedExpected output:
mutatingwebhookconfiguration.admissionregistration.k8s.io/memcached-operator-mutating-webhook-configuration 1 30s
validatingwebhookconfiguration.admissionregistration.k8s.io/memcached-operator-validating-webhook-configuration 1 30sCheck operator logs
kubectl logs -n memcached-operator-system deployment/memcached-operator-controller-managerLook for successful startup messages and confirm there are no error-level log entries. The operator exposes health probes on port 8081 (/healthz and /readyz) and serves metrics on port 8443 (/metrics).
Create Your First Memcached Instance
Once the operator is running, create a Memcached instance by applying a custom resource.
Minimal example
Create a file named memcached.yaml:
apiVersion: memcached.c5c3.io/v1alpha1
kind: Memcached
metadata:
name: my-cache
namespace: default
spec:
replicas: 3
image: "memcached:1.6"
memcached:
maxMemoryMB: 64Apply it:
kubectl apply -f memcached.yamlVerify the instance
Check the Memcached custom resource:
kubectl get memcached my-cacheCheck the managed Deployment and pods:
kubectl get deployment my-cache
kubectl get pods -l app.kubernetes.io/instance=my-cacheCheck the headless Service:
kubectl get service my-cacheInspect the full status, including conditions and metrics:
kubectl get memcached my-cache -o yamlA healthy instance shows Available: True and Degraded: False in its status conditions.
Test the connection
Run a temporary pod to verify the Memcached instance is reachable:
kubectl run memcached-test --image=busybox:1.36 --rm -it --restart=Never -- \
sh -c 'echo "stats" | nc my-cache 11211'You should see Memcached statistics output including STAT pid, STAT uptime, etc. This confirms the cache is running and accepting connections.
To set and retrieve a value:
kubectl run memcached-test --image=busybox:1.36 --rm -it --restart=Never -- \
sh -c 'printf "set hello 0 60 5\r\nworld\r\nget hello\r\nquit\r\n" | nc my-cache 11211'Expected output:
STORED
VALUE hello 0 5
world
ENDDelete the instance
To remove the Memcached instance and all its managed resources (Deployment, Service, PDB, etc.):
kubectl delete memcached my-cacheThe operator automatically cleans up all owned resources via Kubernetes owner references.
More examples
For advanced configurations including high availability, monitoring, TLS, SASL authentication, and NetworkPolicies, see the Examples guide.
Local Development Setup
For developing and testing the operator locally without deploying it to a cluster:
1. Install CRDs
make install2. Run the operator locally
The operator runs on your machine and connects to the cluster configured in your current kubeconfig context:
make runThis compiles and runs the operator binary directly. Webhooks are not active in this mode because they require TLS certificates provisioned by cert-manager inside the cluster.
3. Apply a sample CR
In a separate terminal:
kubectl apply -f config/samples/memcached_v1alpha1_memcached.yaml4. Observe reconciliation
Watch the operator logs in the first terminal and verify that managed resources are created:
kubectl get deployment,service,pdb -l app.kubernetes.io/managed-by=memcached-operatorUninstallation
Remove all operator resources
If you installed via Helm:
helm uninstall memcached-operator --namespace memcached-operator-systemIf you installed via the release manifest:
kubectl delete -f https://github.com/c5c3/memcached-operator/releases/download/v0.2.0/install.yamlIf you installed from source:
make undeployAll commands remove operator resources including the memcached-operator-system namespace.
Warning: Removing the CRDs also deletes all Memcached custom resources and their managed workloads (Deployments, Services, PDBs, etc.) across all namespaces. Back up your Memcached CRs before proceeding if you need to preserve their definitions.
Remove only CRDs
To remove just the CRDs without removing the operator:
make uninstall