# services/logging/bootstrap-jobs/opensearch-observability-setup-job.yaml
# One-off job for logging/opensearch-observability-setup-2.
# Purpose: opensearch observability setup 2 (see container args/env in this file).
# Run by setting spec.suspend to false, reconcile, then set it back to true.
# Safe to delete the finished Job/pod; it should not run continuously.
apiVersion: batch/v1
kind: Job
metadata:
  name: opensearch-observability-setup-2
  namespace: logging
spec:
  suspend: true
  backoffLimit: 3
  ttlSecondsAfterFinished: 3600
  template:
    spec:
      restartPolicy: OnFailure
      nodeSelector:
        node-role.kubernetes.io/worker: "true"
        hardware: rpi5
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: hardware
                    operator: In
                    values:
                      - rpi5
      containers:
        - name: setup
          image: python:3.11-alpine
          command: ["python", "/scripts/seed.py"]
          env:
            - name: OSD_URL
              value: http://opensearch-dashboards.logging.svc.cluster.local:5601
          volumeMounts:
            - name: scripts
              mountPath: /scripts
              readOnly: true
            - name: objects
              mountPath: /config
              readOnly: true
      volumes:
        - name: scripts
          configMap:
            name: opensearch-observability-script
        - name: objects
          configMap:
            name: opensearch-observability-objects
