Should dependencies between Helm charts reflect dependencies between microservices?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
In the world of cloud-native applications and DevOps practices, Kubernetes has become a de facto platform for deploying and managing microservices. Helm, often described as the Kubernetes package manager, simplifies application deployment. A common debate among developers and DevOps professionals centers around whether the dependencies between Helm charts should directly correspond to the dependencies between the underlying microservices they deploy. This article delves into the pros and cons of this practice, providing technical explanations, examples, and a holistic view of the subject.
Understanding Helm and Microservices
Helm Charts
Helm is a tool that helps you manage Kubernetes applications. Helm charts are packages containing the necessary YAML configuration files and templates that describe a set of Kubernetes resources. They allow you to define, install, and upgrade even the most complex Kubernetes applications.
Microservices Architecture
Microservices is an architectural style that structures an application as a collection of services. Each service is:
- Loosely coupled
- Independently deployable
- Organized around business capabilities
- Often implemented via different programming languages or frameworks
In essence, Helm charts package the deployment configurations necessary for these microservices.
Mapping Dependencies: Helm Charts vs. Microservices
Should dependencies within Helm charts mirror those found between microservices? Let’s look at both sides of the argument.
Pros of Mapping Dependencies
- Consistency and Clarity: When Helm chart dependencies reflect microservice dependencies, it provides a clear mapping of the entire application structure. Each chart becomes a direct representation of a service, making it easier to understand the application's architecture.
- Simplified Management: If a Helm chart inherently knows about its microservices' dependencies, it can help automate deployment orders. This is especially useful during initial deployments and scaling operations.
- Inter-Service Communication: Ensuring Helm chart dependencies follow microservices dependencies can ensure that all necessary services are up and running when an application is deployed, reducing the likelihood of self-healing mechanisms triggering unnecessarily.
Cons of Mapping Dependencies
- Complexity in Chart Management: Microservices applications often have complex dependency graphs. Reflecting these in Helm charts can lead to intertwined dependencies that are hard to manage at the Helm level.
- Decoupling and Flexibility: Helm charts that mirror microservices may lose the inherent flexibility of microservices architecture, where services can be updated or replaced independently.
- Resource Overhead: Enforcing strict deployment orders could lead to longer initialization times or unnecessary resource usage, while in many cases, microservices can start independently and handle transient failures.
Examples
- Direct Mapping Example:Consider a simple application with three microservices: A, B, and C, where A depends on B, and B depends on C. In this setup, if Helm charts follow these dependencies:
- Chart A specifies B as a dependency.
- Chart B specifies C as a dependency. This ensures B is deployed before A, and C before B. This strict ordering may be necessary for applications needing absolute sequence in service availability.
- Decoupled Example:Now, let's consider a more flexible scenario. Instead of directly linking the Helm charts, we allow services to check for the availability of their dependencies through health checks or retries:
- Chart A, B, and C are deployed independently.
- A contains logic to check for B's availability and proceeds with retry logic if B is not ready. This approach can lead to a more resilient system where services are designed to handle uncertainties.
Factors to Consider
When deciding whether to mirror dependencies within Helm charts, consider the following:
- Service Dependency Criticality: Is it vital for the service to be available before others?
- Deployment Frequency: Are services updated and redeployed at different rates?
- Operational Overheads: Does managing dependencies in Helm increase or reduce deployment complexity?
- Scaling Requirements: How will dependency mapping affect scaling operations and performance?
Summary Table
| Pros of Mapping Dependencies | Cons of Mapping Dependencies |
| Consistency and Clarity | Complexity in Chart Management |
| Simplified Management | Decoupling and Flexibility |
| Inter-Service Communication | Resource Overhead |
| Deployment Order Automation | Longer Initialization Times |
Conclusion
The decision about whether dependencies between Helm charts should mirror those between microservices is nuanced, often dependent on specific application needs and team preferences. While direct mapping can provide consistency and order, allowing independence provides resilience and flexibility. Each organization needs to weigh the advantages against the pitfalls based on their unique operational context. Consider hybrid models where only critical dependencies are mapped, optimizing both stability and flexibility. This decision should also involve collaboration between software architects, developers, and DevOps practitioners to ensure the most efficient and maintainable system architecture.
Related reading
- Show metrics in Grafana from the Kubernetes Pod that was scraped last by Prometheus
- sidecar vs init container in kubernetes
- Skaffold syncs files but pod doesn't refresh
- Skipping service no endpoints found when attempting to fetch certificate with traefik 2 cert-manager http-01 challenge
- Should Health Checks call other App Health Checks
- Should I have a separate assembly for interfaces?
- Should I have separate containers for Flask, uWSGI, and nginx?
- Should I take ILogger, ILoggerT, ILoggerFactory or ILoggerProvider for a library?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.