Kubernetes Packaging and Customization Basics
Kubernetes Packaging and Customization Basics covers how to package and tailor applications for Kubernetes environments, ensuring efficient deployment and management.
Kubernetes Packaging and Customization Basics covers the tools and conventions used to bundle related manifests into reusable, distributable units, and to adapt a shared set of manifests to the specific needs of different environments without duplicating and hand-editing raw YAML for each one. As the number of objects needed to describe even a modest application grows, Deployments, Services, ConfigMaps, Secrets, Ingress rules, managing them as a loose collection of individually applied files quickly becomes error-prone, motivating dedicated packaging and customization tooling.
The Problem of Manifest Sprawl
Repetition Across Environments
A typical application requires largely the same set of Kubernetes objects in development, staging, and production, differing only in details such as replica counts, resource limits, environment-specific configuration values, or image tags. Maintaining fully separate manifest files per environment duplicates the majority of each file and makes it easy for environments to drift out of sync unintentionally.
Repetition Across Applications
Organizations running many similar services, internal microservices following the same basic Deployment-Service-Ingress shape, face a related problem: each new service requires largely boilerplate manifests, differing mainly in names, images, and a handful of parameters.
Kustomize
Base and Overlay Model
Kustomize structures configuration as a base, a set of plain, valid Kubernetes manifests, and one or more overlays, each applying patches, additional resources, or parameter substitutions on top of that base to produce a fully rendered manifest set for a specific environment, without ever templating the underlying YAML itself.
# base/kustomization.yaml
resources:
- deployment.yaml
- service.yaml
# overlays/production/kustomization.yaml
resources:
- ../../base
patches:
- target:
kind: Deployment
name: codartium-api
patch: |-
- op: replace
path: /spec/replicas
value: 10
kustomize build overlays/production
kubectl apply -k overlays/production
No Templating Language
Kustomize deliberately avoids introducing a separate templating syntax; every input file remains ordinary, directly readable YAML, and customization is expressed through structured patches and well-defined transformers rather than string substitution, which keeps the base manifests valid and lintable on their own.
Helm
Charts as Packages
Helm packages a set of related manifests into a chart: a directory containing templates written in Go's templating language, a values.yaml file supplying default parameter values, and a Chart.yaml file describing metadata such as the chart's name and version.
# Chart.yaml
apiVersion: v2
name: codartium-app
version: 1.4.0
appVersion: "4.1.0"
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-app
spec:
replicas: {{ .Values.replicaCount }}
template:
spec:
containers:
- name: app
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Releases and Values Overrides
Installing a chart creates a release, a named, versioned instance of that chart's rendered manifests applied to the cluster. Environment-specific configuration is supplied by overriding values at install or upgrade time, either through a separate values file or individual flags, without modifying the chart's templates themselves.
helm install codartium-prod ./charts/codartium-app -f values-production.yaml
helm upgrade codartium-prod ./charts/codartium-app --set replicaCount=12
helm rollback codartium-prod 3
Chart Repositories and Dependencies
Charts can be published to and installed from chart repositories, and a chart can declare dependencies on other charts, allowing complex applications composed of multiple sub-services to be packaged, versioned, and installed as a single coherent unit.
Choosing an Approach
Kustomize's Strengths
Kustomize suits teams that prefer working with plain, directly applicable YAML and want customization expressed as structured overlays rather than a templating language, and it is built into kubectl itself, requiring no additional tooling installation.
Helm's Strengths
Helm suits teams distributing reusable, parameterized packages to be installed by others, particularly third-party or open-source software, where a versioned release model, dependency management, and a large ecosystem of published charts provide significant leverage.
kubectl kustomize overlays/staging | kubectl diff -f -
helm template codartium-app ./charts/codartium-app -f values-staging.yaml
Combined Usage
The two tools are not mutually exclusive: some workflows use Helm to install third-party software with published charts, while using Kustomize to manage an organization's own first-party application manifests, or use Kustomize as a final overlay step atop manifests rendered by helm template.
Customization as Part of a Delivery Pipeline
Packaging and customization tooling is most effective when integrated into a broader delivery workflow: base manifests or charts stored in version control, overlays or values files reviewed like any other code change, and a pipeline, often a GitOps controller, applying the rendered output to each target cluster automatically once changes are merged.