In Chapters 1-9, you've built individual Helm charts that deploy applications with templating, hooks, and distribution strategies. But what happens when you have 10 microservices? Do you repeat the same labels, resource probes, and annotations in each chart? What if your security team requires specific SecurityContext defaults across all deployments?
This chapter introduces library charts—a Helm pattern that solves this through reusable templates. Instead of duplicating patterns across charts, you encode them once in a library chart that all application charts consume. Your organization then has a single source of truth for labels, probes, resource defaults, and organizational standards.
By the end of this chapter, you'll understand how library charts enforce consistency across your platform without forcing teams into rigid constraints.
This chapter covers 8 concepts organized into 3 groups:
Time Estimate: 45 minutes
Library charts declare their purpose in Chart.yaml with type: library. This tells Helm that this chart exists to be included as a dependency, not to be installed directly.
Start with the basic structure:
Create org-standards/Chart.yaml:
Create org-standards/values.yaml with organizational defaults:
Output:
The type: library field distinguishes this chart from application charts (which have no type field or type: application).
Helm refuses to install library charts directly. They contain only template definitions, not complete deployable resources.
Try installing the library chart:
Output:
This restriction is intentional. Library charts have no .Chart.Name release—they're meant to provide helper functions that application charts use. Installing them directly would create an empty release with no resources, providing no value.
Quick Reference:
Self-Check Questions:
Answers:
Create reusable templates in the library chart that enforce organizational patterns.
Create org-standards/templates/_labels.tpl:
Create org-standards/templates/_annotations.tpl:
Create org-standards/templates/_probes.tpl:
Output:
These templates define labels, annotations, and probes that any application chart can use without reimplementation.
Application charts declare library charts as dependencies in Chart.yaml.
Create my-api/Chart.yaml with library dependency:
Create my-api/values.yaml:
Update Helm dependencies:
Output:
The helm dependency update command fetches the library chart and places it in my-api/charts/org-standards/.
Application charts use include function to reference templates from library charts.
Create my-api/templates/deployment.yaml:
Output:
The include function pulls templates from the library chart and injects them into the deployment, automatically inheriting organization labels and probes.
Applications override library defaults through the values.yaml hierarchy while maintaining organizational standards.
Application 1: Web service
Create web-service/Chart.yaml:
Create web-service/values.yaml:
Application 2: Background worker
Create bg-worker/Chart.yaml:
Create bg-worker/values.yaml:
Output:
Each application overrides organizational defaults for its context while maintaining consistency through the library chart.
Quick Reference:
Self-Check Questions:
Answers:
Library charts solve real organizational problems: enforcing security policies, maintaining labeling conventions, and standardizing resource defaults across hundreds of deployments.
Pattern 1: Security Enforcement
Create org-standards/templates/_security.tpl:
All deployments automatically get security hardening without individual configuration.
Pattern 2: Compliance Labels
Add to org-standards/values.yaml:
Platform teams enforce compliance requirements that auditors verify through labels.
Pattern 3: Cost Attribution
Create org-standards/templates/_costAttribution.tpl:
Finance teams track costs per team/project through labels injected by the library.
Templates in library charts can be extended or overridden by application charts, creating a flexible inheritance pattern.
Create org-standards/templates/_probes-extended.tpl:
Create my-app/values.yaml:
Output:
The library chart defines structure and defaults, but applications customize behavior through values without modifying templates.
Quick Reference:
Self-Check Questions:
Answers:
Before starting the exercises, be aware of these common pitfalls:
Create your own library chart with organizational standards.
Steps:
Validation: helm lint org-lib/ should show no errors
Expected outcome:
Attempt to install the library chart and observe Helm's protection.
Steps:
Expected error:
Add security context, resource requests, and probe templates to your library.
Steps:
Validation: helm lint org-lib/ should succeed
Build an application chart that declares the library as a dependency.
Steps:
Validation: ls my-service/charts/ should show org-lib
Create a deployment that uses library templates.
Steps:
Validation: Template output includes labels and probes from library
Modify application values to override library probe defaults.
Steps:
Validation: Second template output uses custom probe paths/timings
Step 1: Design Library Chart Structure
Ask AI: "I have 5 microservices that all need the same Kubernetes labels (organization, team, cost-center), security context (runAsNonRoot, readOnlyRootFilesystem), and health check probes. I want to avoid repeating this in each service's chart. How would I structure a library chart to enforce these standards across all services?"
Step 2: Evaluate the Recommendation
Review AI's response. Ask yourself:
Step 3: Request Implementation Guidance
Tell AI: "I need the library to provide templates for common labels, security context, and probes. The application charts should be able to override the probe paths (some use /health, others use /api/health-check). Walk me through how to structure the template conditionals so apps can override without duplicating code."
Step 4: Test the Pattern
Ask AI: "Show me how an application chart would declare this library as a dependency and use the library's label template. I want to see the Chart.yaml, values.yaml, and a sample deployment.yaml that pulls in the library templates."
Step 5: Validate the Approach
Ask yourself:
You built a helm-chart skill in Chapter 0. Test and improve it based on what you learned.
Ask yourself:
If you found gaps: