apiVersion: batch/v1
kind: Job
metadata:
  name: demo-seed-subscriptions
  namespace: bakery-ia
  labels:
    app: demo-seed
    component: initialization
  annotations:
    "helm.sh/hook": post-install,post-upgrade
    "helm.sh/hook-weight": "15"
spec:
  ttlSecondsAfterFinished: 3600
  template:
    metadata:
      labels:
        app: demo-seed-subscriptions
    spec:
      initContainers:
      - name: wait-for-tenant-migration
        image: busybox:1.36
        command:
        - sh
        - -c
        - |
          echo "Waiting 30 seconds for tenant-migration to complete..."
          sleep 30
      - name: wait-for-tenant-seed
        image: busybox:1.36
        command:
        - sh
        - -c
        - |
          echo "Waiting 15 seconds for demo-seed-tenants to complete..."
          sleep 15
      containers:
      - name: seed-subscriptions
        image: bakery/tenant-service:latest
        command: ["python", "/app/scripts/demo/seed_demo_subscriptions.py"]
        env:
        - name: TENANT_DATABASE_URL
          valueFrom:
            secretKeyRef:
              name: database-secrets
              key: TENANT_DATABASE_URL
        - name: LOG_LEVEL
          value: "INFO"
        resources:
          requests:
            memory: "256Mi"
            cpu: "100m"
          limits:
            memory: "512Mi"
            cpu: "500m"
      restartPolicy: OnFailure
      serviceAccountName: demo-seed-sa
