Kubernetes items
See also: Guide to Kubernetes
Manage resources in Kubernetes clusters.
k8s_namespaces = {
"my-app": {},
"my-previous-app": {'delete': True},
}
k8s_deployments = {
"my-app/my-deployment": {
'manifest': {
...
},
},
}
Note that the names of all items in a namespace must be prefixed with the name of their namespace and a forward slash /
. Resource items will automatically depend on their namespace if you defined it.
Resource types
Resource type | Bundle attribute | apiVersion |
---|---|---|
Cluster Role | k8s_clusterroles | rbac.authorization.k8s.io/v1 |
Cluster Role Binding | k8s_clusterrolebindings | rbac.authorization.k8s.io/v1 |
Config Map | k8s_configmaps | v1 |
Cron Job | k8s_cronjobs | batch/v1beta1 |
Custom Resource Definition | k8s_crd | apiextensions.k8s.io/v1beta1 |
Daemon Set | k8s_daemonsets | v1 |
Deployment | k8s_deployments | extensions/v1beta1 |
Ingress | k8s_ingresses | extensions/v1beta1 |
Namespace | k8s_namespaces | v1 |
Network Policy | k8s_networkpolicies | networking.k8s.io/v1 |
Persistent Volume Claim | k8s_pvc | v1 |
Role | k8s_roles | rbac.authorization.k8s.io/v1 |
Role Binding | k8s_rolebindings | rbac.authorization.k8s.io/v1 |
Service | k8s_services | v1 |
Service Account | k8s_serviceaccounts | v1 |
Secret | k8s_secrets | v1 |
StatefulSet | k8s_statefulsets | apps/v1 |
(any) | k8s_raw | (any) |
You can define Custom Resources like this:
k8s_crd = {
"custom-thing": {
'manifest': {
'spec': {
'names': {
'kind': "CustomThing",
},
},
},
},
}
k8s_raw = {
"foo/CustomThing/baz": {
'manifest': {
'apiVersion': "example.com/v1",
},
},
}
The special k8s_raw
items can also be used to create resources that BundleWrap does not support natively:
k8s_raw = {
"foo/HorizontalPodAutoscaler/baz": {
'manifest': {
'apiVersion': "autoscaling/v2beta1",
},
},
}
Resources outside any namespace can be created with k8s_raw
by omitting the namespace in the item name (so that the name starts with /
).
Attribute reference
See also: The list of generic builtin item attributes
context
Only used with Mako and Jinja2 manifests (see manifest_processing
below). The values of this dictionary will be available from within the template as variables named after the respective keys.
delete
Set this to True
to have the resource removed.
manifest
The resource definition (as defined in the Kubernetes API) formatted as a Python dictionary (will be converted to JSON and passed to kubectl apply
). Mutually exclusive with manifest_file
.
manifest_file
Filename of the resource definition relative to the manifests
subdirectory of your bundle. Filenames must end in .yaml
, .yml
, or .json
to indicate file format. Mutually exclusive with manifest
.
manifest_processor
Set this to jinja2
or mako
if you want to use a template engine to process your manifest_file
. Defaults to None
.