apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
  labels:
    service: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      name: redis
  template:
    metadata:
      labels:
        name: redis
        service: redis
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: service
                operator: In
                values:
                - redis
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: redis-server
        image: mirror.gcr.io/library/redis:alpine
        imagePullPolicy: Always
        command:
        - redis-server
        args:
        - /etc/redis/redis.conf
        - --protected-mode
        - "no"
        ports:
        - name: redis
          containerPort: 6379
        resources:
          requests:
            memory: 36Gi
        volumeMounts:
        - mountPath: /data
          name: data
        - mountPath: /etc/redis
          name: config
      nodeSelector:
        cloud.google.com/gke-nodepool: redis
      volumes:
      - name: data
        emptyDir: {}
      - name: config
        configMap:
          name: redis-config
          items:
          - key: redis.conf
            path: redis.conf
