Warning
This module will be removed from Salt in version 3009 in favor of the kubernetes Salt Extension.
Module for handling kubernetes calls.
kubernetes Python client < 4.0
PyYAML < 6.0
The k8s API settings are provided either in a pillar, in the minion's config file, or in master's config file:
kubernetes.kubeconfig: '/path/to/kubeconfig'
kubernetes.kubeconfig-data: '<base64 encoded kubeconfig content'
kubernetes.context: 'context'
These settings can be overridden by adding context and `kubeconfig or kubeconfig_data parameters when calling a function.
The data format for kubernetes.kubeconfig-data value is the content of kubeconfig base64 encoded in one line.
Only kubeconfig or kubeconfig-data should be provided. In case both are provided kubeconfig entry is preferred.
CLI Example:
salt '*' kubernetes.nodes kubeconfig=/etc/salt/k8s/kubeconfig context=minikube
New in version 2017.7.0.
Changed in version 2019.2.0.
Warning
Configuration options changed in 2019.2.0. The following configuration options have been removed:
kubernetes.user
kubernetes.password
kubernetes.api_url
kubernetes.certificate-authority-data/file
kubernetes.client-certificate-data/file
kubernetes.client-key-data/file
Please use now:
kubernetes.kubeconfig or kubernetes.kubeconfig-data
kubernetes.context
Return a list of kubernetes configmaps defined in the namespace
CLI Example:
salt '*' kubernetes.configmaps
salt '*' kubernetes.configmaps namespace=default
Creates the kubernetes configmap as defined by the user.
CLI Example:
salt 'minion1' kubernetes.create_configmap settings default '{"example.conf": "# example file"}'
salt 'minion2' kubernetes.create_configmap name=settings namespace=default data='{"example.conf": "# example file"}'
Creates the kubernetes deployment as defined by the user.
Creates a namespace with the specified name.
CLI Example:
salt '*' kubernetes.create_namespace salt
salt '*' kubernetes.create_namespace name=salt
Creates the kubernetes deployment as defined by the user.
Creates the kubernetes secret as defined by the user.
CLI Example:
salt 'minion1' kubernetes.create_secret passwords default '{"db": "letmein"}'
salt 'minion2' kubernetes.create_secret name=passwords namespace=default data='{"db": "letmein"}'
Creates the kubernetes service as defined by the user.
Deletes the kubernetes configmap defined by name and namespace
CLI Example:
salt '*' kubernetes.delete_configmap settings default
salt '*' kubernetes.delete_configmap name=settings namespace=default
Deletes the kubernetes deployment defined by name and namespace
CLI Example:
salt '*' kubernetes.delete_deployment my-nginx
salt '*' kubernetes.delete_deployment name=my-nginx namespace=default
Deletes the kubernetes namespace defined by name
CLI Example:
salt '*' kubernetes.delete_namespace salt
salt '*' kubernetes.delete_namespace name=salt
Deletes the kubernetes pod defined by name and namespace
CLI Example:
salt '*' kubernetes.delete_pod guestbook-708336848-5nl8c default
salt '*' kubernetes.delete_pod name=guestbook-708336848-5nl8c namespace=default
Deletes the kubernetes secret defined by name and namespace
CLI Example:
salt '*' kubernetes.delete_secret confidential default
salt '*' kubernetes.delete_secret name=confidential namespace=default
Deletes the kubernetes service defined by name and namespace
CLI Example:
salt '*' kubernetes.delete_service my-nginx default
salt '*' kubernetes.delete_service name=my-nginx namespace=default
Return a list of kubernetes deployments defined in the namespace
CLI Example:
salt '*' kubernetes.deployments
salt '*' kubernetes.deployments namespace=default
Return the names of the available namespaces
CLI Example:
salt '*' kubernetes.namespaces
salt '*' kubernetes.namespaces kubeconfig=/etc/salt/k8s/kubeconfig context=minikube
Return the details of the node identified by the specified name
CLI Example:
salt '*' kubernetes.node name='minikube'
Set the value of the label identified by label_name to label_value on the node identified by the name node_name. Creates the label if not present.
CLI Example:
salt '*' kubernetes.node_add_label node_name="minikube" label_name="foo" label_value="bar"
Return the labels of the node identified by the specified name
CLI Example:
salt '*' kubernetes.node_labels name="minikube"
Removes the label identified by label_name from the node identified by the name node_name.
CLI Example:
salt '*' kubernetes.node_remove_label node_name="minikube" label_name="foo"
Return the names of the nodes composing the kubernetes cluster
CLI Example:
salt '*' kubernetes.nodes
salt '*' kubernetes.nodes kubeconfig=/etc/salt/k8s/kubeconfig context=minikube
Checks connections with the kubernetes API server. Returns True if the connection can be established, False otherwise.
CLI Example:
salt '*' kubernetes.ping
Return a list of kubernetes pods defined in the namespace
CLI Example:
salt '*' kubernetes.pods
salt '*' kubernetes.pods namespace=default
Replaces an existing configmap with a new one defined by name and namespace with the specified data.
CLI Example:
salt 'minion1' kubernetes.replace_configmap settings default '{"example.conf": "# example file"}'
salt 'minion2' kubernetes.replace_configmap name=settings namespace=default data='{"example.conf": "# example file"}'
Replaces an existing deployment with a new one defined by name and namespace, having the specificed metadata and spec.
Replaces an existing secret with a new one defined by name and namespace, having the specificed data.
CLI Example:
salt 'minion1' kubernetes.replace_secret name=passwords data='{"db": "letmein"}'
salt 'minion2' kubernetes.replace_secret name=passwords namespace=saltstack data='{"db": "passw0rd"}'
Replaces an existing service with a new one defined by name and namespace, having the specificed metadata and spec.
Return a list of kubernetes secrets defined in the namespace
CLI Example:
salt '*' kubernetes.secrets
salt '*' kubernetes.secrets namespace=default
Return a list of kubernetes services defined in the namespace
CLI Example:
salt '*' kubernetes.services
salt '*' kubernetes.services namespace=default
Return the kubernetes configmap defined by name and namespace.
CLI Example:
salt '*' kubernetes.show_configmap game-config default
salt '*' kubernetes.show_configmap name=game-config namespace=default
Return the kubernetes deployment defined by name and namespace
CLI Example:
salt '*' kubernetes.show_deployment my-nginx default
salt '*' kubernetes.show_deployment name=my-nginx namespace=default
Return information for a given namespace defined by the specified name
CLI Example:
salt '*' kubernetes.show_namespace kube-system
Return POD information for a given pod name defined in the namespace
CLI Example:
salt '*' kubernetes.show_pod guestbook-708336848-fqr2x
salt '*' kubernetes.show_pod guestbook-708336848-fqr2x namespace=default
Return the kubernetes secret defined by name and namespace. The secrets can be decoded if specified by the user. Warning: this has security implications.
CLI Example:
salt '*' kubernetes.show_secret confidential default
salt '*' kubernetes.show_secret name=confidential namespace=default
salt '*' kubernetes.show_secret name=confidential decode=True
Return the kubernetes service defined by name and namespace
CLI Example:
salt '*' kubernetes.show_service my-nginx default
salt '*' kubernetes.show_service name=my-nginx namespace=default