Author: Nick Santos
Helper functions for creating Kubernetes namespaces and manipulating namespaces on Kubernetes objects.
Returns YAML for a Kubernetes namespace.
namespace_create(name: str, allow_duplicates: boolean = False, annotations: List [str] = [], labels: List [str] = [])
Deploys a namespace to the cluster. Equivalent to
load('ext://namespace', 'namespace_yaml')
k8s_yaml(namespace_yaml('name'), allow_duplicates=False)
Given YAML for Kubernetes objects, return new YAML with a different namespace.
load('ext://namespace', 'namespace_create', 'namespace_inject')
namespace_create('my-namespace')
k8s_yaml(namespace_inject(read_file('deployment.yaml'), 'my-namespace'))
load('ext://namespace', 'namespace_create', 'namespace_inject')
ns = 'user-%s' % os.environ.get('USER', 'anonymous')
namespace_create(ns)
k8s_yaml(namespace_inject(read_file('deployment.yaml'), ns))
load('ext://namespace', 'namespace_create', 'namespace_inject')
namespace_create(
'my-namespace',
annotations=['kubernetes.io/metadata.name: my-namespace'],
labels=['kubernetes.io/metadata.name: my-namespace']
)
k8s_yaml(namespace_inject(read_file('deployment.yaml'), 'my-namespace'))
-
namespace_inject
assumes all resources are namespaced-scoped. The behavior is undefined for cluster-scoped resources. -
This extension doesn't do any validation to confirm that namespace names are valid. The behavior is undefined on invalid namespaces.