apiVersion: apps/v1
kind: Deployment
metadata:
  name: spark-history-server
  labels:
    app.kubernetes.io/name: spark-history-server
    app.kubernetes.io/part-of: nowchess
spec:
  replicas: 0
  selector:
    matchLabels:
      app.kubernetes.io/name: spark-history-server
  template:
    metadata:
      labels:
        app.kubernetes.io/name: spark-history-server
        app.kubernetes.io/part-of: nowchess
    spec:
      containers:
        - name: history-server
          image: apache/spark:4.0.3-scala2.13-java17-ubuntu
          command:
            - /opt/spark/bin/spark-class
            - org.apache.spark.deploy.history.HistoryServer
          env:
            - name: SPARK_HISTORY_OPTS
              value: "-Dspark.history.fs.logDirectory=/spark-events"
          ports:
            - name: http
              containerPort: 18080
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 1Gi
          volumeMounts:
            - name: spark-events
              mountPath: /spark-events
      volumes:
        - name: spark-events
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: spark-history-server-svc
  labels:
    app.kubernetes.io/name: spark-history-server
    app.kubernetes.io/part-of: nowchess
spec:
  selector:
    app.kubernetes.io/name: spark-history-server
  ports:
    - name: http
      port: 18080
      targetPort: http
  type: ClusterIP
