apiVersion: apps/v1
kind: Deployment
metadata:
  name: tenant
  namespace: sme
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sme-tenant
  template:
    metadata:
      labels:
        app: sme-tenant
    spec:
      serviceAccountName: tenant
      automountServiceAccountToken: false
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: tenant
          image: ghcr.io/openova-io/openova/services-tenant:046e5eb
          imagePullPolicy: Always
          ports:
            - containerPort: 8083
          env:
            - name: MONGODB_URI
              valueFrom:
                configMapKeyRef:
                  name: sme-services-config
                  key: MONGODB_URI
            - name: MONGODB_DB
              value: "tenants"
            - name: REDPANDA_BROKERS
              valueFrom:
                configMapKeyRef:
                  name: sme-services-config
                  key: REDPANDA_BROKERS
            - name: JWT_SECRET
              valueFrom:
                secretKeyRef:
                  name: sme-secrets
                  key: JWT_SECRET
            - name: CORS_ORIGIN
              valueFrom:
                configMapKeyRef:
                  name: sme-services-config
                  key: CORS_ORIGIN_PUBLIC
            - name: PROVISIONING_URL
              valueFrom:
                configMapKeyRef:
                  name: sme-services-config
                  key: PROVISIONING_URL
          resources:
            requests:
              cpu: 25m
              memory: 32Mi
            limits:
              cpu: 500m
              memory: 128Mi
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8083
            initialDelaySeconds: 5
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8083
            initialDelaySeconds: 3
            periodSeconds: 5
          securityContext:
            allowPrivilegeEscalation: false
            runAsNonRoot: true
            runAsUser: 65534
---
apiVersion: v1
kind: Service
metadata:
  name: tenant
  namespace: sme
spec:
  selector:
    app: sme-tenant
  ports:
    - port: 8083
      targetPort: 8083
