---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: oauth2-proxy
  labels:
    app: oauth2-proxy
spec:
  selector:
    matchLabels:
      app: oauth2-proxy
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: oauth2-proxy
      annotations:
        reloader.stakater.com/auto: "true"
    spec:
      serviceAccountName: oauth2-proxy
      containers:
        - name: oauth2-proxy
          image: "quay.io/oauth2-proxy/oauth2-proxy:v7.1.2"
          imagePullPolicy: IfNotPresent
          args:
            - --http-address=0.0.0.0:4180
            - --config=/etc/oauth2_proxy/oauth2_proxy.cfg
          env:
            - name: OAUTH2_PROXY_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: oauth2-proxy
                  key: client-id
            - name: OAUTH2_PROXY_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: oauth2-proxy
                  key: client-secret
            - name: OAUTH2_PROXY_COOKIE_SECRET
              valueFrom:
                secretKeyRef:
                  name: oauth2-proxy
                  key: cookie-secret
          ports:
            - containerPort: 4180
              name: http
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /ping
              port: http
              scheme: HTTP
            initialDelaySeconds: 0
            timeoutSeconds: 1
          readinessProbe:
            httpGet:
              path: /ping
              port: http
              scheme: HTTP
            initialDelaySeconds: 0
            timeoutSeconds: 1
            successThreshold: 1
            periodSeconds: 10
          volumeMounts:
            - mountPath: /etc/oauth2_proxy
              name: config
      volumes:
        - configMap:
            defaultMode: 420
            name: oauth2-proxy
          name: config
