Sign inSign up

truebyteinnovationllp/spark

By truebyteinnovationllp

โ€ขUpdated 3 months ago

Hardened Apache Spark 4.1.2: PySpark, Java 21, Scala 2.13, Python 3, Debian 13, multi-arch, non-root

Image
Data science
0

1.3K

truebyteinnovationllp/spark repository overview

โ spark

Minimal, security-hardened Apache Spark 4.1 (PySpark) on Debian 13 (trixie). Two-stage build (download + GPG/SHA512 verify โ†’ clean runtime), runs as a non-root user, multi-arch (amd64/arm64), built to follow the Docker Hardened Imagesโ  Spark conventions (Debian 13 base, non-root uid 65532, /opt/spark layout, JRE under /opt/java/openjdk).

โ Highlights

  • ๐Ÿ”’ Hardened โ€” non-root (uid 65532, the DHI convention), compatible with a read-only root filesystem and restricted PodSecurity. Roots-drop uses setpriv (util-linux, C) โ€” no gosu, so no Go runtime / Go-stdlib CVE surface.
  • ๐Ÿ“Œ Reproducible โ€” Debian base pinned by digest; Spark pinned by version and SHA-512 and verified against the release manager's detached GPG signature.
  • ๐Ÿฉน Patched JARs โ€” patch-jars.sh upgrades the cleanly-swappable bundled libraries to fixed releases (Netty 4.2.15, Jackson 2.21.4, Derby 10.17, ZooKeeper 3.9.5), each verified against Maven Central's .sha1. The optional Spark Connect REPL bundle (which shaded a vulnerable Netty) is removed.
  • โ˜• Java 21 โ€” Debian's openjdk-21-jre-headless (apt-patched, no AWT/GUI surface).
  • ๐Ÿ PySpark โ€” Python 3 (python3 + pip); PYSPARK_PYTHON=python3 preset.
  • ๐Ÿงฎ Scala 2.13 โ€” Spark 4.1.x / Hadoop 3 distribution.
  • ๐Ÿชถ Small โ€” tarball fetched + verified in a builder stage; the final image carries runtime deps only (gnupg/wget never reach it).
  • ๐Ÿงฑ Multi-arch โ€” linux/amd64, linux/arm64.
  • ๐Ÿš€ K8s-ready โ€” ships the upstream Spark-on-Kubernetes entrypoint (driver / executor / pass-through modes) and the decommission helper at /opt/decom.sh.

โ Tags

  • latest โ€” newest build.
  • 4.1.2-python3-java21 โ€” Spark 4.1.2, Scala 2.13, Java 21, Python 3, Debian 13.

Note: Java 21 requires the Spark 4.x line. (Spark 3.5.x officially supports Java 8/11/17 only.) Spark 4.x ships Scala 2.13 exclusively.

โ Image facts

Basedebian:trixie-slim (Debian 13), digest-pinned
Spark4.1.2 (spark-4.1.2-bin-hadoop3)
JavaOpenJDK 21 (openjdk-21-jre-headless)
Scala2.13
Python3 (Debian python3)
Userspark (uid/gid 65532), non-root
SPARK_HOME/opt/spark
JAVA_HOME/opt/java/openjdk/21-jre
Entrypoint/opt/spark/bin/docker-entrypoint.sh
Workdir/opt/spark/work-dir

โ Quick start

โ PySpark shell
docker run --rm -it truebyteinnovationllp/spark:4.1.2-python3-java21 \
  /opt/spark/bin/pyspark
โ Run the SparkPi example (local mode)
docker run --rm truebyteinnovationllp/spark:4.1.2-python3-java21 \
  /opt/spark/bin/spark-submit \
  --master 'local[*]' \
  --class org.apache.spark.examples.SparkPi \
  /opt/spark/examples/jars/spark-examples.jar 100
โ Submit a PySpark script
docker run --rm -v "$PWD":/work \
  truebyteinnovationllp/spark:4.1.2-python3-java21 \
  /opt/spark/bin/spark-submit --master 'local[*]' /work/job.py
โ Spark on Kubernetes

The entrypoint understands the driver and executor commands used by spark-submit --master k8s://โ€ฆ. Point spark.kubernetes.container.image at this image; it runs unprivileged by default and switches to the spark user via gosu if a pod starts as root.

โ Hardening notes

  • Immutable runtime โ€” add --read-only (mount a writable volume at /opt/spark/work-dir if your job writes there).
  • Drop capabilities โ€” --cap-drop=ALL; the image needs none.
  • No build tooling โ€” wget/gnupg2 exist only in the builder stage.
  • Supply chain โ€” every release is pushed multi-arch with SBOM + provenance attestations and signed with Cosign (see the repo CI). Verify with:
    cosign verify --key cosign.pub truebyteinnovationllp/spark:4.1.2-python3-java21
    

โ Security posture (CVEs)

Unlike the from-source images in this repo, Spark ships a large, fixed set of prebuilt upstream JARs, so literal "zero CVE" is not achievable by patching a tarball โ€” the upstream Docker Hardened Image reaches zero only by rebuilding Spark from source against patched dependencies. This image instead does the honest, maintainable thing:

  1. Upgrade every cleanly-swappable standalone JAR to a fixed release (patch-jars.sh: Netty 4.2.15, Jackson 2.21.4, Derby 10.17, ZooKeeper 3.9.5).
  2. Remove dead/optional vulnerable surface (Spark Connect REPL bundle with its shaded Netty; macOS/Windows Netty native jars; gosu/Go).
  3. Triage the irreducible remainder in .trivyignoreโ  and spark.openvex.jsonโ , each with a written justification.

The CI gate is Trivy honouring .trivyignore, so the build still fails on any new, undocumented HIGH/CRITICAL โ€” only the reviewed residuals pass.

HIGH/CRITICAL
Stock Spark 4.1.2 tarball~58
This image (raw)~34 โ€” all triaged
This image (undocumented)0 โœ…

The residual ~34 are: Jackson shaded inside Hadoop/Parquet uber-jars (Spark's own classpath Jackson is patched); JLine telnet / Jetty UI / Thrift paths not reachable in normal operation; lz4-java (no published fix); and Debian userland packages marked fix_deferred (perl/expat/ncurses/python) that apt upgrade will patch automatically once Debian ships them. Re-review on every Spark/Debian bump and delete entries as they clear.

โ Build locally

docker build -t spark:4.1.2-python3-java21 spark-docker/

# Override the version (also update SHA512 + GPG key together):
docker build \
  --build-arg SPARK_VERSION=4.1.2 \
  --build-arg SPARK_SHA512=<sha512> \
  --build-arg GPG_KEY=<release-manager-fingerprint> \
  -t spark:4.1.2-python3-java21 spark-docker/

Upstream sources: https://spark.apache.orgโ  ยท signing keys: https://downloads.apache.org/spark/KEYSโ 

Tag summary

Content type

Image

Digest

sha256:bc7e2e00cโ€ฆ

Size

490.4 MB

Last updated

3 months ago

docker pull truebyteinnovationllp/spark