apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: argocd-dex-server
    app.kubernetes.io/part-of: argocd
    app.kubernetes.io/component: dex-server
  name: argocd-dex-server
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-dex-server
  template:
    metadata:
      labels:
        app.kubernetes.io/name: argocd-dex-server
    spec:
      serviceAccountName: argocd-dex-server
      initContainers:
      - name: copyutil
        image: quay.io/argoproj/argocd:latest
        imagePullPolicy: Always
        command: [cp, -n, /usr/local/bin/argocd, /shared/argocd-dex]
        volumeMounts:
        - mountPath: /shared
          name: static-files
        - mountPath: /tmp
          name: dexconfig
      containers:
      - name: dex
        image: ghcr.io/dexidp/dex:v2.35.3-distroless
        imagePullPolicy: Always
        command: [/shared/argocd-dex, rundex]
        securityContext:
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
          runAsNonRoot: true
        ports:
        - containerPort: 5556
        - containerPort: 5557
        - containerPort: 5558
        volumeMounts:
        - mountPath: /shared
          name: static-files
        - mountPath: /tmp
          name: dexconfig
      volumes:
      - emptyDir: {}
        name: static-files
      - emptyDir: {}
        name: dexconfig
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 5
            podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/part-of: argocd
              topologyKey: kubernetes.io/hostname
