Day 5: Secure by default
Goal: ship the Bewerbungslotse so that it runs securely without any action by the operator – no default password, no open port, no root, a read-only file system, Ollama reachable only by the Lotse – and prove it with a configuration scan · Duration: about 120 min · Prerequisite: Day 4 completed
State before this chapter
# on werk1
git -C ~/lotse log --oneline --decorate -1Expected (your commit number differs):
bdb2a6a (HEAD -> main) VEX für 1.0.0: 9 nicht betroffen, 1 betroffen, 1 in Prüfung
# on werk1
helm list -n lotseExpected (excerpt – the columns CHART and APP VERSION):
bewerbungslotse-1.0.0 1.0.0
Introduction
On Day 1 you wrote down the attack surface of the Lotse: a NodePort
through which anyone on the network reaches all routes, an admin export
with the preset password lotse, a container that runs as
root, and an Ollama that every pod in the cluster can query. None of
this is a programming error. These are default settings – and the CRA
names exactly those explicitly.
People who install a product rarely change its default settings. What is open from the factory stays open. That is why today you move security from the operator to the manufacturer: the chart refuses to install without a password of your own, the service is reachable only inside the cluster, the container runs as an ordinary user with a read-only file system, and NetworkPolicies lock Ollama away. A configuration scan with Trivy shows before and after what is open – and the diagnosis task shows how easily this scan overlooks an entire chart without anyone noticing.
Today you will learn:
- what “secure by default configuration” means in the CRA and what it looks like in the chart,
- to check a chart and a Containerfile for misconfigurations with
trivy config, - to build a runtime image in several stages, without pip and without root,
- to enforce a password in the chart instead of presetting one, with
requiredand a Secret, - to restrict the container with
securityContextand to seal off Ollama with NetworkPolicies, - to measure every hardening step instead of claiming it,
- to justify every remaining finding or record it as an open item.
Background
The picture of the day: delivery from the factory
A new car leaves the factory with the handbrake on, the doors locked and exactly one key, which is handed to the vehicle owner in person. Nobody would put a spare key under the floor mat “so that the customer finds it”. And anyone who later wants to put the car back into its delivery state finds the button for it in the workshop.
- Delivery state = default configuration (the values
in
values.yaml). - Spare key under the floor mat = default password
lotse. - Handbrake on, doors locked = default settings that protect: ClusterIP instead of NodePort, NetworkPolicies, no root.
- Handing over the key in person = mandatory value
that the operator sets themselves:
--set-file. - Final inspection on the line = configuration scan
with
trivy config. - Button for the delivery state = reset with
helm upgrade --reset-values.
The terms
| Term | Meaning | In the picture |
|---|---|---|
| secure by default configuration | default settings that are secure without any further action | delivery with the handbrake on |
| misconfiguration | a setting that makes an attack easier | window left open |
trivy config |
checks Containerfiles, manifests and Helm charts against rules | final inspection on the line |
securityContext |
section in the pod manifest: user, privileges, file system, seccomp | immobiliser and door locks |
| capability | a single root privilege of the Linux kernel, such as “reconfigure the network” | master key split into single keys |
| seccomp | filter for system calls; RuntimeDefault blocks rare,
dangerous ones |
limiter that prevents full throttle while stationary |
| NetworkPolicy | rule about which pod may reach which other pod | entry only with a factory pass |
| multi-stage build | image in two stages: build with tools, ship without | the tools stay in the workshop |
required |
Helm function: aborts if a value is missing | no key without a personal handover |
Remember: What is open from the factory stays open at the customer’s site. Security that the operator has to switch on first is not a default configuration.
What the law requires
Annex I, Part I, point 2 CRA lists what products shall do “on the basis of the cybersecurity risk assessment” and “where applicable”. Five letters matter today:
- (b) “be made available on the market with a secure by default configuration, […] including the possibility to reset the product to its original state”,
- (d) “ensure protection from unauthorised access by appropriate control mechanisms, including but not limited to authentication, identity or access management systems”,
- (h) protect the availability of essential and basic functions, also through “resilience and mitigation measures against denial-of-service attacks”,
- (j) “limit attack surfaces” – “including external interfaces”,
- (k) reduce the impact of an incident “using appropriate exploitation mitigation mechanisms and techniques”.
The CRA names no Kubernetes setting. It requires that you can justify why your default settings are secure. The Trivy rules and the Kubernetes Pod Security Standards are a recognised yardstick for that; you write down every deviation with its reason.
Drill 1: What is open from the factory
Where you are: on werk1.
What you have afterwards: the misconfigurations of 1.0.0 as JSON in
~/kurs/05/konfig-1.0.0.json.
trivy config reads files, not running pods. It
recognises Containerfiles, Kubernetes manifests and Helm charts by
itself and renders a chart with its default values before checking
it.
Step 1 – a folder for the exercise.
# on werk1
mkdir -p ~/kurs/05# on werk1
cd ~/lotseStep 2 – the overview.
# on werk1
trivy config --quiet .configchecks configuration files instead of images.--quietsuppresses info messages and the progress display..is the folder Trivy searches – here your repository.
Expected (excerpt – the summary at the beginning, followed by every finding with an explanation):
Report Summary
┌─────────────────────────────┬────────────┬───────────────────┐
│ Target │ Type │ Misconfigurations │
├─────────────────────────────┼────────────┼───────────────────┤
│ Containerfile │ dockerfile │ 2 │
├─────────────────────────────┼────────────┼───────────────────┤
│ chart/templates/lotse.yaml │ helm │ 18 │
├─────────────────────────────┼────────────┼───────────────────┤
│ chart/templates/ollama.yaml │ helm │ 18 │
└─────────────────────────────┴────────────┴───────────────────┘
Below the table, Trivy shows every finding with ID, severity, explanation, link and the affected lines, for example:
KSV-0014 (HIGH): Container 'lotse' of Deployment 'lotse' should set 'securityContext.readOnlyRootFilesystem' to true
Step 3 – as JSON for comparison. 38 findings with explanations are too long to read. You save them as JSON and have one line per finding printed:
# on werk1
trivy config --quiet --format json --output ~/kurs/05/konfig-1.0.0.json .# on werk1
jq -r '.Results[] | .Target as $t | .Misconfigurations[]? | select(.Status == "FAIL") | [$t, .ID, .Severity, .Title] | @tsv' ~/kurs/05/konfig-1.0.0.json| Part | Meaning |
|---|---|
.Target as $t |
remembers the file name for the output |
.Misconfigurations[]? |
every checked rule; ? skips files without findings |
select(.Status == "FAIL") |
only violated rules |
@tsv |
columns separated by tabs |
Expected:
Containerfile DS-0002 HIGH Image user should not be 'root'
Containerfile DS-0026 LOW No HEALTHCHECK defined
chart/templates/lotse.yaml KSV-0001 MEDIUM Can elevate its own privileges
chart/templates/lotse.yaml KSV-0003 LOW Default capabilities: some containers do not drop all
chart/templates/lotse.yaml KSV-0004 LOW Default capabilities: some containers do not drop any
chart/templates/lotse.yaml KSV-0011 LOW CPU not limited
chart/templates/lotse.yaml KSV-0012 MEDIUM Runs as root user
chart/templates/lotse.yaml KSV-0014 HIGH Root file system is not read-only
chart/templates/lotse.yaml KSV-0015 LOW CPU requests not specified
chart/templates/lotse.yaml KSV-0016 LOW Memory requests not specified
chart/templates/lotse.yaml KSV-0018 LOW Memory not limited
chart/templates/lotse.yaml KSV-0020 LOW Runs with UID <= 10000
chart/templates/lotse.yaml KSV-0021 LOW Runs with GID <= 10000
chart/templates/lotse.yaml KSV-0030 LOW Runtime/Default Seccomp profile not set
chart/templates/lotse.yaml KSV-0104 MEDIUM Seccomp policies disabled
chart/templates/lotse.yaml KSV-0106 LOW Container capabilities must only include NET_BIND_SERVICE
chart/templates/lotse.yaml KSV-0110 LOW Workloads in the default namespace
chart/templates/lotse.yaml KSV-0118 HIGH Default security context configured
chart/templates/lotse.yaml KSV-0118 HIGH Default security context configured
chart/templates/lotse.yaml KSV-0125 MEDIUM Restrict container images to trusted registries
chart/templates/ollama.yaml KSV-0001 MEDIUM Can elevate its own privileges
chart/templates/ollama.yaml KSV-0003 LOW Default capabilities: some containers do not drop all
chart/templates/ollama.yaml KSV-0004 LOW Default capabilities: some containers do not drop any
chart/templates/ollama.yaml KSV-0011 LOW CPU not limited
chart/templates/ollama.yaml KSV-0012 MEDIUM Runs as root user
chart/templates/ollama.yaml KSV-0014 HIGH Root file system is not read-only
chart/templates/ollama.yaml KSV-0015 LOW CPU requests not specified
chart/templates/ollama.yaml KSV-0016 LOW Memory requests not specified
chart/templates/ollama.yaml KSV-0018 LOW Memory not limited
chart/templates/ollama.yaml KSV-0020 LOW Runs with UID <= 10000
chart/templates/ollama.yaml KSV-0021 LOW Runs with GID <= 10000
chart/templates/ollama.yaml KSV-0030 LOW Runtime/Default Seccomp profile not set
chart/templates/ollama.yaml KSV-0104 MEDIUM Seccomp policies disabled
chart/templates/ollama.yaml KSV-0106 LOW Container capabilities must only include NET_BIND_SERVICE
chart/templates/ollama.yaml KSV-0110 LOW Workloads in the default namespace
chart/templates/ollama.yaml KSV-0118 HIGH Default security context configured
chart/templates/ollama.yaml KSV-0118 HIGH Default security context configured
chart/templates/ollama.yaml KSV-0125 MEDIUM Restrict container images to trusted registries
What you see: 38 findings that fall into five groups:
| Group | Rules | Annex I, Part I, point 2 |
|---|---|---|
| runs as root | DS-0002, KSV-0012, -0020, -0021, -0118 | k (limit the impact) |
| too many privileges | KSV-0001, -0003, -0004, -0106, -0030, -0104 | k, j |
| file system writable | KSV-0014 | k |
| no resource limits | KSV-0011, -0015, -0016, -0018 | h (availability) |
| origin and location | KSV-0110, -0125, DS-0026 | – (you check these in Drill 5) |
There are two things trivy config does not see: the
default password and the NodePort. For Trivy, both are valid
configuration. You know both from Day 1 – a scan does not replace
looking at the attack surface.
Remember:
trivy configis the final inspection on the line for privileges and limits. It does not find the spare key under the floor mat – you find that only in your own list of the attack surface.
Save your progress? Sign up for free
Drill 2: An image without tools and without root
Where you are: on werk1.
What you have afterwards: the image
werk1:5000/bewerbungslotse:1.0.1-rc1, which runs as user 10001 and contains no pip.
rc1 stands for “Release Candidate 1”, the first
candidate for version 1.0.1. You ship the final 1.0.1 with the updated
libraries on Day 6.
Step 1 – the Containerfile. Two stages: in the first, pip installs the packages into a folder; in the second, you copy only this folder into a fresh base image from which you remove pip.
# on werk1
nano ~/lotse/Containerfile# Stufe 1: Pakete bauen – pip wird nur hier gebraucht
FROM docker.io/library/python:3.12-slim AS bau
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --target /app/pakete -r requirements.txt
# Stufe 2: Laufzeit – ohne pip, als eigener Benutzer
FROM docker.io/library/python:3.12-slim
RUN pip uninstall --yes pip
WORKDIR /app
COPY --from=bau /app/pakete /app/pakete
COPY app.py .
ENV PYTHONPATH=/app/pakete
USER 10001:10001
EXPOSE 8080
CMD ["python", "-m", "gunicorn", "--bind", "0.0.0.0:8080", "--timeout", "300", "--worker-tmp-dir", "/tmp", "app:app"]| Line | Meaning |
|---|---|
FROM … AS bau |
first stage, named bau |
pip install --target /app/pakete |
installs the packages into a separate folder instead of into the system |
RUN pip uninstall --yes pip |
removes pip from the runtime stage; --yes does not ask
for confirmation |
COPY --from=bau |
takes over only the package folder from the first stage |
ENV PYTHONPATH=/app/pakete |
Python also looks for packages in this folder |
USER 10001:10001 |
all following commands and the start run as user and group 10001 |
python -m gunicorn |
starts gunicorn as a module – the start script is not in the package folder |
--worker-tmp-dir /tmp |
gunicorn stores helper files under /tmp; in a moment
this becomes the only writable directory besides
/daten |
User 10001 does not exist in the image as an entry in
/etc/passwd. Linux does not mind: a process runs with a
number, a name is only a label. Values above 10000 avoid overlaps with
users of the node.
Step 2 – the program. Three changes in
app.py: no default password, the export is switched off
without a password, and the comparison runs in constant time.
# on werk1
nano ~/lotse/app.py"""Bewerbungslotse – sortiert Bewerbungen mit einem Sprachmodell vor."""
import hmac
import json
import os
import uuid
from pathlib import Path
import requests
from flask import Flask, abort, jsonify, request, send_file
VERSION = "1.0.1-rc1"
OLLAMA = os.environ.get("OLLAMA_URL", "http://ollama:11434")
MODELL = os.environ.get("MODELL", "qwen3:4b-instruct")
ABLAGE = Path(os.environ.get("ABLAGE", "/daten"))
# strip(): eine Passwortdatei endet meist mit einem Zeilenumbruch
ADMIN_PASSWORT = os.environ.get("ADMIN_PASSWORT", "").strip()
ANWEISUNG = (
"Du hilfst einer Personalabteilung. Bewerte, wie gut die Bewerbung zur Stelle passt. "
'Antworte nur mit JSON: {"passung": <Zahl von 1 bis 5>, "begruendung": "<ein Satz>"}'
)
app = Flask(__name__)
@app.get("/gesund")
def gesund():
return {"status": "ok", "version": VERSION}
@app.post("/api/bewerbungen")
def bewerbung_anlegen():
daten = request.get_json(force=True)
frage = f"Stelle: {daten['stelle']}\n\nBewerbung:\n{daten['text']}"
antwort = requests.post(
f"{OLLAMA}/api/chat",
json={
"model": MODELL,
"stream": False,
"format": "json",
"options": {"temperature": 0},
"messages": [
{"role": "system", "content": ANWEISUNG},
{"role": "user", "content": frage},
],
},
timeout=300,
)
antwort.raise_for_status()
bewertung = json.loads(antwort.json()["message"]["content"])
akte = {
"nummer": uuid.uuid4().hex[:8],
"name": daten["name"],
"stelle": daten["stelle"],
"bewertung": bewertung,
}
(ABLAGE / f"{akte['nummer']}.json").write_text(json.dumps(akte, ensure_ascii=False))
return jsonify(akte), 201
@app.get("/api/bewerbungen/<nummer>")
def bewerbung_lesen(nummer):
akte = ABLAGE / f"{nummer}.json"
if not nummer.isalnum() or not akte.exists():
abort(404)
return json.loads(akte.read_text())
@app.post("/api/bewerbungen/<nummer>/anlagen")
def anlage_hochladen(nummer):
datei = request.files["datei"]
ordner = ABLAGE / "anlagen" / nummer
ordner.mkdir(parents=True, exist_ok=True)
datei.save(ordner / Path(datei.filename).name)
return {"gespeichert": f"{nummer}/{Path(datei.filename).name}"}, 201
@app.get("/api/anlagen/<path:name>")
def anlage_herunterladen(name):
return send_file(ABLAGE / "anlagen" / name)
@app.get("/api/admin/export")
def export():
if not ADMIN_PASSWORT:
abort(404)
zugang = request.authorization
if zugang is None or not hmac.compare_digest(zugang.password or "", ADMIN_PASSWORT):
abort(401)
return [json.loads(p.read_text()) for p in sorted(ABLAGE.glob("*.json"))]| Line | Meaning |
|---|---|
import hmac |
standard library; contains compare_digest |
VERSION = "1.0.1-rc1" |
the version that /gesund reports |
os.environ.get("ADMIN_PASSWORT", "").strip() |
empty instead of lotse without an environment variable;
strip() removes the line break at the end of a password
file |
if not ADMIN_PASSWORT: abort(404) |
without a password, the export does not exist at all |
hmac.compare_digest(…) |
compares in a way that the response time does not reveal how many characters match |
Step 3 – build.
# on werk1
cd ~/lotse# on werk1
podman build -t werk1:5000/bewerbungslotse:1.0.1-rc1 .Expected (excerpt – the beginning of the second stage and the last lines; the numbers differ):
[2/2] STEP 1/9: FROM docker.io/library/python:3.12-slim
[2/2] STEP 2/9: RUN pip uninstall --yes pip
Found existing installation: pip 25.0.1
Uninstalling pip-25.0.1:
Successfully uninstalled pip-25.0.1
…
[2/2] COMMIT werk1:5000/bewerbungslotse:1.0.1-rc1
--> 3a294dedb1da
Successfully tagged werk1:5000/bewerbungslotse:1.0.1-rc1
You can ignore the warning “Running pip as the ‘root’ user” during
uninstallation: during the build, this step still runs as root; only
USER switches over.
# on werk1
podman push werk1:5000/bewerbungslotse:1.0.1-rc1Expected (excerpt – the last line):
Writing manifest to image destination
Step 4 – check which user the image runs as.
# on werk1
podman run --rm werk1:5000/bewerbungslotse:1.0.1-rc1 idExpected:
uid=10001(10001) gid=10001(10001) groups=10001(10001)
On Day 1 this said uid=0(root).
Step 5 – check that pip is missing.
# on werk1
podman run --rm werk1:5000/bewerbungslotse:1.0.1-rc1 python -m pip --versionExpected:
/usr/local/bin/python: No module named pip
# on werk1
podman images --format '{{.Repository}}:{{.Tag}} {{.Size}}' werk1:5000/bewerbungslotseExpected:
werk1:5000/bewerbungslotse:1.0.1-rc1 137 MB
werk1:5000/bewerbungslotse:1.0.0 141 MB
What you see: four megabytes less – not much. The
gain lies elsewhere: an attacker who gets into the container cannot load
tools with pip, and six vulnerabilities of pip disappear from the scan
(Drill 6). apt stays in the image because the Debian base
image brings it along. An image entirely without a package manager would
be the next step – with a different base image and a new assessment of
all Debian matches. You deliberately do not decide that today.
Remember: The tools stay in the workshop: you build with pip and ship without it. And the vehicle runs on an ordinary key, not on the master key.
Save your progress? Sign up for free
Drill 3: A chart with secure default settings
Where you are: on werk1.
What you have afterwards: chart 1.0.1-rc1 with a mandatory password, ClusterIP,
securityContext, resource limits, a data volume and NetworkPolicies.
Step 1 – the values. values.yaml
contains what the operator gets if they specify nothing.
# on werk1
nano ~/lotse/chart/values.yamllotse:
image: werk1:5000/bewerbungslotse:1.0.1-rc1
# Pflichtwert, kein Standardpasswort: --set lotse.adminPasswort=…
adminPasswort: ""
service:
# ClusterIP: nur im Cluster erreichbar; NodePort nur bewusst setzen
typ: ClusterIP
nodePort: 30080
speicher: 1Gi
ollama:
image: docker.io/ollama/ollama:0.40.19
modell: qwen3:4b-instruct
knoten: werk1
speicher: 10Gi
# NetworkPolicies: nur der Lotse darf Ollama erreichen
netzwerkregeln: true| Value | before | now |
|---|---|---|
adminPasswort |
lotse |
empty – the chart demands a value |
service.typ |
NodePort hard-coded in the template | ClusterIP; NodePort only if the operator chooses
it |
speicher |
– (emptyDir, application files gone after a restart) | 1 GiB PersistentVolume |
netzwerkregeln |
– | true: NetworkPolicies on |
Step 2 – the Lotse’s template. Most of today’s changes are here.
# on werk1
nano ~/lotse/chart/templates/lotse.yamlapiVersion: v1
kind: Secret
metadata:
name: lotse-admin
type: Opaque
stringData:
passwort: {{ required "lotse.adminPasswort fehlt – es gibt kein Standardpasswort" .Values.lotse.adminPasswort | quote }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: lotse-daten
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.lotse.speicher }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: lotse
spec:
replicas: 1
selector:
matchLabels:
app: lotse
template:
metadata:
labels:
app: lotse
spec:
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: lotse
image: {{ .Values.lotse.image }}
ports:
- containerPort: 8080
env:
- name: OLLAMA_URL
value: http://ollama:11434
- name: MODELL
value: {{ .Values.ollama.modell }}
- name: ADMIN_PASSWORT
valueFrom:
secretKeyRef:
name: lotse-admin
key: passwort
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: "1"
memory: 512Mi
readinessProbe:
httpGet:
path: /gesund
port: 8080
volumeMounts:
- name: daten
mountPath: /daten
- name: tmp
mountPath: /tmp
volumes:
- name: daten
persistentVolumeClaim:
claimName: lotse-daten
- name: tmp
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: lotse
spec:
type: {{ .Values.lotse.service.typ }}
selector:
app: lotse
ports:
- port: 8080
targetPort: 8080
{{- if eq .Values.lotse.service.typ "NodePort" }}
nodePort: {{ .Values.lotse.service.nodePort }}
{{- end }}| Place | Meaning | Rule |
|---|---|---|
kind: Secret with required "…" |
the password goes into a Secret; without a value, Helm aborts with the message | – |
kind: PersistentVolumeClaim |
application files survive a restart | – |
automountServiceAccountToken: false |
the pod gets no access to the Kubernetes API | – |
runAsNonRoot: true |
Kubernetes does not start the container if it would run as root | KSV-0012 |
runAsUser/runAsGroup: 10001 |
user and group, even if the image specifies nothing | KSV-0020, -0021 |
fsGroup: 10001 |
mounted volumes belong to group 10001 – this lets the Lotse write to
/daten |
– |
seccompProfile: RuntimeDefault |
default filter for system calls | KSV-0030, -0104 |
valueFrom.secretKeyRef |
the environment variable comes from the Secret, not in plain text from the manifest | – |
allowPrivilegeEscalation: false |
no process may get more privileges than its parent process | KSV-0001 |
readOnlyRootFilesystem: true |
only the mounted volumes are writable | KSV-0014 |
capabilities.drop: [ALL] |
all single kernel privileges removed | KSV-0003, -0004, -0106 |
resources |
minimum requirement (requests) and upper limit
(limits) for CPU and memory |
KSV-0011, -0015, -0016, -0018 |
readinessProbe |
Kubernetes only sends requests once /gesund
answers |
DS-0026 in spirit |
tmp as emptyDir |
writable /tmp despite the read-only file system |
– |
type: {{ .Values.lotse.service.typ }} |
service type from the values; nodePort only with
NodePort |
– |
Step 3 – the template for Ollama. Ollama comes as a finished image from the supplier and runs as root. You restrict what is possible without rebuilding the image.
# on werk1
nano ~/lotse/chart/templates/ollama.yamlapiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ollama-modelle
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.ollama.speicher }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ollama
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: ollama
template:
metadata:
labels:
app: ollama
spec:
nodeSelector:
kubernetes.io/hostname: {{ .Values.ollama.knoten }}
automountServiceAccountToken: false
securityContext:
seccompProfile:
type: RuntimeDefault
containers:
- name: ollama
image: {{ .Values.ollama.image }}
ports:
- containerPort: 11434
# Das Zulieferer-Image läuft als root (siehe SCHWACHSTELLEN.md)
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
resources:
requests:
cpu: "1"
memory: 3Gi
limits:
memory: 6Gi
volumeMounts:
- name: modelle
mountPath: /root/.ollama
- name: tmp
mountPath: /tmp
volumes:
- name: modelle
persistentVolumeClaim:
claimName: ollama-modelle
- name: tmp
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: ollama
spec:
selector:
app: ollama
ports:
- port: 11434
targetPort: 11434runAsNonRoot is deliberately missing here – with this
setting, Ollama would not start. The challenge shows why. A CPU limit is
also deliberately missing: the model should be allowed to use all free
cores; you limit the memory.
Step 4 – the network rules. A new file with three NetworkPolicies.
# on werk1
nano ~/lotse/chart/templates/netzwerkregeln.yaml{{- if .Values.netzwerkregeln }}
# Grundregel: kein Pod im Namespace nimmt Verbindungen an
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: alles-zu
spec:
podSelector: {}
policyTypes:
- Ingress
---
# Ollama: nur vom Lotsen
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: ollama-nur-vom-lotsen
spec:
podSelector:
matchLabels:
app: ollama
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: lotse
ports:
- port: 11434
---
# Lotse: Port 8080 von überall (Service bzw. NodePort)
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: lotse-port-8080
spec:
podSelector:
matchLabels:
app: lotse
policyTypes:
- Ingress
ingress:
- ports:
- port: 8080
{{- end }}| Rule | Effect |
|---|---|
alles-zu |
podSelector: {} matches every pod in the namespace;
without an ingress list, every incoming connection is
forbidden |
ollama-nur-vom-lotsen |
pods with app: ollama accept port 11434 only from pods
with app: lotse |
lotse-port-8080 |
pods with app: lotse accept port 8080 from anywhere –
otherwise the service itself would be closed |
NetworkPolicies only take effect if the cluster network enforces them. k3s brings its own rule service for this; with other distributions you have to check.
Step 5 – the chart version.
# on werk1
nano ~/lotse/chart/Chart.yamlapiVersion: v2
name: bewerbungslotse
description: Sortiert Bewerbungen mit einem Sprachmodell vor
type: application
version: 1.0.1-rc1
appVersion: "1.0.1-rc1"Step 6 – check the chart, first without a password.
# on werk1
helm lint ~/lotse/chartExpected:
level=WARN msg="missing required values" message="lotse.adminPasswort fehlt – es gibt kein Standardpasswort"
==> Linting /home/ubuntu/lotse/chart
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, 0 chart(s) failed
helm lint only warns – it checks the structure. An
installation without a value aborts.
# on werk1
helm lint ~/lotse/chart --set lotse.adminPasswort=testExpected:
==> Linting /home/ubuntu/lotse/chart
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, 0 chart(s) failed
Remember: No spare key under the floor mat:
requiredforces the operator to set their own password. What cannot be locked without a rebuild – Ollama as root – you write down.
Save your progress? Sign up for free
Drill 4: Rolling out with your own password
Where you are: on werk1.
What you have afterwards: 1.0.1-rc1 in the cluster, the password in a file that only you can read.
Step 1 – a place for secrets.
# on werk1
mkdir -p ~/geheim# on werk1
chmod 700 ~/geheim700 means: only the owner may read, write and enter the
folder.
Step 2 – a random password.
# on werk1
openssl rand -hex -out ~/geheim/admin-passwort 16| Option | Meaning |
|---|---|
rand |
generates random bytes |
-hex |
outputs them as hexadecimal characters |
-out <file> |
writes to the file instead of to the screen |
16 |
16 bytes, i.e. 32 characters; must come last |
# on werk1
chmod 600 ~/geheim/admin-passwortDo not print the password with cat while anyone is
watching. In a moment you only need it as a file.
Step 3 – roll out.
# on werk1
helm upgrade lotse ~/lotse/chart -n lotse --set-file lotse.adminPasswort=$HOME/geheim/admin-passwort --wait --timeout 5m| Option | Meaning |
|---|---|
lotse |
name of the installation (release) |
~/lotse/chart |
the changed chart |
-n lotse |
namespace |
--set-file lotse.adminPasswort=<file> |
sets the value to the content of the file – the password appears neither on the command line nor in the shell history |
--wait |
waits until all pods are ready |
--timeout 5m |
gives up after five minutes |
After --set-file there is $HOME instead of
~, because the shell does not expand the tilde after the
equals sign.
Expected (your revision is 4; I had one failed attempt before):
Release "lotse" has been upgraded. Happy Helming!
NAME: lotse
LAST DEPLOYED: Thu Dec 3 12:09:40 2026
NAMESPACE: lotse
STATUS: deployed
REVISION: 5
DESCRIPTION: Upgrade complete
TEST SUITE: None
Step 4 – what is in the namespace now.
# on werk1
kubectl -n lotse get pods,svc,netpol,pvcExpected:
NAME READY STATUS RESTARTS AGE
pod/lotse-67c5756f9-d48j5 1/1 Running 0 24s
pod/ollama-5f5ffc5cf-7jxtd 1/1 Running 0 38s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/lotse ClusterIP 10.43.146.193 <none> 8080/TCP 88m
service/ollama ClusterIP 10.43.238.68 <none> 11434/TCP 88m
NAME POD-SELECTOR AGE
networkpolicy.networking.k8s.io/alles-zu <none> 40s
networkpolicy.networking.k8s.io/lotse-port-8080 app=lotse 40s
networkpolicy.networking.k8s.io/ollama-nur-vom-lotsen app=ollama 40s
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
persistentvolumeclaim/lotse-daten Bound pvc-656a09c3-9a67-4051-8136-79f978d1a0a4 1Gi RWO local-path <unset> 40s
persistentvolumeclaim/ollama-modelle Bound pvc-ea7a7a6c-dbe1-4620-a467-3adfe32c6965 10Gi RWO local-path <unset> 88m
| Line | Meaning |
|---|---|
service/lotse ClusterIP |
no more port 30080; the service only has an address inside the cluster |
three networkpolicy |
the rules from Drill 3 |
lotse-daten Bound |
the new volume for the application files |
The application files from Day 0 were in the emptyDir and disappeared with the old pod. That was exactly one of the open items from Day 1.
Step 5 – reset to the factory state. Letter (b) requires that the product can be reset to its original state. For a chart, this means: discard all values someone set later – a NodePort, for example – and specify only the mandatory password again.
# on werk1
helm upgrade lotse ~/lotse/chart -n lotse --reset-values --set-file lotse.adminPasswort=$HOME/geheim/admin-passwort --wait --timeout 5m--reset-values forgets all values set so far and starts
from values.yaml.
Expected (excerpt – your revision is 5):
Release "lotse" has been upgraded. Happy Helming!
…
REVISION: 6
DESCRIPTION: Upgrade complete
Remember: The key is handed over in person: the password lives in a file with permissions 600 and goes into the Secret with
--set-file– never on the command line, never invalues.yaml.
Save your progress? Sign up for free
Drill 5: Measuring again
Where you are: on werk2 and werk1.
What you have afterwards: evidence for every hardening step and a configuration scan with nine justified findings.
A hardening step that you do not measure is a claim. You check every point of the attack surface from Day 1.
Step 1 – the NodePort from outside.
# on werk2
curl -s -m 5 -o /dev/null -w "%{http_code}\n" http://172.16.0.126:30080/gesund| Option | Meaning |
|---|---|
-m 5 |
wait at most five seconds |
-o /dev/null |
discard the response body |
-w "%{http_code}\n" |
print only the HTTP status |
Expected:
000
000 means: no answer. Port 30080 no longer exists. On
Day 1, every route answered from here.
Step 2 – the service inside the cluster. From the node you reach the ClusterIP. Read it off:
# on werk1
kubectl -n lotse get svc lotseExpected (your address differs):
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
lotse ClusterIP 10.43.146.193 <none> 8080/TCP 98m
Use your address in the next commands.
# on werk1
curl -s http://10.43.146.193:8080/gesundExpected:
{"status":"ok","version":"1.0.1-rc1"}
Does the Lotse still work even though it neither runs as root nor may
write? An application from Day 0, from your home folder, where
kurs/00 lives:
# on werk1
cd ~# on werk1
time curl -s -X POST -H "Content-Type: application/json" --data @kurs/00/bewerbung-mara.json http://10.43.146.193:8080/api/bewerbungenExpected (rating and number may differ):
{"bewertung":{"begruendung":"Die Bewerbung zeigt klare, relevante Erfahrung in Linux-Administration und Kubernetes mit konkreten Tools wie k3s, RKE2, Ansible und Helm-Charts, was die Stelle sehr gut passt.","passung":5},"name":"Mara Klein","nummer":"270969b6","stelle":"Linux-Administratorin (m/w/d) mit Kubernetes-Erfahrung"}
real 1m4.344s
The Lotse reached Ollama – the NetworkPolicy lets it through – and wrote the application file.
Step 3 – the old password.
# on werk1
curl -s -o /dev/null -w "%{http_code}\n" -u admin:lotse http://10.43.146.193:8080/api/admin/exportExpected:
401
And with your password? -u admin without a colon makes
curl ask for it. Open ~/geheim/admin-passwort
in a second window with nano and paste the content when
curl asks:
# on werk1
curl -s -o /dev/null -w "%{http_code}\n" -u admin http://10.43.146.193:8080/api/admin/exportExpected:
Enter host password for user 'admin':
200
Step 4 – a foreign pod queries Ollama. On Day 1, the
test pod neugier got to Ollama without any trouble.
# on werk1
kubectl -n lotse run neugier --image=docker.io/curlimages/curl:8.17.0 --rm -i --restart=Never -- curl -s -m 5 -o /dev/null -w '%{http_code}\n' http://ollama:11434/api/versionExpected (excerpt – between notices from
kubectl):
000
pod "neugier" deleted from lotse namespace
pod lotse/neugier terminated (Error)
000 and Error: the NetworkPolicy only lets
pods with app: lotse through.
Step 5 – inside the container.
# on werk1
kubectl -n lotse exec deploy/lotse -- idExpected:
uid=10001 gid=10001 groups=10001
# on werk1
kubectl -n lotse exec deploy/lotse -- touch /app/halloExpected:
touch: cannot touch '/app/hallo': Read-only file system
command terminated with exit code 1
An attacker could not change app.py.
# on werk1
kubectl -n lotse exec deploy/lotse -- ls /datenExpected (your number differs):
270969b6.json
The application file from step 2 is on the volume.
Step 6 – the configuration scan. Because the chart now has a mandatory password, you give Trivy a value. The diagnosis task shows why this is necessary.
# on werk1
cd ~/lotse# on werk1
trivy config --quiet --helm-set lotse.adminPasswort=nurfuerdenscan --format json --output ~/kurs/05/konfig-gehaertet.json .--helm-set sets a value when rendering the chart, like
--set in Helm. The value is a placeholder, not your
password.
# on werk1
jq -r '.Results[] | [.Target, .MisconfSummary.Successes, .MisconfSummary.Failures] | @tsv' ~/kurs/05/konfig-gehaertet.jsonExpected (file, passed rules, violated rules):
Containerfile 26 1
chart/templates/lotse.yaml 97 2
chart/templates/netzwerkregeln.yaml 61 0
chart/templates/ollama.yaml 93 6
# on werk1
jq -r '.Results[] | .Target as $t | .Misconfigurations[]? | select(.Status == "FAIL") | [$t, .ID, .Severity, .Title] | @tsv' ~/kurs/05/konfig-gehaertet.jsonExpected:
Containerfile DS-0026 LOW No HEALTHCHECK defined
chart/templates/lotse.yaml KSV-0110 LOW Workloads in the default namespace
chart/templates/lotse.yaml KSV-0125 MEDIUM Restrict container images to trusted registries
chart/templates/ollama.yaml KSV-0011 LOW CPU not limited
chart/templates/ollama.yaml KSV-0012 MEDIUM Runs as root user
chart/templates/ollama.yaml KSV-0020 LOW Runs with UID <= 10000
chart/templates/ollama.yaml KSV-0021 LOW Runs with GID <= 10000
chart/templates/ollama.yaml KSV-0110 LOW Workloads in the default namespace
chart/templates/ollama.yaml KSV-0125 MEDIUM Restrict container images to trusted registries
Of 38 findings, 9 remain. Each one gets a reason:
| Finding | Reason | Decision |
|---|---|---|
| DS-0026 no HEALTHCHECK | Kubernetes does not evaluate HEALTHCHECK; the
readinessProbe in the chart takes over |
accepted |
| KSV-0110 namespace default (2×) | the templates name no namespace; installation uses
-n lotse |
false alarm |
| KSV-0125 registries (2×) | which registries are allowed is up to the operator, with an admission rule | operator’s responsibility |
| KSV-0011 Ollama without CPU limit | the model should use free cores; memory is limited | deliberate |
| KSV-0012, -0020, -0021 Ollama as root | supplier’s image | open item, see challenge |
Remember: First measure, then tick off: from outside (NodePort), from inside (foreign pod), in the container (user, file system) and with the scan. Whatever remains gets a reason or a date.
Save your progress? Sign up for free
Drill 6: Into the workshop log and into Git
Where you are: on werk1.
What you have afterwards: product profile, workshop log and a vulnerability scan of 1.0.1-rc1 in Git.
Step 1 – vulnerabilities of 1.0.1-rc1.
# on werk1
cd ~/lotse/scans# on werk1
grype registry:werk1:5000/bewerbungslotse:1.0.1-rc1 -o json --file grype-1.0.1-rc1.json# on werk1
jq '.matches | length' grype-1.0.1-rc1.jsonExpected:
260
# on werk1
jq '[.matches[] | select(.artifact.name == "pip")] | length' grype-1.0.1-rc1.jsonExpected:
0
266 minus 6 matches from pip – exactly the group from your workshop log that was due today.
Step 2 – the product profile. The attack surface has changed, and the secure by default configuration gets its own section.
# on werk1
nano ~/lotse/PRODUKT.md# Produktsteckbrief Bewerbungslotse
## Produkt
- Name: Bewerbungslotse
- Version: 1.0.0 (Image werk1:5000/bewerbungslotse:1.0.0, Chart bewerbungslotse 1.0.0)
- Hersteller: Beispielwerk GmbH (fiktiv)
- Zweckbestimmung: sortiert Bewerbungen mit einem Sprachmodell vor
(Passung 1 bis 5 mit Begründung)
- Auslieferung: Container-Image und Helm-Chart; wir betreiben es auch selbst
## Einstufung nach CRA
- Produkt mit digitalen Elementen: ja (Software, Art. 3 Nr. 1)
- Rolle: Hersteller (Art. 3 Nr. 13)
- Anhang III (wichtig, Klasse I/II): nein – keine der Kategorien
- Anhang IV (kritisch): nein
- Ergebnis: Standardprodukt, Konformität durch interne Kontrolle
(Modul A, Art. 32 Abs. 1)
## Unterstützungszeitraum (Art. 13 Abs. 8 und 19)
- Inverkehrbringen geplant: 12/2027
- Ende des Unterstützungszeitraums: 12/2032 (fünf Jahre)
- Begründung: Personalsoftware wird typischerweise mehrere Jahre
genutzt; das Grundimage python:3.12-slim (Debian 13) und
Ollama sind Komponenten mit eigenen Lebenszyklen
## Bestandteile (Stand Tag 1)
| Teil | Version | Herkunft |
|---|---|---|
| Programm app.py | 1.0.0 | eigen |
| Python-Pakete | 14 Stück, requirements.txt | PyPI |
| Python | 3.12.16 | Grundimage |
| Debian-Pakete | 87 Stück | Grundimage Debian 13 |
| Ollama | 0.40.19 | docker.io/ollama/ollama |
| Sprachmodell | qwen3:4b-instruct, Apache 2.0 | Ollama-Bibliothek |
## Stückliste (SBOM, Anhang I Teil II Nr. 1)
- sbom/bewerbungslotse-1.0.0.cdx.json (CycloneDX 1.7, Syft 1.57.2)
- sbom/bewerbungslotse-1.0.0.spdx.json (SPDX, Syft 1.57.2)
- sbom/ollama-0.40.19.cdx.json (Zulieferer-Image; Version des
Hauptmoduls fehlt dort, gilt: 0.40.19)
- Erzeugt aus dem Image in der Registry, nicht aus dem Quellordner
- Nicht enthalten: Sprachmodell qwen3:4b-instruct (siehe Bestandteile)
## Angriffsfläche (Stand Tag 5, Version 1.0.1-rc1)
| Schnittstelle | Erreichbar von | Schutz |
|---|---|---|
| Service lotse :8080 (ClusterIP) | im Cluster und vom Knoten | NodePort nur, wenn der Betreiber ihn setzt |
| /api/admin/export | wie oben | Passwort Pflicht, kein Standardwert; ohne Passwort abgeschaltet |
| Ollama :11434 | nur Pods mit app=lotse | NetworkPolicy |
## Sichere Standardkonfiguration (Anhang I Teil I Nr. 2 b)
- Kein Standardpasswort: Helm bricht ohne lotse.adminPasswort ab
- Service vom Typ ClusterIP statt NodePort
- NetworkPolicies: alles zu, nur Lotse → Ollama und Port 8080 zum Lotsen
- Lotse: Benutzer 10001, kein root, keine Rechteausweitung, alle
Capabilities entfernt, Dateisystem nur lesbar, Seccomp RuntimeDefault,
kein Service-Account-Token, CPU/Speicher begrenzt
- Laufzeit-Image ohne pip (mehrstufiger Bau)
- Akten auf einem PersistentVolume statt emptyDir
- Prüfung: trivy config mit --helm-set, Befunde siehe SCHWACHSTELLEN.md
- Zurücksetzen auf die Werkseinstellungen: helm upgrade mit
--reset-values (nur das Passwort neu angeben)
## Offene Punkte
- Ollama läuft als root (Zulieferer-Image); als Benutzer 10001
getestet, braucht HOME auf eigenem Volume und neu geladenes Modell
- keine Zugriffs- und Entscheidungsprotokolle
- keine Verschlüsselung zwischen Lotse und Ollama (nur im Cluster)Step 3 – the workshop log. The pip line is done, and the nine findings of the configuration scan get their reason.
# on werk1
nano ~/lotse/SCHWACHSTELLEN.md# Schwachstellen Bewerbungslotse 1.0.0
Stand: 2026-12-03 · Scanner: Grype 0.122.1 (Datenbank vom 2026-12-03),
Gegenprobe Trivy 0.77.0 · Grundlage: sbom/bewerbungslotse-1.0.0.cdx.json
## Überblick
- 266 Treffer (Grype): 220 Debian, 32 Python, 14 Python-Interpreter
- Im KEV-Katalog der CISA (Stand 2026.11.30): keiner
- Höchstes EPSS: CVE-2026-21441 (urllib3), 2,9 %
## Entscheidungen
| Gruppe | Treffer | Entscheidung | Wann |
|---|---|---|---|
| Python-Pakete außer pip | 26 | aktualisieren auf Mindestversion | Tag 6 |
| davon Werkzeug safe_join (nur Windows) | 5 | für 1.0.0: nicht betroffen, VEX | erledigt |
| davon Jinja2-Sandbox (nicht genutzt) | 3 | für 1.0.0: nicht betroffen, VEX | erledigt |
| pip (nur beim Bau gebraucht) | 6 | aus dem Laufzeit-Image entfernt (1.0.1-rc1: 260 Treffer) | erledigt |
| Python-Interpreter (über CPE geraten) | 14 | einzeln prüfen; CVE-2025-12781 in VEX als under_investigation | offen |
| Debian mit Korrektur | 3 | Neubau mit aktuellem Grundimage | Tag 6 |
| Debian ohne Korrektur | 217 | Debian-Bewertung übernehmen, Grundimage aktuell halten | laufend |
| davon OpenSSL QUIC CVE-2026-124709 (3 Pakete) | 3 | nicht betroffen, VEX | erledigt |
## VEX
- vex/bewerbungslotse-1.0.0.openvex.json (OpenVEX 0.2.0, 11 Aussagen)
- Produkt: pkg:oci/bewerbungslotse@sha256:b2ff3085… (Digest von 1.0.0)
- Scan mit VEX nur gegen das Image, nicht gegen die Stückliste
## Betrifft uns sicher
- CVE-2024-49767 (Werkzeug 3.0.3, Speicher erschöpfen beim Lesen von
Formulardaten): app.py nimmt Anlagen über request.files an –
erreichbar über POST /api/bewerbungen/<nummer>/anlagen
## Mindestversionen (Python)
| Paket | ist | mindestens |
|---|---|---|
| certifi | 2024.2.2 | 2026.10.18 |
| flask | 3.0.3 | 3.1.3 |
| idna | 3.6 | 3.15 |
| jinja2 | 3.1.4 | 3.1.6 |
| requests | 2.31.0 | 2.33.0 |
| urllib3 | 2.2.1 | 2.8.0 |
| werkzeug | 3.0.3 | 3.1.9 |
## Fehlkonfigurationen (trivy config, Stand 1.0.1-rc1)
- 1.0.0: 38 Befunde, 1.0.1-rc1: 9 Befunde
- Ollama läuft als root (KSV-0012, -0020, -0021): Zulieferer-Image,
akzeptiert für 1.0.1, Umstellung auf Benutzer 10001 geplant
- Ollama ohne CPU-Grenze (KSV-0011): bewusst, das Modell soll alle
freien Kerne nutzen; Speicher ist begrenzt
- Namespace default (KSV-0110): Fehlalarm, das Chart wird mit -n lotse
installiert
- Vertrauenswürdige Registries (KSV-0125): regelt der Betreiber per
Zulassungsregel, nicht das Chart
- Kein HEALTHCHECK im Containerfile (DS-0026): Kubernetes nutzt die
readinessProbe im ChartStep 4 – commit.
# on werk1
cd ~/lotse# on werk1
git status --shortExpected:
M Containerfile
M PRODUKT.md
M SCHWACHSTELLEN.md
M app.py
M chart/Chart.yaml
M chart/templates/lotse.yaml
M chart/templates/ollama.yaml
M chart/values.yaml
?? chart/templates/netzwerkregeln.yaml
?? scans/grype-1.0.1-rc1.json
# on werk1
git add Containerfile app.py chart PRODUKT.md SCHWACHSTELLEN.md scans/grype-1.0.1-rc1.json# on werk1
git commit -m "1.0.1-rc1: sichere Standardkonfiguration, Laufzeit-Image ohne pip"Expected:
[main ee2aa48] 1.0.1-rc1: sichere Standardkonfiguration, Laufzeit-Image ohne pip
10 files changed, 192 insertions(+), 24 deletions(-)
create mode 100644 chart/templates/netzwerkregeln.yaml
create mode 100644 scans/grype-1.0.1-rc1.json
The password lives in ~/geheim, outside the repository.
It never goes into Git.
Remember: The type approval describes the delivery state: what is set from the factory and why is written in the product profile – in the same commit as the chart that sets it.
Save your progress? Sign up for free
Diagnosis task
A colleague builds the configuration scan into the pipeline, with the same command as in Drill 1. She is pleased: after the hardening, Trivy reports only a single finding – not nine as for you. This is how you reproduce it:
# on werk1
cd ~/lotse# on werk1
trivy config --quiet --format json --output ~/kurs/05/konfig-ohne-werte.json .# on werk1
jq -r '.Results[] | [.Target, .MisconfSummary.Failures] | @tsv' ~/kurs/05/konfig-ohne-werte.jsonExpected:
Containerfile 1
Find out where the other eight findings went.
Solution path:
Not only findings are missing, entire files are missing: the chart does not show up at all. Is it broken?
# on werk1 helm template ~/lotse/chartExpected:
Error: execution error at (bewerbungslotse/templates/lotse.yaml:7:15): lotse.adminPasswort fehlt – es gibt kein Standardpasswort Use --debug flag to render out invalid YAMLWithout a password, the chart cannot be rendered – that is how it should be.
And Trivy? Leave out
--quiet:# on werk1 trivy config --format json --output ~/kurs/05/konfig-ohne-werte.json .Expected (cut off on the right):
2026-12-03T12:19:37Z INFO [misconfig] Misconfiguration scanning is enabled 2026-12-03T12:19:37Z INFO [checks-client] Using existing checks from cache path="/home/ubuntu/.cache/trivy/policy/content" 2026-12-03T12:19:43Z WARN [helm scanner] Skipping chart file_path="chart" err="parse chart: execution error at (bewerbungslotse/templates/lotse.yaml:7:15): lotse.adminPasswort fehlt – es gibt kein Standardpasswort" 2026-12-03T12:19:43Z INFO Detected config files num=1The cause: Trivy renders the chart like Helm. If rendering fails, Trivy skips the chart with a warning – and
--quietswallows warnings too. The exit code stays 0, the pipeline stays green.Detected config files num=1gives it away: only the Containerfile was checked.The fix: pass values that make rendering possible –
--helm-set lotse.adminPasswort=nurfuerdenscanas in Drill 5 – and check in the pipeline that all expected files appear in the result.
The lesson: the hardening that makes the chart secure has made the scan blind. A scan that finds nothing is only good once you know that it actually looked.
Challenge
Your workshop log says “Ollama runs as root”. A customer asks why you
don’t simply set runAsNonRoot: true as for the Lotse. Try
it with a single test pod and find out what would be necessary for
Ollama to start as user 10001.
Solution:
A pod with runAsNonRoot:
# on werk1
nano ~/kurs/05/ollama-nichtroot.yamlapiVersion: v1
kind: Pod
metadata:
name: ollama-nichtroot
spec:
securityContext:
runAsNonRoot: true
containers:
- name: ollama
image: docker.io/ollama/ollama:0.40.19# on werk1
kubectl -n lotse apply -f ~/kurs/05/ollama-nichtroot.yaml# on werk1
kubectl -n lotse get pod ollama-nichtrootExpected:
NAME READY STATUS RESTARTS AGE
ollama-nichtroot 0/1 CreateContainerConfigError 0 16s
# on werk1
kubectl -n lotse get events --field-selector involvedObject.name=ollama-nichtrootExpected (excerpt – the last line, cut off on the right):
4s Warning Failed pod/ollama-nichtroot Error: container has runAsNonRoot and image will run as root (pod: "ollama-nichtroot_lotse(5cd899e0-…
The image names no user, so it would be root – and
runAsNonRoot refuses to start it. Kubernetes only checks
whether a user other than 0 is fixed. You give it one:
# on werk1
nano ~/kurs/05/ollama-10001.yamlapiVersion: v1
kind: Pod
metadata:
name: ollama-10001
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10001
containers:
- name: ollama
image: docker.io/ollama/ollama:0.40.19# on werk1
kubectl -n lotse apply -f ~/kurs/05/ollama-10001.yaml# on werk1
kubectl -n lotse get pod ollama-10001Expected:
NAME READY STATUS RESTARTS AGE
ollama-10001 0/1 Error 1 (14s ago) 17s
# on werk1
kubectl -n lotse logs ollama-10001 --tail 5Expected:
Couldn't find '/.ollama/id_ed25519'. Generating new private key.
Error: could not create directory mkdir /.ollama: permission denied
Now the container starts, but Ollama wants to create a key in its
home folder. User 10001 has no entry in /etc/passwd, so its
home folder is / – and it may not write there. You give it
a home folder on a volume:
# on werk1
kubectl -n lotse delete pod ollama-10001# on werk1
nano ~/kurs/05/ollama-10001.yamlapiVersion: v1
kind: Pod
metadata:
name: ollama-10001
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10001
containers:
- name: ollama
image: docker.io/ollama/ollama:0.40.19
env:
- name: HOME
value: /ollama
volumeMounts:
- name: zuhause
mountPath: /ollama
volumes:
- name: zuhause
emptyDir: {}# on werk1
kubectl -n lotse apply -f ~/kurs/05/ollama-10001.yaml# on werk1
kubectl -n lotse get pod ollama-10001Expected:
NAME READY STATUS RESTARTS AGE
ollama-10001 1/1 Running 0 14s
# on werk1
kubectl -n lotse exec ollama-10001 -- idExpected:
uid=10001 gid=0(root) groups=0(root)
Ollama runs as 10001. The group, however, is 0 (root), because
runAsGroup is missing – in the chart you would set it as
well. Clean up the test pods:
# on werk1
kubectl -n lotse delete pod ollama-nichtroot ollama-10001Expected:
pod "ollama-nichtroot" deleted from lotse namespace
pod "ollama-10001" deleted from lotse namespace
The answer to the customer: it is possible, but not with one line.
Ollama needs a writable home folder, and the model currently lives under
/root/.ollama on a volume that belongs to root – it would
have to be downloaded again or rewritten. That is why it is recorded as
an open item with a plan in the product profile instead of being
silently passed over.
Save your progress? Sign up for free
Checkpoint
# on werk1
helm list -n lotseExpected (excerpt – the columns STATUS, CHART and APP VERSION):
deployed bewerbungslotse-1.0.1-rc1 1.0.1-rc1
# on werk1
kubectl -n lotse get svc lotseExpected (excerpt): TYPE is
ClusterIP, under PORT(S) it says
8080/TCP without :30080.
# on werk1
kubectl -n lotse exec deploy/lotse -- idExpected:
uid=10001 gid=10001 groups=10001
# on werk2
curl -s -m 5 -o /dev/null -w "%{http_code}\n" http://172.16.0.126:30080/gesundExpected:
000
# on werk1
jq '[.Results[].Misconfigurations[]? | select(.Status == "FAIL")] | length' ~/kurs/05/konfig-gehaertet.jsonExpected:
9
# on werk1
git -C ~/lotse log --oneline --decorate -1Expected (your commit number differs):
ee2aa48 (HEAD -> main) 1.0.1-rc1: sichere Standardkonfiguration, Laufzeit-Image ohne pip
Test yourself
- Why does
trivy confignot find the default passwordlotseand the NodePort? - What happens if an operator installs chart 1.0.1-rc1 without
lotse.adminPasswort? - The Lotse runs with
readOnlyRootFilesystem: true. Where may it still write, and why? - Why do you pass the password with
--set-fileinstead of with--set lotse.adminPasswort=…? - After a change to the chart, your configuration scan in the pipeline suddenly reports zero findings. What do you check first?
- Which requirement from Annex I, Part I, point 2 does
--reset-valuesfulfil, and why ishelm rollbackto the first revision wrong for it?
Answers:
- For Trivy, both are valid settings; its rules check privileges, limits and origin. Whether a value is a default password or whether a port is meant to be open only the manufacturer knows – from their list of the attack surface.
- Helm aborts:
requiredreports “lotse.adminPasswort fehlt – es gibt kein Standardpasswort”. Nothing is installed. - To
/daten(PersistentVolume) and/tmp(emptyDir). Mounted volumes are exempt fromreadOnlyRootFilesystem;fsGroup: 10001gives the user write permission on/daten. - With
--set, the password would be on the command line: in the shell history and visible to other users in the process list.--set-filereads it from a file with permissions 600. - Whether the scan checked the chart at all: without
--quiet, the warning “Skipping chart” appears, and the list of files in the result shows whether the chart is missing. Usually a mandatory value is missing. - Letter (b), resetting to the original state:
--reset-valuesrestores the factory settings of the current chart.helm rollback 1would return to the insecure version 1.0.0 – with NodePort and default password.
Interview note
“How do you harden a Helm chart?” – Good answer: choose default
values so that an installation without values of your own is secure – no
default password (mandatory value with required, secret in
a Secret), ClusterIP instead of NodePort, NetworkPolicies with “deny
all” as the base rule, securityContext according to the Pod
Security Standards “restricted”, resource limits. Check with
trivy config in the pipeline, with mandatory values set and
a check that the chart really was scanned. If you want to go further:
every remaining finding is in the documentation with a reason, and
supplier images that run as root are a known open item with a plan.
Enterprise note
In large environments, the cluster itself enforces the minimum
standards: Pod Security Admission with the profile
restricted per namespace, or policy engines such as Kyverno
and OPA Gatekeeper, which for example only admit images from your own
registry (that is KSV-0125). As the manufacturer, you ship a chart that
runs under restricted and state in the documentation which
deviations are necessary. Benchmarks such as CIS Kubernetes or the BSI
modules SYS.1.6 (containerisation) and APP.4.4 (Kubernetes) – the BSI
being Germany’s federal cybersecurity agency – are the usual yardstick
for “secure configuration” in audits.
Summary
- According to
trivy config, 1.0.0 had 38 misconfigurations – plus a default password and a NodePort that no scan finds. - The image 1.0.1-rc1 is built in several stages, contains no pip and runs as user 10001.
- The chart enforces a password of your own (
required, Secret,--set-file), uses ClusterIP, NetworkPolicies,securityContext, resource limits and a volume for the application files. - Measured again: NodePort closed, old password 401, foreign pod cannot reach Ollama, file system read-only, rating works.
- Nine findings remain, each with a reason; Ollama as root is an open item with a plan.
- A mandatory value in the chart makes
trivy configsilently skip the chart – scan with--helm-set. - Vulnerabilities: 266 → 260, because pip is missing.
Commands at a glance
| Command | Purpose |
|---|---|
trivy config --quiet . |
misconfigurations in Containerfile, manifests and charts |
trivy config --helm-set <value>=<x> --format json --output <file> . |
scan a chart with mandatory values |
helm lint <chart> --set <value>=<x> |
check the structure of a chart |
openssl rand -hex -out <file> 16 |
random password into a file |
helm upgrade <release> <chart> -n <ns> --set-file <value>=<file> --wait |
roll out, secret from a file |
helm upgrade … --reset-values |
reset to the chart’s factory settings |
kubectl -n <ns> exec deploy/<name> -- id |
user in the running container |
kubectl -n <ns> get events --field-selector involvedObject.name=<pod> |
events of a pod |
curl -s -o /dev/null -w "%{http_code}\n" <url> |
query only the HTTP status |