apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: nowchess-staging
resources:
  - ../base
  - webview-ingress.yaml
images:
  - name: ghcr.io/now-chess/now-chess-systems/analytics
    newTag: 0.2.0
patches:
  - patch: |-
      apiVersion: batch/v1
      kind: CronJob
      metadata:
        name: spark-opening-book
      spec:
        jobTemplate:
          spec:
            template:
              spec:
                containers:
                  - name: spark-driver
                    command:
                      - /opt/spark/bin/spark-submit
                      - --master
                      - spark://spark-master:7077
                      - --conf
                      - spark.executor.instances=1
                      - --conf
                      - spark.executor.cores=1
                      - --conf
                      - spark.executor.memory=512m
                      - --conf
                      - spark.driver.memory=512m
                      - --conf
                      - spark.driver.host=spark-opening-book-driver
                      - --conf
                      - spark.driver.port=44167
                      - --conf
                      - spark.blockManager.port=44777
                      - --class
                      - de.nowchess.analytics.OpeningBookJob
                      - file:///app/analytics.jar
                      - /spark-output/opening-book
                      - "10"
                    env:
                      - name: NOWCHESS_PGN_PATH
                        value: "https://database.lichess.org/standard/lichess_db_standard_rated_2013-01.pgn.zst"
    target:
      kind: CronJob
      name: spark-opening-book
  - patch: |-
      apiVersion: batch/v1
      kind: CronJob
      metadata:
        name: spark-player-stats
      spec:
        jobTemplate:
          spec:
            template:
              spec:
                containers:
                  - name: spark-driver
                    command:
                      - /opt/spark/bin/spark-submit
                      - --master
                      - spark://spark-master:7077
                      - --conf
                      - spark.executor.instances=1
                      - --conf
                      - spark.executor.cores=1
                      - --conf
                      - spark.executor.memory=512m
                      - --conf
                      - spark.driver.memory=512m
                      - --conf
                      - spark.driver.host=spark-player-stats-driver
                      - --conf
                      - spark.driver.port=44167
                      - --conf
                      - spark.blockManager.port=44777
                      - --class
                      - de.nowchess.analytics.PlayerStatsJob
                      - file:///app/analytics.jar
                      - /spark-output/player-stats
                    env:
                      - name: NOWCHESS_PGN_PATH
                        value: "https://database.lichess.org/standard/lichess_db_standard_rated_2013-01.pgn.zst"
    target:
      kind: CronJob
      name: spark-player-stats
  - patch: |-
      apiVersion: batch/v1
      kind: CronJob
      metadata:
        name: spark-player-clustering
      spec:
        jobTemplate:
          spec:
            template:
              spec:
                containers:
                  - name: spark-driver
                    command:
                      - /opt/spark/bin/spark-submit
                      - --master
                      - spark://spark-master:7077
                      - --conf
                      - spark.executor.instances=1
                      - --conf
                      - spark.executor.cores=1
                      - --conf
                      - spark.executor.memory=512m
                      - --conf
                      - spark.driver.memory=512m
                      - --conf
                      - spark.driver.host=spark-player-clustering-driver
                      - --conf
                      - spark.driver.port=44167
                      - --conf
                      - spark.blockManager.port=44777
                      - --class
                      - de.nowchess.analytics.PlayerClusteringJob
                      - file:///app/analytics.jar
                      - /spark-output/player-clusters
                      - "4"
                    env:
                      - name: NOWCHESS_PGN_PATH
                        value: "https://database.lichess.org/standard/lichess_db_standard_rated_2013-01.pgn.zst"
    target:
      kind: CronJob
      name: spark-player-clustering
  - patch: |-
      apiVersion: batch/v1
      kind: CronJob
      metadata:
        name: spark-player-graph
      spec:
        jobTemplate:
          spec:
            template:
              spec:
                containers:
                  - name: spark-driver
                    command:
                      - /opt/spark/bin/spark-submit
                      - --master
                      - spark://spark-master:7077
                      - --conf
                      - spark.executor.instances=1
                      - --conf
                      - spark.executor.cores=1
                      - --conf
                      - spark.executor.memory=512m
                      - --conf
                      - spark.driver.memory=512m
                      - --conf
                      - spark.driver.host=spark-player-graph-driver
                      - --conf
                      - spark.driver.port=44167
                      - --conf
                      - spark.blockManager.port=44777
                      - --class
                      - de.nowchess.analytics.PlayerGraphJob
                      - file:///app/analytics.jar
                      - /spark-output/player-graph
                    env:
                      - name: NOWCHESS_PGN_PATH
                        value: "https://database.lichess.org/standard/lichess_db_standard_rated_2013-01.pgn.zst"
    target:
      kind: CronJob
      name: spark-player-graph
  - patch: |-
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: spark-live-dashboard
      spec:
        template:
          spec:
            containers:
              - name: spark-driver
                command:
                  - /opt/spark/bin/spark-submit
                  - --master
                  - spark://spark-master:7077
                  - --conf
                  - spark.executor.instances=1
                  - --conf
                  - spark.executor.cores=1
                  - --conf
                  - spark.executor.memory=512m
                  - --conf
                  - spark.driver.memory=512m
                  - --conf
                  - spark.driver.host=spark-live-dashboard-driver
                  - --conf
                  - spark.driver.port=37007
                  - --conf
                  - spark.blockManager.port=37777
                  - --class
                  - de.nowchess.analytics.LiveDashboardJob
                  - local:///app/analytics.jar
                  - /spark-checkpoint
    target:
      kind: Deployment
      name: spark-live-dashboard
  - patch: |-
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: spark-analytics-webview
      spec:
        replicas: 1
    target:
      kind: Deployment
      name: spark-analytics-webview
