apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: curl-job
  namespace: observability
spec:
  schedule: "*/30 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: curl-container
            image: badouralix/curl-jq # Use an image with curl and jq installed
            command: ["/bin/sh", "-c", "/bin/sh /etc/cmd/curl-command.sh"]
            volumeMounts:
            - name: curl-command-volume
              mountPath: /etc/cmd
          restartPolicy: OnFailure
          volumes:
          - name: curl-command-volume
            configMap:
              name: curl-command
---

apiVersion: v1
kind: ConfigMap
metadata:
  name: curl-command
  namespace: observability
data:
  curl-command.sh: |
    #!/bin/sh
    set -x;
    random_app_id=$(cat /dev/urandom | tr -dc '0-9' | fold -w 13 | head -n 1)
    token="GET_THE_TOKEN_VIA_O11Y_API"
    curl --location --request POST 'http://www.gs.us-west-2.aws.observability-staging.pingcap.cloud/api/v1/clusters/' \
    --header "Authorization: Bearer $token" \
    --header 'Content-Type: application/json' \
    --data-raw '{
      "tenantID": "benchmark",
      "projectID": "123456",
      "applicationID": "'"$random_app_id"'",
      "name": "benchmark",
      "bizType": "tidbcloud",
      "agentAccessARN": "access-sa6@pingcap-gardener.iam.gserviceaccount.com",
      "monitorSpecID": "spec1",
      "region": "us-west1",
      "shareMode": "shared",
      "muteAlert": false,
      "vendor": "gcp",
      "version": "V1",
      "ruleTemplateID": "benchmark"
    }'