apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis-master
  namespace: default
  labels:
    name: redis-master
spec:
  serviceName: redis-master
  replicas: 1
  selector:
    matchLabels:
      app: redis-master
  template:
    metadata:
      labels:
        app: redis-master
        redis-master: "true"
      annotations:
        #net.ipv4.tcp_syncookies=0 need kernel version 4.4 or newer
        security.alpha.kubernetes.io/sysctls: "net.ipv4.tcp_syncookies=0,net.ipv4.ip_local_port_range=10000 65535"
        #kernel version 4.15 needed
        security.alpha.kubernetes.io/unsafe-sysctls: "net.core.somaxconn=65535,net.ipv4.tcp_tw_reuse=1,net.ipv4.tcp_fin_timeout=30,net.ipv4.tcp_keepalive_intvl=4,net.ipv4.tcp_keepalive_probes=3,net.ipv4.tcp_keepalive_time=120,net.ipv4.tcp_max_syn_backlog=65535,net.ipv4.tcp_rfc1337=1,net.ipv4.tcp_slow_start_after_idle=0,net.ipv4.tcp_fack=1,net.ipv4.tcp_fwmark_accept=1,net.ipv4.fwmark_reflect=1"
    spec:
      terminationGracePeriodSeconds: 10
      #imagePullSecrets: 
      #  - name: regsecret
      containers:
      - name: redis
        image: slpcat/redis-3.2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 6379
        env:
        - name: MASTER
          value: "true"
        #- name: REDIS_PASS
        #  valueFrom:
        #    secretKeyRef:
        #      name: redis-secret
        #      key: redisAuthPass
        resources:
          requests:
            memory: "256Mi"
            cpu: "250m"
          limits:
            memory: "2Gi"
            cpu: "2000m"
        volumeMounts:
        - name: redis-master-volume
          mountPath: /var/lib/redis
  volumeClaimTemplates:
  - metadata:
      name: redis-master-volume
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 5Gi
