Zum Inhalt springen
Trainingslager IT-Trainingslager

Tag 10: Library Charts

Ziel: Gemeinsame Bausteine in ein Library Chart plattform auslagern, einen zweiten Dienst in 20 Zeilen darauf bauen und die Bibliothek versioniert weiterentwickeln. · Dauer: ca. 60 min · Voraussetzung: Tag 9

Briefing

  • Ein Library Chart (type: library) enthält nur define-Bausteine. Es erzeugt selbst keine Objekte und ist nicht installierbar.
  • Ein Anwendungs-Chart bindet es als Abhängigkeit ein und ruft die Bausteine mit include auf – im eigenen Kontext, also mit eigenen .Values und .Chart.
  • Eine Änderung an der Bibliothek trifft jeden Nutzer beim nächsten dependency update. Darum streng nach SemVer versionieren und Nutzer einzeln nachziehen.
 plattform (library)          helper (20 Zeilen)        notes
 ├─ plattform.labels   <──────── include ───────────────── include (Labels)
 ├─ plattform.*SecurityContext                    ──────── include (restricted)
 ├─ plattform.deployment <────── include
 └─ plattform.service    <────── include

Drill 1: Das Library Chart plattform

# auf prod
mkdir -p ~/helm/tag10 && cd ~/helm/charts
mkdir -p plattform/templates
cat > plattform/Chart.yaml <<'EOF'
# plattform/Chart.yaml – Stand Tag 10
apiVersion: v2
name: plattform
description: Gemeinsame Bausteine für alle Charts der Plattform
type: library
version: 0.1.0
EOF
cat > plattform/templates/_namen.tpl <<'EOF'
{{/* plattform/templates/_namen.tpl – Stand Tag 10 */}}
{{- define "plattform.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "plattform.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else if contains (include "plattform.name" .) .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name (include "plattform.name" .) | trunc 63
  | trimSuffix "-" }}
{{- end }}
{{- end }}

{{- define "plattform.selectorLabels" -}}
app.kubernetes.io/name: {{ include "plattform.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "plattform.labels" -}}
{{ include "plattform.selectorLabels" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }}
{{- with .Values.team }}
team: {{ . | quote }}
{{- end }}
{{- end }}
EOF
cat > plattform/templates/_sicherheit.tpl <<'EOF'
{{/* plattform/templates/_sicherheit.tpl – Stand Tag 10 */}}
{{/* Pod Security Standard "restricted" */}}
{{- define "plattform.podSecurityContext" -}}
runAsNonRoot: true
seccompProfile:
  type: RuntimeDefault
{{- end }}

{{- define "plattform.containerSecurityContext" -}}
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
  drop: [ALL]
{{- end }}
EOF
cat > plattform/templates/_deployment.tpl <<'EOF'
{{/* plattform/templates/_deployment.tpl – Stand Tag 10 */}}
{{- define "plattform.deployment" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "plattform.fullname" . }}
  labels:
    {{- include "plattform.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.replicaCount | default 1 }}
  selector:
    matchLabels:
      {{- include "plattform.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "plattform.labels" . | nindent 8 }}
    spec:
      securityContext:
        {{- include "plattform.podSecurityContext" . | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag
            | default .Chart.AppVersion }}"
          ports: [{name: http, containerPort: {{ .Values.port | default 8080 }}}]
          securityContext:
            {{- include "plattform.containerSecurityContext" . | nindent 12 }}
          {{- with .Values.probePath }}
          readinessProbe:
            httpGet: {path: {{ . }}, port: http}
          {{- end }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
{{- end }}
EOF
cat > plattform/templates/_service.tpl <<'EOF'
{{/* plattform/templates/_service.tpl – Stand Tag 10 */}}
{{- define "plattform.service" -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "plattform.fullname" . }}
  labels:
    {{- include "plattform.labels" . | nindent 4 }}
spec:
  selector:
    {{- include "plattform.selectorLabels" . | nindent 4 }}
  ports:
    - name: http
      port: 80
      targetPort: http
{{- end }}
EOF
helm lint plattform | tail -1

Erwartet:

1 chart(s) linted, 0 chart(s) failed

Alle Dateien beginnen mit _: Sie enthalten nur Definitionen. Die Bausteine nutzen .Values und .Chart – welche Werte das sind, entscheidet erst das Chart, das sie aufruft.

Fortschritt speichern? Kostenlos registrieren

Drill 2: Nicht installierbar

# auf prod
helm template x ./plattform
helm install plattform ./plattform -n tag10 --create-namespace
kubectl get namespace tag10
helm package plattform -d ~/helm/tag10

Erwartet:

Error: library charts are not installable
Error: INSTALLATION FAILED: library charts are not installable
Error from server (NotFound): namespaces "tag10" not found
Successfully packaged chart and saved it to: /home/ubuntu/helm/tag10/plattform-0.1.0.tgz

Selbst helm template verweigert. Helm bricht so früh ab, dass auch --create-namespace nichts anlegt. Paketieren und veröffentlichen geht dagegen – genau dafür ist eine Bibliothek da.

Fortschritt speichern? Kostenlos registrieren

Drill 3: helper in 20 Zeilen

# auf prod
mkdir -p helper/templates
cat > helper/Chart.yaml <<'EOF'
# helper/Chart.yaml – Stand Tag 10
apiVersion: v2
name: helper
description: HTTP-Testdienst (go-httpbin) auf Basis von plattform
version: 0.1.0
appVersion: "2.26.0"
dependencies:
  - name: plattform
    version: "~0.1.0"
    repository: file://../plattform
EOF
cat > helper/values.yaml <<'EOF'
# helper/values.yaml – Stand Tag 10
image:
  repository: ghcr.io/mccutchen/go-httpbin
port: 8080
probePath: /status/200
resources:
  requests: {cpu: 10m, memory: 16Mi}
  limits: {memory: 64Mi}
EOF
echo '{{ include "plattform.deployment" . }}' > helper/templates/deployment.yaml
echo '{{ include "plattform.service" . }}' > helper/templates/service.yaml
cat helper/Chart.yaml helper/values.yaml helper/templates/* | wc -l
helm dependency update helper | tail -1
helm template helper ./helper -s templates/deployment.yaml \
  | sed -n '/securityContext/,/readinessProbe/p'

Erwartet:

20
Deleting outdated charts
      securityContext:
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: helper
          image: "ghcr.io/mccutchen/go-httpbin:2.26.0"
          ports: [{name: http, containerPort: 8080}]
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities:
              drop: [ALL]
          readinessProbe:

Der Container heißt helper und das Image hat den Tag 2.26.0, weil .Chart im Baustein das aufrufende Chart ist, nicht plattform. Eine Schwäche hat der Baustein: replicaCount | default 1 macht aus einer bewusst gesetzten 0 wieder 1 – die Falle aus Tag 5. Für helper genügt es; eine Bibliothek für viele Teams prüft mit hasKey.

Fortschritt speichern? Kostenlos registrieren

Drill 4: helper ausrollen und restricted prüfen

# auf prod
helm install helper ./helper -n notes --wait | grep STATUS
IP=$(kubectl -n notes get svc helper -o jsonpath='{.spec.clusterIP}')
curl -s $IP/get | jq -c '{url}'
kubectl label --dry-run=server --overwrite ns notes \
  pod-security.kubernetes.io/enforce=restricted

Erwartet:

STATUS: deployed
{"url":"http://10.43.234.156/get"}
namespace/notes labeled (server dry run)
Warning: existing pods in namespace "notes" violate the new PodSecurity enforce level
"restricted:latest"
Warning: notes-57d48b9df5-fbdxz (and 2 other pods): allowPrivilegeEscalation != false,
unrestricted capabilities, runAsNonRoot != true, seccompProfile

Auf dem k3s-Knoten erreichst du ClusterIPs direkt. Der Probelauf mit --dry-run=server setzt das Label nicht, nennt aber alle Pods, die „restricted“ verletzen würden: die zwei notes-Pods und Postgres – helper nicht.

Fortschritt speichern? Kostenlos registrieren

Drill 5: notes auf die Bibliothek umstellen

Erst den Stand festhalten, dann umstellen und vergleichen:

# auf prod
helm template notes ./notes -f values/prod.yaml > ~/helm/tag10/vorher.yaml
cat >> notes/Chart.yaml <<'EOF'
  - name: plattform
    version: "~0.1.0"
    repository: file://../plattform
EOF
sed -i 's/^version: .*/version: 0.9.0/; s/Tag 09/Tag 10/' notes/Chart.yaml
jq '.title = "notes – Stand Tag 10" | .properties.plattform = {"type": "object"}' \
  notes/values.schema.json > /tmp/s.json && mv /tmp/s.json notes/values.schema.json
cat > notes/templates/_helpers.tpl <<'EOF'
{{/* notes/templates/_helpers.tpl – Stand Tag 10 */}}

{{/* Namen und Labels kommen jetzt aus dem Library Chart plattform */}}
{{- define "notes.name" -}}{{ include "plattform.name" . }}{{- end }}
{{- define "notes.fullname" -}}{{ include "plattform.fullname" . }}{{- end }}
{{- define "notes.selectorLabels" -}}
{{ include "plattform.selectorLabels" . }}{{- end }}
{{- define "notes.labels" -}}{{ include "plattform.labels" . }}{{- end }}

{{/* Image: Tag leer = appVersion aus Chart.yaml */}}
{{- define "notes.image" -}}
{{- $repo := required "image.repository fehlt" .Values.image.repository }}
{{- printf "%s:%s" $repo (.Values.image.tag | default .Chart.AppVersion) }}
{{- end }}

{{/* DB-Umgebung für Init-Container und notes-api; leer = Speicherbetrieb */}}
{{- define "notes.dbEnv" -}}
{{- $db := .Values.database }}
{{- $secret := coalesce $db.existingSecret .Values.global.dbSecret }}
{{- if $secret }}
{{- $host := $db.host }}
{{- if and (not $host) .Values.postgres.enabled }}
{{- $host = printf "%s-postgres" .Release.Name }}
{{- end }}
- name: NOTES_DB_PASSWORD
  valueFrom:
    secretKeyRef:
      name: {{ $secret }}
      key: {{ $db.passwordKey }}
- name: NOTES_DB_URL
  value: {{ printf "postgres://%s:$(NOTES_DB_PASSWORD)@%s:%v/%s?%s" $db.user
    (required "database.host fehlt" $host) $db.port $db.name "sslmode=disable"
    | quote }}
{{- end }}
{{- end }}
EOF
cat > notes/templates/deployment.yaml <<'EOF'
{{/* notes/templates/deployment.yaml – Stand Tag 10 */}}
{{- $dbEnv := include "notes.dbEnv" . }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "notes.fullname" . }}
  labels:
    {{- include "notes.labels" . | nindent 4 }}
spec:
  replicas: {{ hasKey .Values "replicaCount" | ternary .Values.replicaCount 2 }}
  selector:
    matchLabels:
      {{- include "notes.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "notes.labels" . | nindent 8 }}
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/config.yaml") .
          | sha256sum }}
    spec:
      terminationGracePeriodSeconds: {{ durationSeconds .Values.shutdownTimeout }}
      securityContext:
        {{- include "plattform.podSecurityContext" . | nindent 8 }}
      {{- if $dbEnv }}
      initContainers:
        - name: migrate
          image: {{ include "notes.image" . | quote }}
          args: ["migrate"]
          securityContext:
            {{- include "plattform.containerSecurityContext" . | nindent 12 }}
          env:
            {{- $dbEnv | nindent 12 }}
      {{- end }}
      containers:
        - name: notes-api
          image: {{ include "notes.image" . | quote }}
          ports: [{name: http, containerPort: 8080}]
          securityContext:
            {{- include "plattform.containerSecurityContext" . | nindent 12 }}
          env:
            - name: NOTES_API_KEY
              valueFrom:
                secretKeyRef:
                  name: {{ required "apiKey.existingSecret fehlt"
                    .Values.apiKey.existingSecret }}
                  key: {{ .Values.apiKey.key }}
            {{- with $dbEnv }}
            {{- . | nindent 12 }}
            {{- end }}
          envFrom:
            - configMapRef:
                name: {{ include "notes.fullname" . }}-config
          readinessProbe:
            httpGet: {path: /healthz, port: http}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
EOF
helm dependency update notes | tail -1
helm template notes ./notes -f values/prod.yaml > ~/helm/tag10/nachher.yaml
diff ~/helm/tag10/vorher.yaml ~/helm/tag10/nachher.yaml | grep '^[<>]' | sort | uniq -c

Erwartet (gekürzt):

Deleting outdated charts
      1 <         checksum/config: 4adc2ea403fb3f11d24bcb7e4537bb3054d4542f79565f4834…
      1 <         helm.sh/chart: notes-0.8.0
      6 <     helm.sh/chart: notes-0.8.0
      1 <   chart: "notes-0.8.0"
      2 >               drop: [ALL]
      2 >             allowPrivilegeEscalation: false
      2 >             capabilities:
      2 >             readOnlyRootFilesystem: true
      2 >           securityContext:
      1 >           type: RuntimeDefault
      1 >         checksum/config: 14a13835155b7e9bbe47d63eff93afc4c13f60c257b6c7f9fb…
      1 >         helm.sh/chart: notes-0.9.0
      1 >         runAsNonRoot: true
      1 >         seccompProfile:
      1 >       securityContext:
      6 >     helm.sh/chart: notes-0.9.0
      1 >   chart: "notes-0.9.0"

Namen und Selektoren sind identisch, neu sind nur die SecurityContexts. Zweierlei fällt auf: helm.sh/chart ändert sich mit jeder Chart-Version, und weil das Label auch in config.yaml steht, ändert sich die Prüfsumme aus Tag 7 – jede neue Chart-Version startet die Pods neu, auch ohne Konfigurationsänderung. Das ist hier gewollt (neue SecurityContexts), aber gut zu wissen.

# auf prod
helm upgrade notes ./notes -n notes -f values/prod.yaml --wait | grep REVISION
sleep 20
kubectl label --dry-run=server --overwrite ns notes \
  pod-security.kubernetes.io/enforce=restricted
curl -s -H 'Host: api.notes.lab' localhost/notes; echo

Erwartet (ID gekürzt):

REVISION: 21
Warning: existing pods in namespace "notes" violate the new PodSecurity enforce level
"restricted:latest"
Warning: notes-postgres-0: allowPrivilegeEscalation != false, unrestricted capabilities,
runAsNonRoot != true, seccompProfile
namespace/notes labeled (server dry run)
[{"id":"e725da85-…","text":"in Postgres"}]

Nur noch Postgres verletzt „restricted“ – das offizielle Image startet als root und wechselt dann den Benutzer. notes-api läuft auch mit schreibgeschütztem Dateisystem. Das sleep gibt den alten Pods Zeit zu verschwinden: --wait wartet auf die neuen, nicht auf das Ende der alten.

Fortschritt speichern? Kostenlos registrieren

Drill 6: Bibliothek versionieren

plattform bekommt ein zusätzliches Label und wird 0.2.0. Nur helper zieht nach.

# auf prod
git add -A
git commit -qm "Tag 10: Library Chart plattform 0.1.0, helper, notes 0.9.0"
sed -i 's/^version: 0.1.0/version: 0.2.0/; s/Tag 10/Tag 10 (0.2.0)/' \
  plattform/Chart.yaml
L='app.kubernetes.io/part-of: plattform'
sed -i "/^app.kubernetes.io\/managed-by/a $L" plattform/templates/_namen.tpl
sed -i 's/version: "~0.1.0"/version: "~0.2.0"/; s/^version: 0.1.0/version: 0.2.0/' \
  helper/Chart.yaml
helm dependency update helper | tail -1
helm upgrade helper ./helper -n notes --wait | grep REVISION
kubectl -n notes get deploy helper \
  -o jsonpath='{.metadata.labels.app\.kubernetes\.io/part-of}{"\n"}'
helm dependency update notes 2>&1 | tail -1
ls helper/charts notes/charts

Erwartet:

Deleting outdated charts
REVISION: 2
plattform
Error: can't get a valid version for 1 subchart(s): "plattform" (repository
"file://../plattform", version "~0.1.0"). Make sure a matching chart version exists
in the repo, or change the version constraint in Chart.yaml
helper/charts:
plattform-0.2.0.tgz

notes/charts:
plattform-0.1.0.tgz
postgres-0.1.0.tgz

helper trägt das neue Label, notes bleibt bei 0.1.0 – aber nur, weil das alte .tgz noch in notes/charts/ liegt. Ein file://-Repo kennt nur die Version, die gerade im Ordner steht; dein Git ignoriert .tgz-Dateien. Ein frischer Klon könnte notes nicht mehr bauen. Echte Versionierung braucht ein Repository mit allen Versionen – ab Tag 15 die OCI-Registry.

# auf prod
git add -A && git commit -qm "Tag 10: plattform 0.2.0, helper 0.2.0 zieht nach"

Fortschritt speichern? Kostenlos registrieren

Übung: Speed-Drills

  1. Welcher Chart-Typ ist plattform? Zeitziel: 15 s
  2. Welche plattform-Version steckt in helper, welche in notes? Zeitziel: 20 s
  3. Lass helper den Statuscode 418 liefern. Zeitziel: 30 s
  4. Zeig den Pod-SecurityContext des laufenden Deployments notes. Zeitziel: 20 s

Lösung

# auf prod
cd ~/helm/charts
yq .type plattform/Chart.yaml
ls helper/charts notes/charts
IP=$(kubectl -n notes get svc helper -o jsonpath='{.spec.clusterIP}')
curl -s -o /dev/null -w '%{http_code}\n' $IP/status/418
kubectl -n notes get deploy notes -o jsonpath='{.spec.template.spec.securityContext}'

Erwartet:

library
helper/charts:
plattform-0.2.0.tgz

notes/charts:
plattform-0.1.0.tgz
postgres-0.1.0.tgz
418
{"runAsNonRoot":true,"seccompProfile":{"type":"RuntimeDefault"}}

Fortschritt speichern? Kostenlos registrieren

Kontrollpunkt

# auf prod
helm list -n notes

Erwartet: helper Revision 2 (helper-0.2.0) und notes Revision 21 (notes-0.9.0), beide deployed.

# auf prod
helm install x ~/helm/charts/plattform -n notes

Erwartet: Error: INSTALLATION FAILED: library charts are not installable

# auf prod
kubectl -n notes get pods

Erwartet: helper, zwei notes-Pods und notes-postgres-0, alle 1/1 Running.

Challenge

Baue in tag10 ein Chart web mit nginxinc/nginx-unprivileged:1.31.7-alpine auf plattform und installiere es in einem Namespace, der „restricted“ erzwingt. Der Pod wird abstürzen. Finde den Grund und behebe ihn in einer Kopie der Bibliothek (0.3.0).

Hinweis: readOnlyRootFilesystem – nginx will in /tmp schreiben.

Lösung

# auf prod
cd ~/helm/tag10 && mkdir -p web/templates
cat > web/Chart.yaml <<'EOF'
apiVersion: v2
name: web
version: 0.1.0
appVersion: "1.31.7-alpine"
dependencies:
  - name: plattform
    version: "~0.2.0"
    repository: file://../../charts/plattform
EOF
cat > web/values.yaml <<'EOF'
image:
  repository: docker.io/nginxinc/nginx-unprivileged
probePath: /
resources:
  limits: {memory: 32Mi}
EOF
echo '{{ include "plattform.deployment" . }}' > web/templates/deployment.yaml
helm dependency update web | tail -1
kubectl create namespace tag10
kubectl label ns tag10 pod-security.kubernetes.io/enforce=restricted
helm install web ./web -n tag10 --wait --timeout 40s
kubectl -n tag10 logs deploy/web --tail 1

Erwartet:

Deleting outdated charts
namespace/tag10 created
namespace/tag10 labeled
Error: INSTALLATION FAILED: resource Deployment/tag10/web not ready. status: InProgress,
message: Available: 0/1
context deadline exceeded
nginx: [emerg] mkdir() "/tmp/proxy_temp" failed (30: Read-only file system)

Die Bibliothek bekommt einen Schalter tmpDir, der ein emptyDir unter /tmp einhängt:

# auf prod
cp -r ~/helm/charts/plattform .
sed -i 's/^version: 0.2.0/version: 0.3.0/' plattform/Chart.yaml
cat > plattform/templates/_deployment.tpl <<'EOF'
{{/* plattform/templates/_deployment.tpl – Stand Tag 10 (0.3.0, Challenge) */}}
{{- define "plattform.deployment" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "plattform.fullname" . }}
  labels:
    {{- include "plattform.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.replicaCount | default 1 }}
  selector:
    matchLabels:
      {{- include "plattform.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "plattform.labels" . | nindent 8 }}
    spec:
      securityContext:
        {{- include "plattform.podSecurityContext" . | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag
            | default .Chart.AppVersion }}"
          ports: [{name: http, containerPort: {{ .Values.port | default 8080 }}}]
          securityContext:
            {{- include "plattform.containerSecurityContext" . | nindent 12 }}
          {{- with .Values.probePath }}
          readinessProbe:
            httpGet: {path: {{ . }}, port: http}
          {{- end }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
          {{- if .Values.tmpDir }}
          volumeMounts:
            - {name: tmp, mountPath: /tmp}
          {{- end }}
      {{- if .Values.tmpDir }}
      volumes:
        - {name: tmp, emptyDir: {sizeLimit: 64Mi}}
      {{- end }}
{{- end }}
EOF
sed -i 's|"~0.2.0"|"~0.3.0"|; s|file://../../charts/plattform|file://../plattform|' \
  web/Chart.yaml
echo 'tmpDir: true' >> web/values.yaml
helm dependency update web | tail -1
helm upgrade web ./web -n tag10 --wait --timeout 60s | grep REVISION
kubectl -n tag10 exec deploy/web -- wget -qO- 127.0.0.1:8080 \
  | grep -o '<title>.*</title>'

Erwartet:

Deleting outdated charts
REVISION: 2
<title>Welcome to nginx!</title>

Der Pod läuft jetzt unter „restricted“ mit schreibgeschütztem Wurzeldateisystem, nur /tmp ist beschreibbar. Mit localhost statt 127.0.0.1 meldete wget im Labor Connection refused – im Zweifel die IPv4-Adresse nehmen.

Fortschritt speichern? Kostenlos registrieren

Aufräumen

# auf prod
helm uninstall web -n tag10
kubectl delete namespace tag10

Erwartet:

release "web" uninstalled
namespace "tag10" deleted

Interview-Notiz

  • Was ist ein Library Chart? Ein Chart mit type: library, das nur benannte Templates enthält. Es ist nicht installierbar und erzeugt Objekte nur über include im nutzenden Chart.
  • Wann lohnt es sich? Wenn viele Charts dieselben Muster teilen – Labels, SecurityContexts, Deployments. Für zwei Charts lohnt sich der Aufwand selten.
  • Wie rollst du eine Änderung an der Bibliothek aus? Neue SemVer-Version veröffentlichen, Nutzer einzeln per Versionsbereich und Chart.lock nachziehen, vorher per helm template-Diff prüfen.

Enterprise-Notiz

  • Plattform-Teams liefern Bibliothek und Richtlinien zusammen aus: Die Bibliothek erzeugt „restricted“-konforme Pods, Pod Security Admission oder Kyverno erzwingen es.
  • Jede neue Bibliotheksversion verändert gerenderte Manifeste vieler Teams. Ein automatischer Diff aller Nutzer-Charts im CI fängt Überraschungen ab.
  • Bibliotheken liegen in einer Registry mit unveränderlichen Versionen (Tag 15); file:// taugt nur fürs lokale Entwickeln.
  • Zu viel Logik in der Bibliothek macht Charts unlesbar. Bewährt hat sich: Labels, Namen, SecurityContexts und einfache Standardobjekte – Sonderfälle bleiben im Chart.