Almond is a Scala kernel for Jupyter.

Some features:

You can deploy Almond on Kubernetes with the following manifest:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: almond
  labels:
    app: almond
spec:
  replicas: 1
  selector:
    matchLabels:
      app: almond
  template:
    metadata:
      labels:
        app: almond
    spec:
      containers:
        - name: almond
          image: almondsh/almond:0.13.11
          resources:
            requests:
              memory: 384Mi
            limits:
              memory: 384Mi
          ports:
            - containerPort: 8888
---
kind: Service
apiVersion: v1
metadata:
  name: almond
spec:
  type: ClusterIP
  selector:
    app: almond
  ports:
    - protocol: TCP
      port: 8888
      targetPort: 8888
---
kind: Service
apiVersion: v1
metadata:
  name: almond-headless
spec:
  clusterIP: None
  selector:
    app: almond

Port forward:

kubectl port-forward svc/almond 8888:8888

List the available servers including the required token:

kubectl exec -it deploy/almond -- bash -c "jupyter server list"

Spark session

Almond comes with its own Spark integration. To interact with a Spark cluster, we deployed a service named almond-headless so that they are discoverable when run in Cluster mode.

import $ivy.`org.apache.spark::spark-sql:3.3.2`
import org.apache.spark.sql._

// create a SparkSession using the NotebookSparkSessionBuilder provided by almond-spark
val spark = {
  NotebookSparkSession.builder()
    .master("spark://spark-master-svc:7077")
    .config("spark.driver.host", "almond-headless")
    .config("spark.executor.instances", "1")
    .config("spark.executor.memory", "2g")
    .config("spark.executor.cores", "1")
    .getOrCreate()
}

import org.apache.spark.sql.functions._
import spark.implicits._