%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/states/kubernetes.pyc

�
���^c@@s>dZddlmZddlZddlZddlmZeje�Z	d�Z
d�Zdd�Zdddd	d	d
�Zdddd	d	d�Zdd�Zd
�Zd�Zdd�Zddddd�Zdd�Zddddd�Zdd�Zdddd	d	d�Zd�Zd�Zd�ZdS(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(tabsolute_importN(tsixcC@s
dtkS(sE
    Only load if the kubernetes module is available in __salt__
    skubernetes.ping(t__salt__(((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt__virtual__^scC@st|d<||d<|S(sB
    Helper function to propagate errors to
    the end user.
    tresulttcomment(tFalse(tretterr_msg((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt_errores

tdefaultcK@si|d6id6td6dd6}td|||�}|dkrltdsTtnd|d<d|d<|Stdr�d	|d<d|d<|Std
|||�}|ddkr�t|d<iid
d6dd6d6|d<|d|d<ndj|�|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
    tnametchangesRtRskubernetes.show_deploymentttestsThe deployment does not exists%The deployment is going to be deletedskubernetes.delete_deploymenttcodei�tabsenttnewtpresenttoldskubernetes.deploymenttmessages#Something went wrong, response: {0}N(RRtNonet__opts__tTruetformat(Rt	namespacetkwargsRt
deploymenttres((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytdeployment_absentos,






R
c
K@s�i|d6id6td6dd6}|s.|rA|rAt|d�S|dkrVi}n|dkrki}ntd|||�}|dkrtdr�d|d<d	|d<|Std
d|d|d|d
|d|d|dt|�}	iid6|	d6|ddj||�<nitdr,d|d<|Stjd�d|d<tdd|d|d|d
|d|d|dt|�}	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.
    RRRR
Rs@'source' cannot be used in combination with 'metadata' or 'spec'skubernetes.show_deploymentRs%The deployment is going to be createdskubernetes.create_deploymentRtmetadatatspectsourcettemplatetsaltenvRRs{0}.{1}s(Forcing the recreation of the deployments5The deployment is already present. Forcing recreationskubernetes.replace_deploymentN(
RR	RRRt__env__RtlogtinfoR(
RRRRR R!RRRR((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytdeployment_present�s`!

		


	!




	
c
K@s�i|d6id6td6dd6}|s.|rA|rAt|d�S|dkrVi}n|dkrki}ntd|||�}|dkrtdr�d|d<d	|d<|Std
d|d|d|d
|d|d|dt|�}	iid6|	d6|ddj||�<notdr,d|d<|Stjd�d|d<tdd|d|d|d
|d|d|d|dt|�}	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.
    RRRR
Rs@'source' cannot be used in combination with 'metadata' or 'spec'skubernetes.show_serviceRs"The service is going to be createdskubernetes.create_serviceRRRR R!R"RRs{0}.{1}s%Forcing the recreation of the services2The service is already present. Forcing recreationskubernetes.replace_servicetold_serviceN(
RR	RRRR#RR$R%R(
RRRRR R!RRtserviceR((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytservice_present�sb!

		


	!




	
cK@si|d6id6td6dd6}td|||�}|dkrltdsTtnd|d<d|d<|Stdr�d	|d<d|d<|Std
|||�}|ddkr�t|d<iid
d6dd6d6|d<|d|d<ndj|�|d<|S(s�
    Ensures that the named service is absent from the given namespace.

    name
        The name of the service

    namespace
        The name of the namespace
    RRRR
Rskubernetes.show_serviceRsThe service does not exists"The service is going to be deletedskubernetes.delete_serviceRi�RRRRskubernetes.serviceRs#Something went wrong, response: {0}N(RRRRRR(RRRRR(R((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytservice_absentWs,






cK@sci|d6id6td6dd6}td||�}|dkritdsQtnd|d<d|d<|Stdr�d	|d<d|d<|Std
||�}|ddks�t|d
tj�r�d|d
ks�t|d
t�rL|d
ddkrLt|d<iidd6dd6d6|d<|dr?|d|d<q_d|d<ndj	|�|d<|S(sa
    Ensures that the named namespace is absent.

    name
        The name of the namespace
    RRRR
Rskubernetes.show_namespaceRsThe namespace does not exists$The namespace is going to be deletedskubernetes.delete_namespaceRi�tstatustTerminatingtphaseRRRRskubernetes.namespaceRs#Something went wrong, response: {0}N(
RRRRRt
isinstanceRtstring_typestdictR(RRRRR((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytnamespace_absent�s8








cK@s�i|d6id6td6dd6}td||�}|dkr�tdrcd|d<d|d<|Std	||�}t|d<iid
6|d6|dd<n$tds�tnd|d<d
|d<|S(sd
    Ensures that the named namespace is present.

    name
        The name of the namespace.

    RRRR
Rskubernetes.show_namespaceRs$The namespace is going to be createdskubernetes.create_namespaceRRRsThe namespace already existsN(RRRRR(RRRRR((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytnamespace_present�s$






cK@s�i|d6id6td6dd6}td|||�}|dkrltdsTtnd|d<d|d<|Stdr�d	|d<d|d<|Std
|||�t|d<iidd6d
d6d6|d<d|d<|S(s�
    Ensures that the named secret is absent from the given namespace.

    name
        The name of the secret

    namespace
        The name of the namespace
    RRRR
Rskubernetes.show_secretRsThe secret does not exists!The secret is going to be deletedskubernetes.delete_secretRRRRskubernetes.secretsSecret deletedN(RRRRR(RRRRtsecret((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt
secret_absent�s(







c	K@s�i|d6id6td6dd6}|r;|r;t|d�Std|||�}|dkr�|dkrri}ntdr�d|d<d	|d<|Std
d|d|d|d
|d|dt|�}iid6|d6|ddj||�<nmtdrd|d<d|d<|Stjd�d|d<tdd|d|d|d
|d|dt|�}it	|d�d6|d<t
|d<|S(s!
    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.
    RRRR
Rs2'source' cannot be used in combination with 'data'skubernetes.show_secretRs!The secret is going to be createdskubernetes.create_secretRtdataR R!R"RRs{0}.{1}s"The secret is going to be replaceds%Forcing the recreation of the services1The secret is already present. Forcing recreationskubernetes.replace_secretN(RR	RRRR#RR$R%tlistR(	RRR5R R!RRR3R((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytsecret_present�sX

	


	!





	
cK@s�i|d6id6td6dd6}td|||�}|dkrltdsTtnd|d<d|d<|Stdr�d	|d<d|d<|Std
|||�t|d<iidd6d
d6d6|d<d|d<|S(s	
    Ensures that the named configmap is absent from the given namespace.

    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.
    RRRR
Rskubernetes.show_configmapRsThe configmap does not exists$The configmap is going to be deletedskubernetes.delete_configmapRRRRskubernetes.configmapsConfigMap deletedN(RRRRR(RRRRt	configmap((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytconfigmap_absentSs(







c	K@s�i|d6id6td6dd6}|r;|r;t|d�S|dkrPi}ntd|||�}|dkr�tdr�d|d<d	|d<|Std
d|d|d|d
|d|dt|�}iid6|d6|ddj||�<nmtdrd|d<d|d<|Stjd�d|d<tdd|d|d|d
|d|dt|�}i|dd6|d<t	|d<|S(s3
    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.
    RRRR
Rs2'source' cannot be used in combination with 'data'skubernetes.show_configmapRs$The configmap is going to be createdskubernetes.create_configmapRR5R R!R"RRs{0}.{1}s%The configmap is going to be replaceds%Forcing the recreation of the services4The configmap is already present. Forcing recreationskubernetes.replace_configmapN(
RR	RRRR#RR$R%R(	RRR5R R!RRR8R((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytconfigmap_present}sX

	


	!





	
cK@s2i|d6id6td6dd6}td|||�}|dkrltdsTtnd|d<d|d<|Stdr�d	|d<d|d<|Std
|||�}|ddks�|ddkrt|d<iid
d6dd6d6|d<|ddkr
d|d<q.|d|d<ndj|�|d<|S(s�
    Ensures that the named pod is absent from the given namespace.

    name
        The name of the pod

    namespace
        The name of the namespace
    RRRR
Rskubernetes.show_podRsThe pod does not existsThe pod is going to be deletedskubernetes.delete_podRi�RRRRskubernetes.podsIn progressRs#Something went wrong, response: {0}N(RRRRRR(RRRRtpodR((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt
pod_absent�s0





 

c
K@sji|d6id6td6dd6}|s.|rA|rAt|d�S|dkrVi}n|dkrki}ntd|||�}|dkrtdr�d|d<d	|d<|Std
d|d|d|d
|d|d|dt|�}	iid6|	d6|ddj||�<n0tdr,d|d<|Sd|d<t|d<|Si|d6|d
6|d<t|d<|S(s�
    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.
    RRRR
Rs@'source' cannot be used in combination with 'metadata' or 'spec'skubernetes.show_podRsThe pod is going to be createdskubernetes.create_podRRRR R!R"RRs{0}.{1}s�salt is currently unable to replace a pod without deleting it. Please perform the removal of the pod requiring the 'pod_absent' state if this is the desired behaviour.N(RR	RRRR#RR(
RRRRR R!RRR;R((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytpod_present�sP!

		


	!




cK@s�i|d6id6td6dd6}td||�}||kritdsQtnd|d<d|d<|Stdr�d	|d<d|d<|Std
d|d||�t|d<iid
d6dd6d6|d<d|d<|S(s�
    Ensures that the named label is absent from the node.

    name
        The name of the label

    node
        The name of the node
    RRRR
Rskubernetes.node_labelsRsThe label does not exists The label is going to be deletedskubernetes.node_remove_labelt	node_namet
label_nameRRRRskubernetes.node_labelsLabel removed from nodeN(RRRRR(RtnodeRRtlabels((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytnode_label_absentUs.








c	K@sIi|d6id6td6dd6}td||�}|jd�d}g}g}x:|D]2}|j|�r�|j|�q[|j|�q[W|s�tds�tnd|d<d	|d<|Stdr�d
|d<d|d<|Sx(|D] }tdd|d
||�q�Wt|d<iit|�d6|d6d6|d<d|d<|S(s�
    Ensures the label folder doesn't exist on the specified node.

    name
        The name of label folder

    node
        The name of the node
    RRRR
Rskubernetes.node_labelst/RsThe label folder does not exists'The label folder is going to be deletedskubernetes.node_remove_labelR>R?RRs#kubernetes.node_label_folder_absentsLabel folder removed from nodeN(	RRtstript
startswithtappendRRRR6(	RR@RRRAtfoldertlabels_to_dropt
new_labelstlabel((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytnode_label_folder_absents@











cK@sIi|d6id6td6dd6}td||�}||kr�tdrcd|d<d|d<|Std	d
|d|d||�nt|||kr�t|d<d
|d<|Stdr�d|d<d|d<|Sd|d<td	d|d
|d||�tj|�}|||<i|d6|d6|ddj||�<t|d<|S(s�
    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.
    RRRR
Rskubernetes.node_labelsRsThe label is going to be setskubernetes.node_add_labelR?tlabel_valueR>s4The label is already set and has the specified values The label is going to be updateds,The label is already set, changing the valueRRs{0}.{1}N(RRRRRtcopyR(RR@tvalueRRRAt
old_labels((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pytnode_label_present�sF














(t__doc__t
__future__RRMtloggingtsalt.extRt	getLoggert__name__R$RR	RRR&R)R*R1R2R4R7R9R:R<R=RBRKRP(((s:/usr/lib/python2.7/site-packages/salt/states/kubernetes.pyt<module>RsP		
+[Z)	2	!+R,N.S	*	6

Zerion Mini Shell 1.0