apiVersion: apps/v1
kind: StatefulSet
metadata:
  annotations:
    prometheus.io/path: /metrics
    prometheus.io/port: "9150"
    prometheus.io/scrape: "true"
  labels:
    app: memcached
  name: memcached
  namespace: monitoring
spec:
  podManagementPolicy: OrderedReady
  replicas: 3
  selector:
    matchLabels:
      app: memcached
  serviceName: memcached
  template:
    metadata:
      labels:
        app: memcached
    spec:
      containers:
        - command:
            - memcached
            - -m 6144 # amount of memory allocated to memcached for object storage
            - -I 1m # max item memory
            - -c 4096 # maximum number of simultaneous connections to the memcached service
            - -v # Verbose mode. Prints errors and warnings while executing the main event loop.
          image: memcached:1.5.20-alpine
          imagePullPolicy: IfNotPresent
          livenessProbe:
            failureThreshold: 3
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: memcache
            timeoutSeconds: 5
          name: memcached
          ports:
            - containerPort: 11211
              name: memcache
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: memcache
            timeoutSeconds: 1
          resources:
            limits:
              memory: 8Gi
            requests:
              cpu: 200m
              memory: 8Gi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
        - image: quay.io/prometheus/memcached-exporter:v0.6.0
          imagePullPolicy: IfNotPresent
          name: exporter
          ports:
            - containerPort: 9150
              name: exporter
              protocol: TCP
          resources:
            limits:
              memory: 300Mi
            requests:
              cpu: 5m
              memory: 64Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
  updateStrategy:
    type: RollingUpdate
