# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- gcs-testing.yaml
- fio-config.yaml

images:
- name: fio
  newName: us-docker.pkg.dev/fsi-research-1/research-images/fio
  newTag: latest

configMapGenerator:
- literals:
  - JOB_NAME=fio-test-gcs-10k-cache-15k-final-1
  - BUCKETNAME=fsi-research-1-us-central1-gke-data-beao
  - COMPLETIONS=10000
  - PARALLELISM=5000
  - TEST_DIR=test_files
  - MOUNT_PATH=/data
  name: gcs-vars

replacements:
- source:
    kind: ConfigMap
    name: gcs-vars
    fieldPath: data.JOB_NAME
  targets:
  - select:
      kind: Job
    fieldPaths:
    - metadata.name
- source:
    kind: ConfigMap
    name: gcs-vars
    fieldPath: data.BUCKETNAME
  targets:
  - select:
      kind: Job
    fieldPaths:
    - spec.template.spec.volumes.[name=gcs-fuse-csi-ephemeral].csi.volumeAttributes.bucketName
- source:
    kind: ConfigMap
    name: gcs-vars
    fieldPath: data.TEST_DIR
  targets:
  - select:
      kind: Job
    fieldPaths:
    - spec.template.spec.containers.[name=fio].env.[name=TEST_DIR].value
- source:
    kind: ConfigMap
    name: gcs-vars
    fieldPath: data.MOUNT_PATH
  targets:
  - select:
      kind: Job
    fieldPaths:
    - spec.template.spec.containers.[name=fio].env.[name=MOUNT_PATH].value
- source:
    kind: ConfigMap
    name: gcs-vars
    fieldPath: data.MOUNT_PATH
  targets:
  - select:
      kind: Job
    fieldPaths:
    - spec.template.spec.containers.[name=fio].volumeMounts.[name=gcs-fuse-csi-ephemeral].mountPath
- source:
    kind: ConfigMap
    name: gcs-vars
    fieldPath: data.COMPLETIONS
  targets:
  - select:
      kind: Job
    fieldPaths:
    - spec.completions
- source:
    kind: ConfigMap
    name: gcs-vars
    fieldPath: data.PARALLELISM
  targets:
  - select:
      kind: Job
    fieldPaths:
    - spec.parallelism
