# services/logging/opensearch-single-node-tune-cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: opensearch-single-node-tune
  namespace: logging
spec:
  schedule: "*/30 * * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      backoffLimit: 2
      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: tune
              image: python:3.11-alpine
              command: ["python", "/scripts/tune.py"]
              env:
                - name: OPENSEARCH_URL
                  value: http://opensearch-master.logging.svc.cluster.local:9200
              resources:
                requests:
                  cpu: 10m
                  memory: 32Mi
                limits:
                  cpu: 200m
                  memory: 128Mi
              volumeMounts:
                - name: scripts
                  mountPath: /scripts
          volumes:
            - name: scripts
              configMap:
                name: opensearch-single-node-tune-script
