Part 4: Chart Dependencies and Repositories

Series Navigation: ← Part 3: Advanced Templates and Values | Back to Series Overview | Part 5: Production Best Practices β†’

Introduction

In the previous parts, we built self-contained Charts. But real-world applications rarely run in isolation. Your TypeScript API likely needs Redis for caching, PostgreSQL for data, or other supporting services. That's where Chart dependencies come in.

In this article, I'll share how I manage dependencies, work with Chart repositories, and build reusable Charts. These patterns have helped me maintain consistency across dozens of microservices.

Understanding Chart Dependencies

Chart dependencies allow your Chart to install and configure other Charts automatically. Instead of manually installing Redis and your API separately, you define Redis as a dependency, and Helm handles both.

Why Use Dependencies?

From my experience deploying TypeScript applications:

  1. Consistency: Same Redis configuration across all environments

  2. Simplicity: One helm install deploys complete stack

  3. Version Control: Lock dependency versions for reproducibility

  4. Configuration Management: Override dependency values from parent chart

  5. Testing: Deploy complete application stack in CI/CD

Defining Dependencies

Dependencies are defined in Chart.yaml.

Basic Dependency Declaration

Chart.yaml:

Dependency Fields

  • name: Chart name (must match chart name in repository)

  • version: Chart version (supports ranges: 1.2.3, ~1.2.3, ^1.2.3, 1.x.x)

  • repository: Repository URL or alias

  • condition: Enable/disable dependency via values

  • tags: Categorize dependencies for bulk enable/disable

  • alias: Use different name for dependency (for multiple instances)

  • import-values: Import values from dependency

Managing Dependencies

Download Dependencies

This creates:

  • charts/ directory with downloaded chart archives

  • Chart.lock file tracking exact versions

Chart.lock File

After running helm dependency update, Helm creates Chart.lock:

Best practices:

  • βœ… Commit Chart.lock to version control

  • βœ… Run helm dep update after changing Chart.yaml

  • βœ… Use specific versions in production

  • ❌ Don't commit charts/ directory (add to .helmignore)

Configuring Dependencies

Configure dependency values in your parent values.yaml.

Parent values.yaml

values.yaml:

Using Dependency Values in Templates

templates/deployment.yaml:

Dependency Conditions and Tags

Conditional Dependencies

Enable/disable individual dependencies:

Chart.yaml:

Install with conditions:

Tags for Bulk Control

Group dependencies with tags:

Chart.yaml:

values.yaml:

Install with tag control:

Multiple Instances with Aliases

Use aliases to include the same chart multiple times:

Chart.yaml:

values.yaml:

Importing Values from Dependencies

Share values between parent and child charts:

Child chart values.yaml (dependency):

Parent Chart.yaml:

Parent template usage:

Chart Repositories

Chart repositories host and distribute Helm Charts.

Repository Types

  1. HTTP/HTTPS Repositories: Traditional index-based repos

  2. OCI Registries: Store charts as OCI artifacts (Docker-style)

  3. Git Repositories: Charts stored in Git repos

  4. Artifact Hub: Central discovery portal

Adding Repositories

Using Repository Aliases

In Chart.yaml, use repository aliases:

Creating Your Own Chart Repository

I maintain private repositories for internal Charts.

HTTP Repository

1. Package your charts:

2. Create repository index:

3. Host files:

4. Use repository:

GitHub Pages Repository

I use GitHub Pages for public Charts:

1. Create repository structure:

2. Package and index:

3. Enable GitHub Pages pointing to /docs directory

4. Use repository:

Modern approach using container registries:

1. Package chart:

2. Login to registry:

3. Push chart:

4. Install from OCI registry:

Chart.yaml with OCI:

Chart Versioning Strategy

Versioning is critical for production deployments.

Semantic Versioning

I follow SemVer for Chart versions:

  • MAJOR: Incompatible changes (breaking)

  • MINOR: Backwards-compatible features

  • PATCH: Backwards-compatible fixes

Chart.yaml:

Version Ranges in Dependencies

Versioning Workflow

My workflow for versioning:

Practical Example: Complete Stack

Here's a complete Chart for a TypeScript API with all dependencies:

Chart.yaml:

values.yaml:

Install complete stack:

Managing Subcharts

Subcharts in charts/ directory are managed automatically.

Local Subcharts

Create local subcharts for shared components:

Parent Chart.yaml:

Local subcharts don't need helm dep update.

Best Practices

From my experience managing Charts:

  1. Pin Dependency Versions: Use exact versions in production

  2. Commit Chart.lock: Ensures reproducible builds

  3. Use Conditions: Allow flexible dependency management

  4. OCI Registries: Modern, efficient chart distribution

  5. Version Semantically: Clear versioning prevents confusion

  6. Document Dependencies: README should list required dependencies

  7. Test Combinations: Verify charts work with/without dependencies

  8. Namespace Isolation: Test dependencies don't conflict

  9. Resource Limits: Always set limits for dependencies

  10. Security Scanning: Scan dependencies for vulnerabilities

What's Next?

We've covered dependencies and repositories comprehensively. In the final part (Part 5), we'll explore production-ready patterns:

  • Secrets management and encryption

  • Security best practices

  • Rollback strategies

  • CI/CD integration

  • Chart testing and validation

  • Performance optimization

  • Troubleshooting production issues


Series Navigation: ← Part 3: Advanced Templates and Values | Back to Series Overview | Part 5: Production Best Practices β†’

Key Takeaways

  • βœ… Dependencies automate installation of supporting services

  • βœ… Chart.lock ensures reproducible deployments

  • βœ… Conditions and tags provide flexible dependency management

  • βœ… OCI registries are the modern approach for chart distribution

  • βœ… Semantic versioning clarifies compatibility

  • βœ… Repository management enables sharing charts across teams

  • βœ… Aliases allow multiple instances of same chart

  • βœ… Always pin versions in production environments

Last updated