apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: argocd-redis
    app.kubernetes.io/part-of: argocd
    app.kubernetes.io/component: redis
  name: argocd-redis
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-redis
  template:
    metadata:
      labels:
        app.kubernetes.io/name: argocd-redis
    spec:
      initContainers:
        - command:
            - argocd
            - admin
            - redis-initial-password
          image: quay.io/argoproj/argocd:latest
          imagePullPolicy: IfNotPresent
          name: secret-init
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - ALL
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            seccompProfile:
              type: RuntimeDefault
      securityContext:
        runAsNonRoot: true
        runAsUser: 999
        seccompProfile:
          type: RuntimeDefault
      serviceAccountName: argocd-redis        
      containers:
      - name: redis
        image: redis:7.2.11-alpine
        imagePullPolicy: Always
        args:
        - "--save"
        - ""
        - "--appendonly"
        - "no"
        - --requirepass $(REDIS_PASSWORD)
        env:
          - name: REDIS_PASSWORD
            valueFrom:
              secretKeyRef:
                key: auth
                name: argocd-redis
        ports:
        - containerPort: 6379
        securityContext:
          readOnlyRootFilesystem: true
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/name: argocd-redis
              topologyKey: kubernetes.io/hostname
          - weight: 5
            podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/part-of: argocd
              topologyKey: kubernetes.io/hostname
      nodeSelector:
        kubernetes.io/os: linux