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.ResourceRequirementsNoResource requests and limits for the container
memcached*MemcachedConfigNoMemcached server configuration parameters
highAvailability*HighAvailabilitySpecNoHigh-availability settings
monitoring*MonitoringSpecNoMonitoring and metrics configuration
security*SecuritySpecNoSecurity settings
autoscaling*AutoscalingSpecNoHorizontal 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[]stringNoAdditional 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.TopologySpreadConstraintNoTopology domain spread constraints for pods
podDisruptionBudget*PDBSpecNoPodDisruptionBudget configuration

AntiAffinityPreset

String enum type controlling pod anti-affinity behavior.

ValueDescription
softUses preferredDuringSchedulingIgnoredDuringExecution
hardUses requiredDuringSchedulingIgnoredDuringExecution

PDBSpec

Defines PodDisruptionBudget configuration for Memcached pods.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalseWhether a PodDisruptionBudget is created
minAvailable*intstr.IntOrStringNo1Minimum available pods during disruption (absolute or %)
maxUnavailable*intstr.IntOrStringNoMaximum unavailable pods during disruption (absolute or %)

MonitoringSpec

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

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalseEnables the memcached-exporter sidecar
exporterImage*stringNo"prom/memcached-exporter:v0.15.4"Container image for the exporter sidecar
exporterResources*corev1.ResourceRequirementsNoResource requests/limits for the exporter sidecar
serviceMonitor*ServiceMonitorSpecNoPrometheus ServiceMonitor configuration

ServiceMonitorSpec

Defines Prometheus ServiceMonitor resource configuration.

FieldTypeRequiredDefaultValidationDescription
additionalLabelsmap[string]stringNoExtra 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.PodSecurityContextNoSecurity context for the Memcached pod
containerSecurityContext*corev1.SecurityContextNoSecurity context for the Memcached container
sasl*SASLSpecNoSASL authentication configuration
tls*TLSSpecNoTLS encryption configuration

SASLSpec

Defines SASL authentication configuration for Memcached.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalseWhether SASL authentication is active
credentialsSecretRefcorev1.LocalObjectReferenceNoReference to the Secret containing a password-file key with SASL credentials

TLSSpec

Defines TLS encryption configuration for Memcached.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalseWhether TLS encryption is active
certificateSecretRefcorev1.LocalObjectReferenceNoReference 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 Deployment.

FieldTypeRequiredDefaultValidationDescription
enabledboolNofalseControls whether horizontal pod autoscaling is active
minReplicas*int32NoMinimum: 1Lower limit for the number of replicas. When nil, the HPA default (1) is used
maxReplicasint32YesMinimum: 1Upper limit for the number of replicas
metrics[]autoscalingv2.MetricSpecNoSpecifications for calculating desired replica count. When empty and autoscaling is enabled, the defaulting webhook injects a CPU utilization metric targeting 80%
behavior*autoscalingv2.HorizontalPodAutoscalerBehaviorNoScaling 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

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.