Namespaces Helper
Create Kubernetes Namespaces with the ohMyHelm namespaces helper, including schema constraints and a note on the setPreInstallHook bug.
Namespaces Helper
The root helper namespaces creates one or more v1/Namespace resources. Names are automatically truncated to a maximum of 63 characters and stripped of trailing hyphens.
Supported Fields
According to values.schema.json, only the following fields are allowed under namespaces (additionalProperties: false applies both to namespaces and to every entry in spaces[]):
| Field | Type | Description |
|---|---|---|
namespaces.spaces[].name |
String | Name of the Namespace to create |
namespaces.setPreInstallHook |
Boolean | Present in the schema, but currently ineffective due to a template bug (see warning below) |
Basic Configuration
namespaces:
spaces:
- name: acme-dev
- name: acme-staging
- name: acme-prod
Resulting Kubernetes manifest:
apiVersion: v1
kind: Namespace
metadata:
name: acme-dev
---
apiVersion: v1
kind: Namespace
metadata:
name: acme-staging
---
apiVersion: v1
kind: Namespace
metadata:
name: acme-prod
Note on setPreInstallHook
**Workaround:** Create the release namespace with `helm upgrade --install --create-namespace` or define a Namespace with its pre-install hook annotation and labels directly via the [`manifests` helper](/docs/ohmyhelm/helpers/manifests/).
Alternative with Labels and Pre-Install Hook via manifests:
manifests:
- apiVersion: v1
kind: Namespace
content:
metadata:
name: acme-prod
labels:
pod-security.kubernetes.io/enforce: restricted
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "-10"