Day 10: Checking Manifests
Goal: Check manifests before rolling them out: schema with kubeconform, best practices with kube-linter, kube-score and Polaris; read findings, switch them off selectively, and harden a manifest so that all four are satisfied · Duration: approx. 85 min · Prerequisite: Day 9
Briefing
- Popeye (Day 9) checks what runs in the cluster. Today’s tools check files before they reach the cluster: in the editor, in the pre-commit hook, in the pipeline.
- There are two kinds of checks, and they complement each other:
- Schema: Is this a valid Kubernetes object at all? Are field names and types correct? kubeconform checks this against the JSON schemas of the respective Kubernetes version.
- Rules: Is the object valid but unwise? No limits,
root,
latest, no PDB. kube-linter, kube-score and Polaris check this, each with its own rule set and its own opinion.
- The order matters: schema first, then rules. Drill 2 shows why.
| Tool | Version | Checks | Strength |
|---|---|---|---|
| kubeconform | v0.8.0 | schema | fast, version-exact, CRDs via schema catalogs |
| kube-linter | v0.8.3 | rules | clear checks, exceptions via annotation |
| kube-score | v1.20.0 | rules | relationships between objects (Service ↔︎ Pods, PDB, policy) |
| Polaris | v10.2.6 | rules | files and cluster, score, dashboard, admission |
For the day, you get a folder with all manifests of the shop and two new files.
Drill 1: Tools and Check Folder
ARCH=$(dpkg --print-architecture)
cd /tmp
curl -sL https://github.com/yannh/kubeconform/releases/download/v0.8.0/kubeconform-linux-${ARCH}.tar.gz | tar xz kubeconform
sudo install kubeconform /usr/local/bin/
KL=kube-linter-linux; [ "$ARCH" = arm64 ] && KL=kube-linter-linux_arm64
curl -sLo kube-linter https://github.com/stackrox/kube-linter/releases/download/v0.8.3/$KL
sudo install kube-linter /usr/local/bin/
curl -sL https://github.com/zegl/kube-score/releases/download/v1.20.0/kube-score_1.20.0_linux_${ARCH}.tar.gz | tar xz kube-score
sudo install kube-score /usr/local/bin/
curl -sL https://github.com/FairwindsOps/polaris/releases/download/v10.2.6/polaris_10.2.6_linux_${ARCH}.tar.gz | tar xz polaris
sudo install polaris /usr/local/bin/
kubeconform -v; kube-linter version; kube-score version; polaris versionExpected:
v0.8.0
0.8.3
kube-score version: 1.20.0, commit: 81371e9f53b633bec69423fc298295bd71bd869a, built: 2025-04-28T16:54:40Z
Polaris version:10.2.6
kube-linter breaks the pattern: the file for amd64 is called
kube-linter-linux, the one for arm64
kube-linter-linux_arm64, without an archive. Hence the line
with KL.
Now the check folder: the manifests of the last days, plus a
colleague’s new Deployment lieferung (delivery) and a
CiliumNetworkPolicy.
mkdir -p ~/werkzeuge/tag10/manifeste && cd ~/werkzeuge/tag10
cp ../tag00/laden.yaml ../tag07/kasse.yaml ../tag09/cache-svc.yaml ../tag08/api-policy.yaml manifeste/
cat > manifeste/neu.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: lieferung
namespace: laden
spec:
replica: 2
selector:
matchLabels: {app: lieferung}
template:
metadata:
labels: {app: lieferung}
spec:
containers:
- name: lieferung
image: nginx:latest
ports:
- containerPort: "80"
EOF
cat > manifeste/l7.yaml <<'EOF'
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: web-nur-get
namespace: laden
spec:
endpointSelector:
matchLabels: {app: web}
ingress:
- toPorts:
- ports: [{port: "80", protocol: TCP}]
rules:
http: [{method: GET}]
EOF
ls manifesteExpected:
api-policy.yaml cache-svc.yaml kasse.yaml l7.yaml laden.yaml neu.yaml
The copies show the state of the files, not of the
cluster: kasse.yaml without the volume from Day 7 and
without the requests from Day 9, cache-svc.yaml with the
wrong selector app=redis. That is everyday reality: what is
in the repo is not what is running.
Save your progress? Sign up for free
Drill 2: Schema with kubeconform
kubeconform -summary manifeste/
echo "exit $?"Expected (one long line wrapped):
manifeste/l7.yaml - CiliumNetworkPolicy web-nur-get failed validation: could not find schema for CiliumNetworkPolicy
manifeste/neu.yaml - Deployment lieferung is invalid: problem validating schema. Check JSON formatting: jsonschema validation failed with 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone/deployment-apps-v1.json#' - at '/spec/template/spec/containers/0/ports/0/containerPort': got string, want integer
Summary: 18 resources found in 6 files - Valid: 16, Invalid: 1, Errors: 1, Skipped: 0
exit 1
Two findings: containerPort: "80" is a string, not an
integer. And there is no schema for the CiliumNetworkPolicy, because
kubeconform only knows the built-in types. But the typo
replica: instead of replicas: is missing. By
default, the schema allows unknown fields. With -strict, it
does not:
kubeconform -strict -summary manifeste/neu.yamlExpected (shortened):
manifeste/neu.yaml - Deployment lieferung is invalid: … - at '/spec/template/spec/containers/0/ports/0/containerPort': got string, want integer - at '/spec': additional properties 'replica' not allowed
Summary: 1 resource found in 1 file - Valid: 0, Invalid: 1, Errors: 0, Skipped: 0
Without -strict, the cluster would have accepted the
Deployment and silently discarded replica: one replica
instead of two, without any error message. Always use
-strict.
You set the Kubernetes version with -kubernetes-version.
Without it, kubeconform checks against master, i.e. the
latest development state:
kubeconform -strict -kubernetes-version 1.37.0 -summary manifeste/laden.yamlExpected:
Summary: 13 resources found in 1 file - Valid: 13, Invalid: 0, Errors: 0, Skipped: 0
For CRDs, there are two ways: skip them
(-ignore-missing-schemas, then the file counts as
Skipped) or load schemas from a catalog. The community
catalog datreeio/CRDs-catalog contains schemas for many
common CRDs:
kubeconform -strict -summary -schema-location default \
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
manifeste/l7.yamlExpected:
Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0
The order of -schema-location matters: first the
built-in ones, then the catalog. In companies, you put the schemas of
your own CRDs into an internal repo and point there, instead of asking
GitHub on every run.
Why schema first? Look at what kube-linter does with the broken file:
kube-linter lint manifeste/neu.yaml; echo "exit $?"Expected:
Warning: no valid objects found.
exit 0
Exit 0. kube-linter cannot read the file, warns
quietly and reports success. In the folder run (Drill 3),
neu.yaml does not even show up. A linter without a schema
check in front of it overlooks exactly the files that are most
broken.
Fix the two errors before continuing:
sed -i 's/containerPort: "80"/containerPort: 80/; s/replica: 2/replicas: 2/' manifeste/neu.yaml
kubeconform -strict -summary manifeste/neu.yamlExpected:
Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0
Save your progress? Sign up for free
Drill 3: kube-linter
kube-linter lint manifeste/ > kl.txt 2>&1; echo "exit $?"
tail -1 kl.txt
grep -o "(check: [a-z-]*" kl.txt | sort | uniq -c | sort -rnExpected (counted before the fix of
neu.yaml; afterwards its findings are added, among them
latest-tag):
exit 1
Error: found 28 lint errors
6 (check: run-as-non-root
6 (check: no-read-only-root-fs
5 (check: unset-memory-requirements
5 (check: unset-cpu-requirements
3 (check: no-anti-affinity
1 (check: privileged-container
1 (check: privilege-escalation-container
1 (check: dangling-service
Each line in kl.txt names the file, object, finding and
remedy. Two findings are worth a look:
grep -E "dangling|privileged-container" kl.txt | cut -c1-200Expected (shortened):
…/manifeste/cache-svc.yaml: (object: laden/cache /v1, Kind=Service) no pods found matching service labels (map[app:redis]) (check: dangling-service, …
…/manifeste/laden.yaml: (object: lager/packer apps/v1, Kind=Deployment) container "packer" is privileged (check: privileged-container, …
dangling-service is the selector bug from Day 9, this
time found in the file, before it reaches the cluster.
For this, kube-linter compares all objects in the folder with each
other.
Which checks exist and which are active by default:
kube-linter checks list --format plain | grep -A2 -E "^Name: (latest-tag|dangling-service)$"Expected:
Name: dangling-service
Description: Indicates when services do not have any associated deployments.
Remediation: Confirm that your service's selector correctly matches the labels on one of your deployments.
--
Name: latest-tag
Description: Indicates when a deployment-like object is running a container with an invalid container image
Remediation: Use a container image with a specific tag other than latest.
Not every rule fits. A configuration file switches checks off or on:
cat > .kube-linter.yaml <<'EOF'
checks:
addAllBuiltIn: false
exclude:
- no-anti-affinity
- no-read-only-root-fs
include:
- latest-tag
EOF
kube-linter lint --config .kube-linter.yaml manifeste/ 2>&1 | tail -1Expected:
Error: found 23 lint errors
For individual objects, there are exceptions via annotation, with a
justification. The packer in lager (warehouse)
must run privileged (that has been the assumption since
Day 0). Record this on the object, in the copy in
manifeste/:
python3 - <<'EOF'
p = "manifeste/laden.yaml"
s = open(p).read()
s = s.replace(" name: packer\n namespace: lager\n",
" name: packer\n namespace: lager\n annotations:\n"
" ignore-check.kube-linter.io/privileged-container: \"begründet in Ticket LAGER-17\"\n", 1)
open(p, "w").write(s)
EOF
grep -A4 "name: packer" manifeste/laden.yaml | head -5
kube-linter lint --config .kube-linter.yaml manifeste/ 2>&1 | grep -E "packer|Error:" | cut -c1-150Expected (shortened):
name: packer
namespace: lager
annotations:
ignore-check.kube-linter.io/privileged-container: "begründet in Ticket LAGER-17"
labels: {app: packer}
…(object: lager/packer apps/v1, Kind=Deployment) container "packer" is Privileged hence allows privilege escalation. (check: privilege-escalation-cont…
…(object: lager/packer apps/v1, Kind=Deployment) container "packer" is not set to runAsNonRoot (check: run-as-non-root, …
…(object: lager/packer apps/v1, Kind=Deployment) container "packer" has cpu request 0 (check: unset-cpu-requirements, …
…(object: lager/packer apps/v1, Kind=Deployment) container "packer" has memory limit 0 (check: unset-memory-requirements, …
Error: found 22 lint errors
privileged-container is gone, but
privilege-escalation-container keeps reporting the
same cause. An exception always applies to only one check.
Whoever adds an exception has to name all checks that depend on the same
property. This is intentional: every exception should be visible and
justified.
The Python snippet inserts the annotation because
sedis bad at multi-line replacements. In a real repo, you change the file in the editor.
Save your progress? Sign up for free
Drill 4: kube-score
kube-score has a stronger opinion than kube-linter and explains each finding in detail:
kube-score score manifeste/kasse.yamlExpected (colors removed, shortened):
apps/v1/Deployment kasse in laden 💥
path=/home/ubuntu/werkzeuge/tag10/manifeste/kasse.yaml
[CRITICAL] Pod NetworkPolicy
· The pod does not have a matching NetworkPolicy
[CRITICAL] Container Resources
· kasse -> CPU limit is not set
· kasse -> Memory limit is not set
· kasse -> CPU request is not set
· kasse -> Memory request is not set
[CRITICAL] Container Image Pull Policy
· kasse -> ImagePullPolicy is not set to Always
[CRITICAL] Container Security Context ReadOnlyRootFilesystem
· kasse -> Container has no configured security context
[CRITICAL] Container Ephemeral Storage Request and Limit
· kasse -> Ephemeral Storage limit is not set
· kasse -> Ephemeral Storage request is not set
[CRITICAL] Container Security Context User Group ID
· kasse -> Container has no configured security context
[CRITICAL] Deployment has PodDisruptionBudget
· No matching PodDisruptionBudget was found
[WARNING] Deployment has host PodAntiAffinity
· Deployment does not have a host podAntiAffinity set
Read the list critically. Missing requests, no PDB, no security
context: justified. ImagePullPolicy is not set to Always as
CRITICAL: a matter of opinion. With fixed tags or
digests, IfNotPresent is perfectly fine. That is exactly
what --ignore-test is for.
For pipelines, -o ci is more readable, one line per
finding. Pass all files together, because kube-score checks
relationships between objects:
kube-score score -o ci manifeste/*.yaml | grep "v1/Service"Expected:
[OK] api/laden v1/Service
[OK] api/laden v1/Service
[OK] api/laden v1/Service
[OK] api/laden v1/Service
[OK] cache/laden v1/Service
[OK] cache/laden v1/Service
[CRITICAL] cache/laden v1/Service: The services selector does not match any pods
[OK] cache/laden v1/Service
[OK] web/laden v1/Service
[OK] web/laden v1/Service
[OK] web/laden v1/Service
[OK] web/laden v1/Service
kube-score also finds the wrong selector. It sees the NetworkPolicy from Day 8 as well:
kube-score score -o ci manifeste/*.yaml | grep "NetworkPolicy" | head -3Expected:
[CRITICAL] inventur/lager batch/v1/CronJob: The pod does not have a matching NetworkPolicy
[WARNING] api/laden apps/v1/Deployment: The pod does not have a matching egress NetworkPolicy
[CRITICAL] cache/laden apps/v1/Deployment: The pod does not have a matching NetworkPolicy
api is only a WARNING now: ingress is covered, egress is
not. Now switch off the matters of opinion and count:
kube-score score -o ci manifeste/*.yaml | grep -c CRITICAL
kube-score score -o ci --ignore-test container-image-pull-policy \
--ignore-test container-ephemeral-storage-request-and-limit manifeste/*.yaml | grep -c CRITICALExpected:
75
55
kube-score list provides the names for
--ignore-test.
Save your progress? Sign up for free
Drill 5: Polaris
Polaris checks files and running clusters with the same rule set and gives a score from 0 to 100.
polaris audit --audit-path manifeste/ --format score
polaris audit --audit-path manifeste/ --format pretty --only-show-failed-tests --severity danger | grep -E "^[A-Z][a-zA-Z]+ |❌"Expected (colors removed, order may differ):
56
CronJob inventur in namespace lager
privilegeEscalationAllowed ❌ Danger
runAsRootAllowed ❌ Danger
Deployment kasse in namespace laden
privilegeEscalationAllowed ❌ Danger
runAsRootAllowed ❌ Danger
…
Deployment packer in namespace lager
privilegeEscalationAllowed ❌ Danger
runAsPrivileged ❌ Danger
runAsRootAllowed ❌ Danger
Deployment lieferung in namespace laden
tagNotSpecified ❌ Danger
privilegeEscalationAllowed ❌ Danger
runAsRootAllowed ❌ Danger
ClusterRoleBinding api-alles-lesen
clusterrolebindingPodExecAttach ❌ Danger
The last line is wrong. api-alles-lesen binds the
built-in ClusterRole view, and that allows neither
pods/exec nor pods/attach. The exact message
reveals the problem:
polaris audit --audit-path manifeste/ --format pretty | grep -A6 "ClusterRoleBinding api-alles-lesen" | grep -A1 PodExecAttachExpected:
clusterrolebindingPodExecAttach ❌ Danger
Security - The ClusterRoleBinding references a ClusterRole that allows Pods/exec, allows pods/attach, or that does not exist
“or that does not exist”: view is not in the files; it
is built into the cluster. During the file run, Polaris does not know
what it contains and raises the alarm to be on the safe side. Checked
against the cluster, it looks different:
polaris audit --format pretty | grep -A4 "ClusterRoleBinding api-alles-lesen"Expected:
ClusterRoleBinding api-alles-lesen
clusterrolebindingClusterAdmin 🎉 Success
Security - The ClusterRoleBinding does not reference the default cluster-admin ClusterRole or one with wildcard permissions
clusterrolebindingPodExecAttach 🎉 Success
Security - The ClusterRoleBinding does not reference a ClusterRole allowing pods/exec or pods/attach
Without --audit-path, Polaris checks the current
context. The lesson applies to all linters: a check of files
knows only the files. Whatever is presupposed in the cluster
(built-in roles, CRDs, namespaces) is unknown to it.
For pipelines, Polaris provides exit codes:
polaris audit --audit-path manifeste/ --set-exit-code-on-danger --format score >/dev/null; echo "exit $?"Expected:
exit 3
--set-exit-code-below-score 80 additionally exits with 4
if the score drops below 80.
Save your progress? Sign up for free
Exercise: Who Finds What?
Tick which tool reported the finding in Drills 1 to 5:
| Finding | kubeconform | kube-linter | kube-score | Polaris |
|---|---|---|---|---|
containerPort: "80" |
||||
replica: instead of replicas: |
||||
Service cache without matching Pods |
||||
nginx:latest |
||||
| CiliumNetworkPolicy without schema |
Solution
| Finding | kubeconform | kube-linter | kube-score | Polaris |
|---|---|---|---|---|
containerPort: "80" |
✓ | – (file skipped) | not checked | not checked |
replica: instead of replicas: |
✓ only with -strict |
– | not checked | not checked |
Service cache without matching Pods |
– | ✓ dangling-service |
✓ | not reported |
nginx:latest |
– | ✓ latest-tag |
not checked | ✓ tagNotSpecified |
| CiliumNetworkPolicy without schema | ✓ (error or catalog) | – | – | – |
“Not checked” means: not tried in this chapter. No tool covers
everything. A good pair for the pipeline is kubeconform
-strict + one rule linter; which one is a team
decision.
Save your progress? Sign up for free
Challenge
Turn the Deployment lieferung into a manifest that
passes all four: kubeconform -strict without errors,
kube-linter without findings, kube-score without CRITICAL and WARNING,
Polaris without Danger. The image may be
nginxinc/nginx-unprivileged:1.30.6-alpine (listens on 8080,
does not run as root). It should be reachable only from
web. Roll it out and prove that it runs.
Solution
mkdir -p loesung
cat > loesung/lieferung.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: lieferung
namespace: laden
labels: {app: lieferung, app.kubernetes.io/name: lieferung, app.kubernetes.io/instance: lieferung}
spec:
replicas: 2
selector:
matchLabels: {app: lieferung}
template:
metadata:
labels: {app: lieferung, app.kubernetes.io/name: lieferung, app.kubernetes.io/instance: lieferung}
spec:
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 10101
runAsGroup: 10101
seccompProfile: {type: RuntimeDefault}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels: {app: lieferung}
containers:
- name: lieferung
image: nginxinc/nginx-unprivileged:1.30.6-alpine
imagePullPolicy: Always
ports:
- name: http
containerPort: 8080
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: {drop: [ALL]}
resources:
requests: {cpu: 20m, memory: 32Mi, ephemeral-storage: 16Mi}
limits: {cpu: 200m, memory: 64Mi, ephemeral-storage: 64Mi}
readinessProbe:
httpGet: {path: /, port: http}
livenessProbe:
tcpSocket: {port: http}
initialDelaySeconds: 5
volumeMounts:
- {name: tmp, mountPath: /tmp}
volumes:
- name: tmp
emptyDir: {}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: lieferung
namespace: laden
spec:
minAvailable: 1
unhealthyPodEvictionPolicy: AlwaysAllow
selector:
matchLabels: {app: lieferung}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: lieferung
namespace: laden
spec:
podSelector:
matchLabels: {app: lieferung}
policyTypes: [Ingress, Egress]
ingress:
- from:
- podSelector:
matchLabels: {app: web}
ports:
- port: 8080
egress:
- to:
- namespaceSelector: {}
podSelector:
matchLabels: {k8s-app: kube-dns}
ports:
- {port: 53, protocol: UDP}
EOF
kubeconform -strict -summary loesung/
kube-linter lint loesung/ 2>&1 | tail -1
kube-score score loesung/lieferung.yaml >/dev/null; echo "kube-score exit $?"
polaris audit --audit-path loesung/ --format score --set-exit-code-on-danger; echo "polaris exit $?"Expected:
Summary: 3 resources found in 1 file - Valid: 3, Invalid: 0, Errors: 0, Skipped: 0
No lint errors found!
kube-score exit 0
96
polaris exit 0
The path there was not straight. Three rounds of feedback, each instructive:
- kube-linter required
unhealthyPodEvictionPolicyin the PDB (new checkpdb-unhealthy-pod-eviction-policy). - kube-score rejected identical readiness and liveness probes: otherwise a hanging application would be taken out of the Service and restarted at the same time. That is why the liveness probe only checks the port.
- Polaris did not accept
egress: []as an “egress rule” and warned until the policy allowed DNS.
What remains in Polaris are two warnings
(priorityClassNotSet,
topologySpreadConstraint), no Danger. Now roll it out:
kubectl apply -f loesung/
kubectl -n laden rollout status deploy/lieferung --timeout=120s
L=$(kubectl -n laden get pods -l app=lieferung -o jsonpath='{.items[0].status.podIP}')
W=$(kubectl -n laden get pods -l app=web -o jsonpath='{.items[0].metadata.name}')
kubectl -n laden exec $W -c nginx -- wget -qO- -T3 http://$L:8080/ | grep -o "<title>.*</title>"
kubectl -n laden exec netshoot -- curl -s -m3 -o /dev/null -w "%{http_code}\n" http://$L:8080/Expected:
deployment.apps/lieferung created
poddisruptionbudget.policy/lieferung created
networkpolicy.networking.k8s.io/lieferung created
deployment "lieferung" successfully rolled out
<title>Welcome to nginx!</title>
000
command terminated with exit code 28
web gets through, netshoot does not. Hardened does not
mean “no longer runs”: with a read-only file system, nginx needs a
writable /tmp, which is what the emptyDir is
for.
Save your progress? Sign up for free
Checkpoint
kubeconform -v; kube-linter version; polaris version
kubectl -n laden get deploy lieferung -o jsonpath='{.status.readyReplicas}{"\n"}'
kubectl -n laden get pdb,netpol -o name | sortExpected:
v0.8.0
0.8.3
Polaris version:10.2.6
2
networkpolicy.networking.k8s.io/api-nur-von-web
networkpolicy.networking.k8s.io/lieferung
poddisruptionbudget.policy/lieferung
Interview Note
- What do you check in the pipeline before manifests are
rolled out? Schema (kubeconform
-strict, matching Kubernetes version, CRD schemas), then rules (kube-linter or Polaris), thenkubectl apply --dry-run=serveragainst a real API server with admission. - Why
-strict? Without it, unknown fields, i.e. typos, disappear silently. - How do you handle exceptions? Per object and per check, with a justification in the manifest (kube-linter annotation, Polaris exemption), not by switching checks off globally.
Enterprise Note
- Polaris and kube-linter also exist in the cluster: Polaris as an
admission webhook that rejects Danger findings. If you run Kyverno or
Gatekeeper anyway, you write rules there once and check the same
policies in the pipeline (
kyverno apply,gator test). - The rule set is a team matter. A
.kube-linter.yamlor Polaris configuration in the repo settles discussions about “but that is not an error” once and in writing. - kube-score has stalled at version 1.20.0 from April 2025, but is still maintained (last commit May 2026). For new pipelines, kube-linter and Polaris are the safer choice.