apiVersion: apps/v1
kind: Deployment
metadata:
  name: sandbox-api
  namespace: sandbox
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sandbox
      component: sandbox-api
  template:
    metadata:
      labels:
        app: sandbox
        component: sandbox-api
    spec:
      serviceAccountName: sandbox-api
      containers:
      - name: api
        image: quay.io/enmasse/sandbox-api:latest
        ports:
          - name: http
            protocol: TCP
            containerPort: 8080
        env:
        - name: QUARKUS_OIDC_AUTH_SERVER_URL
          valueFrom:
            secretKeyRef:
              name: sandbox-oidc
              key: issuer
        - name: QUARKUS_OIDC_CLIENT_ID
          valueFrom:
            secretKeyRef:
              name: sandbox-oidc
              key: clientid
        - name: QUARKUS_OIDC_CREDENTIALS_SECRET
          valueFrom:
            secretKeyRef:
              name: sandbox-oidc
              key: clientsecret
        - name: QUARKUS_HTTP_CORS
          value: "true"
        - name: QUARKUS_HTTP_CORS_ORIGINS
          value: "http://localhost:3000,https://sandbox.enmasse.io,https://api.sandbox.enmasse.io"
        - name: ENMASSE_SANDBOX_EXPIRATION_TIME
          valueFrom:
            configMapKeyRef:
              name: sandbox-config
              key: expirationTime
        - name: ENMASSE_SANDBOX_MAXTENANTS
          valueFrom:
            configMapKeyRef:
              name: sandbox-config
              key: maxTenants
        - name: KEYCLOAK_REALM_ADMIN_USER
          valueFrom:
            secretKeyRef:
              name: sandbox-api
              key: username
        - name: KEYCLOAK_REALM_ADMIN_PASSWORD
          valueFrom:
            secretKeyRef:
              name: sandbox-api
              key: password
        imagePullPolicy: Always
