|
3 | 3 |
|
4 | 4 | # k3s cluster image with OpenShell Helm charts and manifests |
5 | 5 | # |
6 | | -# This image is based on k3s and includes: |
| 6 | +# Multi-stage build: extracts k3s artifacts from the upstream rancher/k3s |
| 7 | +# Alpine image and layers them onto the NVIDIA Ubuntu base image. |
| 8 | +# |
| 9 | +# This image includes: |
| 10 | +# - k3s binary and all supporting binaries (containerd-shim, runc, CNI, etc.) |
7 | 11 | # - Packaged OpenShell Helm chart |
8 | 12 | # - HelmChart CR for auto-deploying OpenShell |
9 | 13 | # - Custom entrypoint for DNS configuration in Docker environments |
|
23 | 27 | # GHSA-9h8m-3fm2-qjrq otel/sdk v1.39.0 (macOS-only PATH hijack; N/A for Linux) |
24 | 28 | # CVE-2024-36623 docker/docker v25.0.8 (streamformatter race condition) |
25 | 29 | # Bump K3S_VERSION when a release with updated dependencies ships. |
| 30 | + |
| 31 | +# --------------------------------------------------------------------------- |
| 32 | +# Stage 1: Extract k3s artifacts from upstream rancher image (Alpine-based) |
| 33 | +# --------------------------------------------------------------------------- |
26 | 34 | ARG K3S_VERSION=v1.35.2-k3s1 |
27 | | -FROM rancher/k3s:${K3S_VERSION} |
| 35 | +FROM rancher/k3s:${K3S_VERSION} AS k3s |
| 36 | + |
| 37 | +# --------------------------------------------------------------------------- |
| 38 | +# Stage 2: Runtime on NVIDIA hardened Ubuntu base |
| 39 | +# --------------------------------------------------------------------------- |
| 40 | +FROM nvcr.io/nvidia/base/ubuntu:noble-20251013 |
| 41 | + |
| 42 | +# Install runtime dependencies that k3s expects from the host OS. |
| 43 | +# - iptables: used by flannel/kube-proxy for network policy and NAT rules |
| 44 | +# - mount/umount: needed by kubelet for volume mounts (provided by mount package) |
| 45 | +# - ca-certificates: TLS verification for registry pulls |
| 46 | +# - conntrack: k3s/kube-proxy uses conntrack for connection tracking |
| 47 | +# - dnsutils: nslookup used by entrypoint/healthcheck for DNS probe |
| 48 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 49 | + ca-certificates \ |
| 50 | + iptables \ |
| 51 | + mount \ |
| 52 | + dnsutils \ |
| 53 | + && rm -rf /var/lib/apt/lists/* |
| 54 | + |
| 55 | +# Copy the full /bin directory from k3s (contains all statically-linked |
| 56 | +# binaries and their symlinks: k3s, kubectl, crictl, ctr, containerd, |
| 57 | +# containerd-shim-runc-v2, runc, cni plugins, busybox, coreutils, |
| 58 | +# ip, ipset, conntrack, nsenter, pigz, etc.) |
| 59 | +COPY --from=k3s /bin/ /bin/ |
| 60 | + |
| 61 | +# Copy iptables/nftables tooling (xtables-nft-multi, iptables-detect.sh, etc.) |
| 62 | +# These are in /bin/aux/ in the k3s image and must be on PATH. |
| 63 | +# Note: the Ubuntu iptables package provides /usr/sbin/iptables, but k3s |
| 64 | +# expects its own bundled version at /bin/aux/iptables. Both are on PATH; |
| 65 | +# k3s finds its copy via /bin/aux in PATH. |
| 66 | + |
| 67 | +# Copy CA certificates from k3s (bundled Alpine CA bundle). |
| 68 | +# The Ubuntu ca-certificates package also installs certs; having both is fine. |
| 69 | +COPY --from=k3s /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/k3s-ca-certificates.crt |
| 70 | + |
| 71 | +# Copy timezone data used by k3s/Go for time.LoadLocation |
| 72 | +COPY --from=k3s /usr/share/zoneinfo/ /usr/share/zoneinfo/ |
| 73 | + |
| 74 | +# Set environment variables matching the upstream k3s image. |
| 75 | +# PATH includes /bin/aux for iptables tooling and /var/lib/rancher/k3s/data/cni |
| 76 | +# for runtime-extracted CNI binaries. |
| 77 | +ENV PATH="/var/lib/rancher/k3s/data/cni:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/bin/aux" \ |
| 78 | + CRI_CONFIG_FILE="/var/lib/rancher/k3s/agent/etc/crictl.yaml" |
28 | 79 |
|
29 | 80 | # Create directories for manifests, charts, and configuration |
30 | 81 | RUN mkdir -p /var/lib/rancher/k3s/server/manifests \ |
31 | 82 | /var/lib/rancher/k3s/server/static/charts \ |
32 | 83 | /etc/rancher/k3s \ |
33 | 84 | /opt/openshell/manifests \ |
34 | | - /opt/openshell/charts |
| 85 | + /opt/openshell/charts \ |
| 86 | + /run/flannel |
35 | 87 |
|
36 | 88 | # Copy entrypoint script that configures DNS for Docker environments |
37 | 89 | # This script detects the host gateway IP and configures CoreDNS to use it |
|
0 commit comments