base
by Das Meta
A Base Helm chart for Kubernetes
About this chart
Introduction
This chart provides a base template helpers which can be used to develop new charts using Helm package manager.
Prerequisites
- Kubernetes 1.18+
- Helm 3.7.1
commands
# minimal setup
helm repo add dasmeta https://dasmeta.github.io/helm # adds dasmeta helm chart into helm repos list
helm upgrade --install -n default my-test-app dasmeta/base --version 0.3.11 -f ./my-test-app.values.yaml # create/change helm release, you have to have ./my-test-app.values.yaml created, check examples to know how to create/configure it
# to get diff and debug check what will be created/changed on apply
helm plugin install https://github.com/databus23/helm-diff # to install helm diff plugin
helm diff upgrade --install -n default my-test-app dasmeta/base --version 0.3.11 -f ./my-test-app.values.yaml # shows diff of what will be create/changed
# for case you have the chart as dependency
helm dependency update # in case you added `dasmeta/base` in helm chart Chart.yaml as dependency this command will pull/update dependency
helm upgrade --install my-app . # allows to run current directory helm chart
The default values and related description/examples can be found in ./values.yaml file
Key values
| Key | Description | Default / Example |
|---|---|---|
image.repository | Main container image repository | set per app |
image.tag | Image tag. Ignored when image.digest is set. Falls back to Chart.appVersion when empty | set per app |
image.digest | Optional image digest. When non-empty, the main container is repository@digest and this takes precedence over image.tag | "" |
initContainers[].image.digest | Optional digest for one init container. When non-empty, that init container is repository@digest and this takes precedence over its image.tag. An empty or omitted digest keeps repository:tag | unset |
initContainers[].securityContext | Optional Kubernetes container security context, rendered as supplied for each init container. Also supported in single-object format. Omitted, empty or null values omit the field; the main container's context is not copied | unset |
containerPort | Main container port | set per app |
service.enabled | Create Service | true |
service.type | Service type | ClusterIP |
service.sessionAffinity | Service session affinity (None or ClientIP) | unset / no affinity |
service.sessionAffinityConfig | Optional sessionAffinityConfig (e.g. ClientIP timeout) | {} |
ingress.enabled | Enable Ingress | false |
config | Env vars for main container (map) | example in values.yaml |
externalSecretsApiVersion | API version of the generated ExternalSecret. Set to external-secrets.io/v1beta1 if the cluster's external secret operator does not serve v1 | external-secrets.io/v1 |
gatewayApi.enabled | Enable Gateway API (subchart) | false |
pdb.enabled | Create a PodDisruptionBudget. Leave unset for the safe default: created automatically when the effective replica floor is 2 or more, omitted below that. true at a floor below 2 is refused | unset (derived) |
pdb.maxUnavailable | Ceiling on simultaneously-unavailable replicas. Absolute number or percentage string. Recommended form; can never become a zero-eviction budget | "25%" (applied by the template) |
pdb.minAvailable | Floor on available replicas. Mutually exclusive with maxUnavailable. Must stay below the effective replica floor. Never set to autoscaling.minReplicas | unset |
pdb.allowZeroEvictions | Allow a budget that permits zero voluntary evictions, for a workload rolled by hand that automation must never evict. Renders with a warning and an annotation rather than being refused | false |
pdb.selectorOverride | Labels the budget selects on. Only needed where the chart cannot derive them — see Flagger below | unset (derived) |
pdb.pdbName | Override the generated PodDisruptionBudget name | chart fullname |
terminationGracePeriodSeconds | Time Kubernetes waits for the pod to shut down before killing it. Must exceed the defaultLifecycle.preStop sleep | unset (Kubernetes default 30) |
0.5.0
The main container can be pinned by digest. Set image.digest to a full digest such as sha256:<64 hex chars>. The rendered image is <repository>@<digest>. When image.digest is empty, rendering is unchanged: image.tag is used, and an empty tag still falls back to Chart.appVersion. If both image.digest and image.tag are set, the digest wins.
image:
repository: my-registry/my-app
digest: "sha256:<full-image-digest>"
See examples/base/with-image-digest.yaml. This applies to the main application container. Extra containers still use their own image tag.
0.6.0
Each init container can be pinned by digest the same way. Set initContainers[].image.digest. That init container renders as <repository>@<digest>. When the digest is missing or empty, the init container still renders repository:tag. If both image.digest and image.tag are set on an init container, the digest wins. Other init container fields are unchanged.
initContainers:
- name: migrate
image:
repository: my-registry/migrate
digest: "sha256:<full-image-digest>"
command: ["/bin/sh", "-c"]
args: ["echo migrated"]
See examples/base/with-init-container-digest.yaml.
0.7.0
Init containers now support an optional securityContext. Each non-empty context is rendered as supplied, including nested fields and explicit false values. This works with both the list format and the legacy single-object initContainers format.
initContainers:
- name: migrator-service
image:
repository: example/migrator
tag: example
pullPolicy: IfNotPresent
securityContext:
runAsNonRoot: true
runAsUser: 1002
runAsGroup: 1001
privileged: false
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
Omit securityContext, or set it to {} or null, to preserve the existing output without a container-level context. The chart does not copy the main container's securityContext to init containers. Pod-level settings remain controlled by podSecurityContext; Kubernetes applies overlapping settings according to its security context rules.
See examples/base/with-init-container-security-context.yaml. Run the regression cases with ./tests/run.sh base init-security-context.
Upgrading to 0.4.0
This release changes rendered output. Read this before bumping.
PodDisruptionBudgets are now created by default
A budget is created automatically when the effective replica floor is 2 or
more, defaulting to maxUnavailable: "25%". The effective replica floor is
autoscaling.minReplicas when autoscaling is enabled, and replicaCount
otherwise. Below a floor of 2 no budget is created, because a budget over a
single replica either blocks every drain or protects nothing.
Previously pdb.enabled defaulted to false, so most services had no budget at
all and a node drain could evict every replica at once, emptying the service's
endpoints for one to two minutes.
Budgets that permit zero evictions are now refused
The chart now fails to render any budget that permits no voluntary eviction at the replica floor. This is deliberate and it is the more important half of the change.
Such a budget blocks every drain-based operation: node consolidation stalls, reclaimed-capacity (spot) replacement stalls, and managed node group upgrades fail on pod eviction. The reported symptom is that node scaling or the cluster upgrade is stuck, which sends the investigation somewhere other than the service that caused it.
Refused configurations:
| Configuration | Why |
|---|---|
minAvailable >= effective replica floor | permits nothing |
maxUnavailable: 0 | permits nothing |
| a percentage resolving to 0 permitted evictions | only "0%" can, since budget percentages round up |
a value outside the IntOrString domain | negative numbers, percentages above 100, and anything that is neither |
both minAvailable and maxUnavailable set | the Kubernetes API accepts only one |
pdb.enabled: true at a replica floor below 2 | no budget over a single replica is both safe and useful |
Every message above names pdb.allowZeroEvictions as the way through, so the escape hatch is discoverable
from the failure rather than from this document.
When a zero-eviction budget is correct
Some workloads are rolled by hand, pod by pod, after cooling an internal process down first, and must never be evicted by automation. For those, a budget permitting nothing is the right answer rather than a mistake:
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 3
pdb:
enabled: true
minAvailable: 3 # equals the floor, permits nothing -- deliberately
allowZeroEvictions: true # say so, and the chart renders it
podAnnotations:
karpenter.sh/do-not-disrupt: "true" # stop the autoscaler retrying a drain it cannot finish
The chart then renders the budget, annotates it dasmeta.io/zero-evictions, and prints a warning on every
install and upgrade. Nothing is silenced: node drains still block, node group upgrades still fail on
eviction, and the node stops receiving AMI patches until someone moves the workload. The flag records that
those consequences are intended, and the annotation is what tells whoever finds the stuck drain months later
that it was a decision.
The default budget tracks the current replica count
maxUnavailable defaults to "25%" at every replica floor.
A percentage rather than a number computed by the chart, because Kubernetes resolves a percentage at
runtime against the current expected pod count, while a number is fixed at template time from the floor
and never moves. For a service with minReplicas: 10, maxReplicas: 100:
| running replicas | absolute 2 | "25%" |
|---|---|---|
| 10 | 2 | 2 |
| 20 | 2 | 5 |
| 100 | 2 | 25 |
25% is not arbitrary: it is what a Deployment rollout already does by default, so draining paces at a rate the service demonstrably tolerates every time it is deployed.
Rounding. The disruption controller resolves both minAvailable and maxUnavailable percentages
rounding up. That is not the same as a Deployment rolling update, where maxUnavailable rounds down
— so "25%" is 1 permitted eviction at a floor of 2 under budget rules and 0 under rollout rules. Only
"0%" can resolve to zero.
This paces draining, not rollouts. A Deployment rollout deletes pods directly and never uses the
Eviction API, so its speed comes from strategy.rollingUpdate (Kubernetes defaults to 25% unavailable /
25% surge) and a PodDisruptionBudget has no say in it. What the budget paces is node drains: consolidation,
reclaimed-capacity replacement, and cluster upgrades.
Override in either direction — an absolute number to pin it regardless of scale, or a different percentage.
When the chart does NOT create a budget for you
Automatic creation needs the chart to own both the workload and the selector. It stands down where it does not, because an unrequested budget there is wrong rather than merely useless:
| situation | why |
|---|---|
workloadType is not Deployment | the workload template does not render, so the budget would select nothing |
selectorLabelsOverride is set | the release points at another release's pods. Two budgets over one pod makes it un-evictable, because the eviction API refuses a pod covered by more than one |
Setting pdb.enabled: true still creates one in both cases — the author has taken ownership, and the
guards above only govern what happens unasked.
Flagger
Under a Flagger rolloutStrategy the budget follows the generated primary, not the canary:
- with autoscaling enabled, the floor is
rolloutStrategy.configs.primaryScalerMinReplicas, falling back toautoscaling.minReplicasexactly as Flagger does - with autoscaling disabled, Flagger emits no
autoscalerRefat all and the primary mirrors the Deployment, so the floor isreplicaCount - the selector is the Deployment's full selector —
selectorLabelsplus anything added throughmatchLabels— with one key suffixed-primary: the first ofapp,name,app.kubernetes.io/namethat is present, which is how Flagger chooses it
Both matter. Flagger scales the canary Deployment to zero between rollouts, so a budget derived from the
canary would take its floor from a workload that is not serving and select pods that do not exist —
protection that looks present and is not. The bundled canary example has a canary floor of 1 and a primary
floor of 5, so reading the canary would have rendered no budget at all.
Flagger walks its -selector-labels list in order and suffixes the first key it finds in the target's
selector, leaving the rest untouched. A release whose selector carries app therefore gets
app=<value>-primary while app.kubernetes.io/name is unchanged — assuming the last key is the suffixed
one produces a selector matching zero pods. Where the selector contains none of those keys the chart
refuses rather than guessing, because Flagger itself would refuse the canary.
That order is Flagger's -selector-labels default, and it is a controller-wide flag this chart does not
set — so there is deliberately no per-release option to change it here. One would alter only the budget
while Flagger kept its own order, which
Deploy base with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has base on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartbase is pinned at v0.7.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply