apiVersion: apps/v1
kind: Deployment
metadata:
  name: geeksbot
  namespace: discord-bots
  labels:
    app: geeksbot
spec:
  replicas: 1
  selector:
    matchLabels:
      app: geeksbot
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  minReadySeconds: 120
  template:
    metadata:
      labels:
        app: geeksbot
    spec:
      containers:
        - name: pgbouncer
          image: timoha/pgbouncer:1.15.0
          resources:
            requests:
              memory: "256Mi"
              cpu: "0.5"
            limits:
              memory: "512Mi"
              cpu: "1"
          env:
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: geeksbot
                  key: pgbouncer_url
            - name: SERVER_TLS_SSLMODE
              valueFrom:
                secretKeyRef:
                  name: geeksbot
                  key: pgbouncer_ssl
            - name: AUTH_TYPE
              valueFrom:
                secretKeyRef:
                  name: geeksbot
                  key: pgbouncer_auth
          ports:
            - containerPort: 5432
        - name: geeksbot
          image: <IMAGE>
          resources:
            requests:
              memory: "512Mi"
              cpu: "1"
            limits:
              memory: "1Gi"
              cpu: "2"
          env:
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: geeksbot
                  key: database_url
            - name: DISCORD_TOKEN
              valueFrom:
                secretKeyRef:
                  name: geeksbot
                  key: discord_token
      imagePullSecrets:
        - name: registry-1
