%PDF- %PDF-
| Direktori : /proc/self/root/proc/3522530/root/lib/python2.7/site-packages/salt/states/ |
| Current File : //proc/self/root/proc/3522530/root/lib/python2.7/site-packages/salt/states/kubernetes.pyc |
�
���^c @@ s> d Z d d l m Z d d l Z d d l Z d d l m Z e j e � Z d � Z
d � Z d d � Z d d d d d d
� Z d d d d d d � Z d d � Z d
� Z d � Z d d � Z d d d d d � Z d d � Z d d d d d � Z d d � Z d d d d d d � Z d � Z d � Z d � Z d S( s�
Manage kubernetes resources as salt states
==========================================
NOTE: This module requires the proper pillar values set. See
salt.modules.kubernetesmod for more information.
.. warning::
Configuration options will change in 2019.2.0.
The kubernetes module is used to manage different kubernetes resources.
.. code-block:: yaml
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
.. versionadded: 2017.7.0
i ( t absolute_importN( t sixc C@ s
d t k S( sE
Only load if the kubernetes module is available in __salt__
s kubernetes.ping( t __salt__( ( ( s: /usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt __virtual__^ s c C@ s t | d <| | d <| S( sB
Helper function to propagate errors to
the end user.
t resultt comment( t False( t rett err_msg( ( s: /usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt _errore s
t defaultc K@ s i | d 6i d 6t d 6d d 6} t d | | | � } | d k rl t d sT t n d | d <d | d <| St d r� d | d <d | d <| St d
| | | � } | d d k r� t | d <i i d
d 6d d 6d 6| d <| d | d <n d j | � | d <| S( s�
Ensures that the named deployment is absent from the given namespace.
name
The name of the deployment
namespace
The name of the namespace
t namet changesR t R s kubernetes.show_deploymentt tests The deployment does not exists% The deployment is going to be deleteds kubernetes.delete_deploymentt codei� t absentt newt presentt olds kubernetes.deploymentt messages# Something went wrong, response: {0}N( R R t Nonet __opts__t Truet format( R t namespacet kwargsR t
deploymentt res( ( s: /usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt deployment_absento s,
R
c
K@ s� i | d 6i d 6t d 6d d 6} | s. | rA | rA t | d � S| d k rV i } n | d k rk i } n t d | | | � } | d k rt d r� d | d <d | d <| St d
d | d | d | d
| d | d | d t | � } i i d 6| d 6| d d j | | � <ni t d r,d | d <| St j d � d | d <t d d | d | d | d
| d | d | d t | � } i | d 6| d
6| d <t | d <| S( s�
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.
R R R R
R s@ 'source' cannot be used in combination with 'metadata' or 'spec's kubernetes.show_deploymentR s% The deployment is going to be createds kubernetes.create_deploymentR t metadatat spect sourcet templatet saltenvR R s {0}.{1}s( Forcing the recreation of the deployments5 The deployment is already present. Forcing recreations kubernetes.replace_deploymentN(
R R R R R t __env__R t logt infoR (
R R R R R R! R R R R ( ( s: /usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt deployment_present� s` !
!
c
K@ s� i | d 6i d 6t d 6d d 6} | s. | rA | rA t | d � S| d k rV i } n | d k rk i } n t d | | | � } | d k rt d r� d | d <d | d <| St d
d | d | d | d
| d | d | d t | � } i i d 6| d 6| d d j | | � <no t d r,d | d <| St j d � d | d <t d d | d | d | d
| d | d | d | d t | � } i | d 6| d
6| d <t | d <| S( s�
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.
R R R R
R s@ 'source' cannot be used in combination with 'metadata' or 'spec's kubernetes.show_serviceR s"