salt.states.kubernetes

Manage kubernetes resources as salt states

NOTE: This module requires the proper pillar values set. See salt.modules.kubernetes for more information.

Warning

Configuration options will change in Flourine.

The kubernetes module is used to manage different kubernetes resources.

my-nginx:
  kubernetes.deployment_present:
    - namespace: default
      metadata:
        app: frontend
      spec:
        replicas: 1
        template:
          metadata:
            labels:
              run: my-nginx
          spec:
            containers:
            - name: my-nginx
              image: nginx
              ports:
              - containerPort: 80

my-mariadb:
  kubernetes.deployment_absent:
    - namespace: default

# kubernetes deployment as specified inside of
# a file containing the definition of the the
# deployment using the official kubernetes format
redis-master-deployment:
  kubernetes.deployment_present:
    - name: redis-master
    - source: salt://k8s/redis-master-deployment.yml
  require:
    - pip: kubernetes-python-module

# kubernetes service as specified inside of
# a file containing the definition of the the
# service using the official kubernetes format
redis-master-service:
  kubernetes.service_present:
    - name: redis-master
    - source: salt://k8s/redis-master-service.yml
  require:
    - kubernetes.deployment_present: redis-master

# kubernetes deployment as specified inside of
# a file containing the definition of the the
# deployment using the official kubernetes format
# plus some jinja directives
 nginx-source-template:
  kubernetes.deployment_present:
    - source: salt://k8s/nginx.yml.jinja
    - template: jinja
  require:
    - pip: kubernetes-python-module


# Kubernetes secret
k8s-secret:
  kubernetes.secret_present:
    - name: top-secret
      data:
        key1: value1
        key2: value2
        key3: value3
salt.states.kubernetes.configmap_absent(name, namespace='default', **kwargs)

Ensures that the named configmap is absent from the given namespace.

name
The name of the configmap
namespace
The name of the namespace
salt.states.kubernetes.configmap_present(name, namespace='default', data=None, source='', template='', **kwargs)

Ensures that the named configmap is present inside of the specified namespace with the given data. If the configmap exists it will be replaced.

name
The name of the configmap.
namespace
The namespace holding the configmap. The 'default' one is going to be used unless a different one is specified.
data
The dictionary holding the configmaps.
source
A file containing the data of the configmap in plain format.
template
Template engine to be used to render the source file.
salt.states.kubernetes.deployment_absent(name, namespace='default', **kwargs)

Ensures that the named deployment is absent from the given namespace.

name
The name of the deployment
namespace
The name of the namespace
salt.states.kubernetes.deployment_present(name, namespace='default', metadata=None, spec=None, source='', template='', **kwargs)

Ensures that the named deployment is present inside of the specified namespace with the given metadata and spec. If the deployment exists it will be replaced.

name
The name of the deployment.
namespace
The namespace holding the deployment. The 'default' one is going to be used unless a different one is specified.
metadata
The metadata of the deployment object.
spec
The spec of the deployment object.
source
A file containing the definition of the deployment (metadata and spec) in the official kubernetes format.
template
Template engine to be used to render the source file.
salt.states.kubernetes.namespace_absent(name, **kwargs)

Ensures that the named namespace is absent.

name
The name of the namespace
salt.states.kubernetes.namespace_present(name, **kwargs)

Ensures that the named namespace is present.

name
The name of the deployment.
salt.states.kubernetes.node_label_absent(name, node, **kwargs)

Ensures that the named label is absent from the node.

name
The name of the label
node
The name of the node
salt.states.kubernetes.node_label_folder_absent(name, node, **kwargs)

Ensures the label folder doesn't exist on the specified node.

name
The name of label folder
node
The name of the node
salt.states.kubernetes.node_label_present(name, node, value, **kwargs)

Ensures that the named label is set on the named node with the given value. If the label exists it will be replaced.

name
The name of the label.
value
Value of the label.
node
Node to change.
salt.states.kubernetes.pod_absent(name, namespace='default', **kwargs)

Ensures that the named pod is absent from the given namespace.

name
The name of the pod
namespace
The name of the namespace
salt.states.kubernetes.pod_present(name, namespace='default', metadata=None, spec=None, source='', template='', **kwargs)

Ensures that the named pod is present inside of the specified namespace with the given metadata and spec. If the pod exists it will be replaced.

name
The name of the pod.
namespace
The namespace holding the pod. The 'default' one is going to be used unless a different one is specified.
metadata
The metadata of the pod object.
spec
The spec of the pod object.
source
A file containing the definition of the pod (metadata and spec) in the official kubernetes format.
template
Template engine to be used to render the source file.
salt.states.kubernetes.secret_absent(name, namespace='default', **kwargs)

Ensures that the named secret is absent from the given namespace.

name
The name of the secret
namespace
The name of the namespace
salt.states.kubernetes.secret_present(name, namespace='default', data=None, source='', template='', **kwargs)

Ensures that the named secret is present inside of the specified namespace with the given data. If the secret exists it will be replaced.

name
The name of the secret.
namespace
The namespace holding the secret. The 'default' one is going to be used unless a different one is specified.
data
The dictionary holding the secrets.
source
A file containing the data of the secret in plain format.
template
Template engine to be used to render the source file.
salt.states.kubernetes.service_absent(name, namespace='default', **kwargs)

Ensures that the named service is absent from the given namespace.

name
The name of the service
namespace
The name of the namespace
salt.states.kubernetes.service_present(name, namespace='default', metadata=None, spec=None, source='', template='', **kwargs)

Ensures that the named service is present inside of the specified namespace with the given metadata and spec. If the deployment exists it will be replaced.

name
The name of the service.
namespace
The namespace holding the service. The 'default' one is going to be used unless a different one is specified.
metadata
The metadata of the service object.
spec
The spec of the service object.
source
A file containing the definition of the service (metadata and spec) in the official kubernetes format.
template
Template engine to be used to render the source file.