Skip to content

Memcached CRD Types Reference ​

API reference for the memcached.c5c3.io/v1alpha1 Custom Resource Definition types.

Source: api/v1alpha1/memcached_types.go

Memcached ​

Top-level custom resource representing a Memcached cluster.

Group: memcached.c5c3.ioVersion: v1alpha1Kind: MemcachedScope: Namespaced

Printer Columns ​

ColumnTypeJSONPathDescription
Replicasinteger.spec.replicasNumber of desired Memcached pods
Readyinteger.status.readyReplicasNumber of ready Memcached pods
Agedate.metadata.creationTimestampResource creation timestamp

Subresources ​

  • status: Enabled. Status updates use the /status subresource endpoint.

MemcachedSpec ​

Defines the desired state of a Memcached cluster.

FieldTypeRequiredDefaultValidationDescription
replicas*int32No1Minimum: 0, Maximum: 64Number of Memcached pods
image*stringNo"memcached:1.6"—Container image for the Memcached server
resources*corev1.ResourceRequirementsNo——Resource requests and limits for the container
memcached*MemcachedConfigNo——Memcached server configuration parameters
highAvailability*HighAvailabilitySpecNo——High-availability settings
monitoring*MonitoringSpecNo——Monitoring and metrics configuration
security*SecuritySpecNo——Security settings
autoscaling*AutoscalingSpecNo——Horizontal pod autoscaling configuration

MemcachedConfig ​

Defines Memcached server runtime parameters. These are translated into memcached command-line flags by the reconciler.

FieldTypeRequiredDefaultValidationDescription
maxMemoryMBint32No64Minimum: 16, Maximum: 65536Maximum memory for item storage in MB (-m flag)
maxConnectionsint32No1024Minimum: 1, Maximum: 65536Maximum simultaneous connections (-c flag)
threadsint32No4Minimum: 1, Maximum: 128Number of worker threads (-t flag)
maxItemSizestringNo"1m"Pattern: ^[0-9]+(k|m)$Maximum size of a single item (-I flag, e.g. "1m", "512k")
verbosityint32No0Minimum: 0, Maximum: 2Logging verbosity (0=none, 1=-v, 2=-vv)
extraArgs[]stringNo——Additional command-line arguments passed to memcached

HighAvailabilitySpec ​

Defines high-availability settings for Memcached pods, including anti-affinity, topology spread, and pod disruption budgets.

FieldTypeRequiredDefaultValidationDescription
antiAffinityPreset*AntiAffinityPresetNo"soft"Enum: soft, hardPod anti-affinity scheduling mode
topologySpreadConstraints[]corev1.TopologySpreadConstraintNo——Topology domain spread constraints for pods
podDisruptionBudget*PDBSpecNo——PodDisruptionBudget configuration

AntiAffinityPreset ​

String enum type controlling pod anti-affinity behavior.

ValueDescription
softUses preferredDuringSchedulingIgnoredDuringExecution
hardUses requiredDuringSchedulingIgnoredDuringExecution

PDBSpec ​

Defines PodDisruptionBudget configuration for Memcached pods.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalse—Whether a PodDisruptionBudget is created
minAvailable*intstr.IntOrStringNo1—Minimum available pods during disruption (absolute or %)
maxUnavailable*intstr.IntOrStringNo——Maximum unavailable pods during disruption (absolute or %)

MonitoringSpec ​

Defines monitoring and metrics collection configuration, including the memcached-exporter sidecar and Prometheus ServiceMonitor.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalse—Enables the memcached-exporter sidecar
exporterImage*stringNo"prom/memcached-exporter:v0.15.4"—Container image for the exporter sidecar
exporterResources*corev1.ResourceRequirementsNo——Resource requests/limits for the exporter sidecar
serviceMonitor*ServiceMonitorSpecNo——Prometheus ServiceMonitor configuration

ServiceMonitorSpec ​

Defines Prometheus ServiceMonitor resource configuration.

FieldTypeRequiredDefaultValidationDescription
additionalLabelsmap[string]stringNo——Extra labels added to the ServiceMonitor resource
intervalstringNo"30s"—Prometheus scrape interval (e.g. "30s")
scrapeTimeoutstringNo"10s"—Prometheus scrape timeout (e.g. "10s")

SecuritySpec ​

Defines security settings for Memcached pods, including pod/container security contexts, authentication, and encryption.

FieldTypeRequiredDefaultValidationDescription
podSecurityContext*corev1.PodSecurityContextNo——Security context for the Memcached pod
containerSecurityContext*corev1.SecurityContextNo——Security context for the Memcached container
sasl*SASLSpecNo——SASL authentication configuration
tls*TLSSpecNo——TLS encryption configuration

SASLSpec ​

Defines SASL authentication configuration for Memcached.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalse—Whether SASL authentication is active
credentialsSecretRefcorev1.LocalObjectReferenceNo——Reference to the Secret containing a password-file key with SASL credentials

TLSSpec ​

Defines TLS encryption configuration for Memcached.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalse—Whether TLS encryption is active
certificateSecretRefcorev1.LocalObjectReferenceNo——Reference to the Secret containing tls.crt, tls.key, and optionally ca.crt

AutoscalingSpec ​

Defines horizontal pod autoscaling configuration for Memcached. When enabled is true, the operator creates an HPA resource targeting the Memcached StatefulSet. The StatefulSet keeps the replica count the HPA sets, and a new StatefulSet starts at minReplicas, or 1 when minReplicas is nil.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalse—Controls whether horizontal pod autoscaling is active
minReplicas*int32No—Minimum: 1Lower limit for the number of replicas. When nil, the HPA default (1) is used
maxReplicasint32Yes—Minimum: 1Upper limit for the number of replicas
metrics[]autoscalingv2.MetricSpecNo——Specifications for calculating desired replica count. When empty and autoscaling is enabled, the defaulting webhook injects a CPU utilization metric targeting 80%
behavior*autoscalingv2.HorizontalPodAutoscalerBehaviorNo——Scaling behavior in both Up and Down directions. When nil and autoscaling is enabled, the defaulting webhook injects a scaleDown stabilization window of 300 seconds

MemcachedStatus ​

Defines the observed state of a Memcached cluster, updated by the reconciler via the status subresource.

FieldTypeRequiredDescription
conditions[]metav1.ConditionNoStandard conditions with merge patch strategy (key: type)
readyReplicasint32NoNumber of Memcached pods in Ready state
observedGenerationint64NoMost recent .metadata.generation observed by the controller
serverList[]stringNoOne host:port entry per pod, <statefulset>-<i>.<service>.<namespace>.svc:11211, ordered by pod index i. It follows the StatefulSet's replica count, not pod readiness, and is empty when the instance has zero replicas

Full Example ​

A fully-specified Memcached CR demonstrating all available fields:

yaml
apiVersion: memcached.c5c3.io/v1alpha1
kind: Memcached
metadata:
  name: memcached-production
  namespace: cache
spec:
  replicas: 3
  image: "memcached:1.6"
  resources:
    requests:
      cpu: "100m"
      memory: "128Mi"
    limits:
      cpu: "500m"
      memory: "256Mi"
  memcached:
    maxMemoryMB: 128
    maxConnections: 2048
    threads: 4
    maxItemSize: "2m"
    verbosity: 0
    extraArgs:
      - "-o"
      - "modern"
  highAvailability:
    antiAffinityPreset: "soft"
    topologySpreadConstraints:
      - maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
        labelSelector:
          matchLabels:
            app.kubernetes.io/name: memcached-production
    podDisruptionBudget:
      enabled: true
      minAvailable: 2
  monitoring:
    enabled: true
    exporterImage: "prom/memcached-exporter:v0.15.4"
    exporterResources:
      requests:
        cpu: "50m"
        memory: "32Mi"
      limits:
        cpu: "100m"
        memory: "64Mi"
    serviceMonitor:
      interval: "30s"
      scrapeTimeout: "10s"
      additionalLabels:
        release: prometheus
  autoscaling:
    enabled: true
    minReplicas: 2
    maxReplicas: 10
  security:
    podSecurityContext:
      runAsNonRoot: true
    containerSecurityContext:
      runAsUser: 11211
      allowPrivilegeEscalation: false
    sasl:
      enabled: true
      credentialsSecretRef:
        name: memcached-sasl-credentials
    tls:
      enabled: true
      certificateSecretRef:
        name: memcached-tls-certs

Minimal Example ​

A minimal CR relying on defaults:

yaml
apiVersion: memcached.c5c3.io/v1alpha1
kind: Memcached
metadata:
  name: memcached-dev
spec:
  replicas: 1

This creates a single-replica Memcached pod with image memcached:1.6, 64 MB memory limit, 1024 max connections, 4 threads, and 1m max item size.