apiVersion: v1
kind: Service
metadata:
  name: spark-k8s-service
  labels:
    app: spark-k8s-app
spec:
  ports:
  - port: 7070
    name: spark-port
  clusterIP: None
  selector:
    app: spark-k8s-app
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: spark-k8s-sc
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  iopsPerGB: "10"
  fsType: ext4
  encrypted: "true"
reclaimPolicy: Retain
mountOptions:
  - debug
volumeBindingMode: Immediate
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: spark-k8s-statefulset
spec:
  serviceName: "spark-k8s-service"
  replicas: 2
  selector:
    matchLabels:
      app: spark-k8s-app
  template:
    metadata:
      labels:
        app: spark-k8s-app
    spec:
      containers:
      - name: spark-k8s-container
        image: yukizzz/spark:v2.4.0-rc3-driver
        ports:
        - containerPort: 7070
          name: spark-k8s-port
        volumeMounts:
        - name: spark-k8s-vm
          mountPath: /mnt/ebs
  volumeClaimTemplates:
  - metadata:
      name: spark-k8s-vm
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "spark-k8s-sc"
      resources:
        requests:
          storage: 1Gi