403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/kubernetes.cpython-310.pyc
o

;j/c�@s�dZddlZddlZe�e�Zdd�Zdd�Zd'dd	�Z				
	
d(dd�Z					
	
d(d
d�Z
d'dd�Zdd�Zdd�Z
d'dd�Z	d)dd�Zd'dd�Z	d)dd�Zd'dd�Z				
	
d(dd �Zd!d"�Zd#d$�Zd%d&�ZdS)*a�
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
�NcCsdtvrdSdS)zE
    Only load if the kubernetes module is available in __salt__
    zkubernetes.pingT)Fz%kubernetes module could not be loaded)�__salt__�rr�J/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/kubernetes.py�__virtual__YsrcCsd|d<||d<|S)zB
    Helper function to propagate errors to
    the end user.
    F�result�commentr)�ret�err_msgrrr�_errorbsr
�defaultcK��|iddd�}td||fi|��}|dur&tdsdnd|d<d	|d
<|Stdr4d|d
<d|d<|Std||fi|��}|d
dkrZd|d<dddd�i|d<|d|d
<|Sd|��|d
<|S)z�
    Ensures that the named deployment is absent from the given namespace.

    name
        The name of the deployment

    namespace
        The name of the namespace
    F���name�changesrr�kubernetes.show_deploymentN�testTrzThe deployment does not existrz%The deployment is going to be deletedzkubernetes.delete_deployment�code��zkubernetes.deployment�absent�present��new�oldr�message� Something went wrong, response: �r�__opts__)r�	namespace�kwargsr�
deployment�resrrr�deployment_absentl�$�r"r
c

Ks|iddd�}|s|r|rt|d�S|duri}|duri}td||fi|��}|dur[tdr;d|d<d	|d
<|Stdd||||||td�|��}	i|	d
�|d|�d|��<n$tdred|d<|St�d�d|d
<tdd||||||td�|��}	||d�|d<d|d<|S)a�
    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.
    Fr
r�@'source' cannot be used in combination with 'metadata' or 'spec'Nrrrz%The deployment is going to be createdrzkubernetes.create_deployment�rr�metadata�spec�source�template�saltenv�rrr�.z(Forcing the recreation of the deploymentz5The deployment is already present. Forcing recreationzkubernetes.replace_deployment�r&r'Tr�r
rr�__env__�log�info)
rrr&r'r(r)rrr r!rrr�deployment_present�s\"���

��r2c
Ks|iddd�}|s|r|rt|d�S|duri}|duri}td||fi|��}|dur[tdr;d|d<d	|d
<|Stdd||||||td�|��}	i|	d
�|d|�d|��<n%tdred|d<|St�d�d|d
<tdd|||||||td�|��}	||d�|d<d|d<|S)a�
    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.
    Fr
rr$N�kubernetes.show_servicerrz"The service is going to be createdrzkubernetes.create_servicer%r+rr,�%Forcing the recreation of the servicez2The service is already present. Forcing recreationzkubernetes.replace_service)rrr&r'r(r)Zold_servicer*r-Trr.)
rrr&r'r(r)rr�servicer!rrr�service_present�s^"���

�	�r6cKr)z�
    Ensures that the named service is absent from the given namespace.

    name
        The name of the service

    namespace
        The name of the namespace
    Fr
rr3NrTrzThe service does not existrz"The service is going to be deletedzkubernetes.delete_servicerrzkubernetes.servicerrrrrrr)rrrrr5r!rrr�service_absentCr#r7cKs|iddd�}td|fi|��}|dur%tdsdnd|d<d	|d
<|Stdr3d|d
<d|d<|Std|fi|��}|d
dks_t|dt�rPd|dvs_t|dt�r~|dddkr~d|d<dddd�i|d<|drx|d|d
<|Sd|d
<|Sd|��|d
<|S)za
    Ensures that the named namespace is absent.

    name
        The name of the namespace
    Fr
r�kubernetes.show_namespaceNrTrzThe namespace does not existrz$The namespace is going to be deletedzkubernetes.delete_namespacerr�statusZTerminatingZphasezkubernetes.namespacerrrrrr)rr�
isinstance�str�dict�rrrrr!rrr�namespace_absentgs6����r>cKs�|iddd�}td|fi|��}|dur<tdr#d|d<d|d	<|Std
|fi|��}d|d<i|d�|d
d<|StdsBdnd|d<d|d	<|S)zd
    Ensures that the named namespace is present.

    name
        The name of the namespace.

    Fr
rr8Nrrz$The namespace is going to be createdrzkubernetes.create_namespaceTr+rrzThe namespace already existsrr=rrr�namespace_present�s�r?cK�|iddd�}td||fi|��}|dur&tdsdnd|d<d	|d
<|Stdr4d|d
<d|d<|Std||fi|��d|d<d
ddd�i|d<d|d
<|S)z�
    Ensures that the named secret is absent from the given namespace.

    name
        The name of the secret

    namespace
        The name of the namespace
    Fr
r�kubernetes.show_secretNrTrzThe secret does not existrz!The secret is going to be deletedzkubernetes.delete_secretzkubernetes.secretrrrrzSecret deletedr)rrrr�secretrrr�
secret_absent�srCc		Ks|iddd�}|r|rt|d�Std||fi|��}|durR|dur%i}tdr3d|d<d	|d
<|Stdd|||||td�|��}i|d
�|d|�d|��<n'tdr`d|d<d|d
<|St�d�d|d
<tdd|||||td�|��}dt|d�i|d<d|d<|S)a!
    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.
    Fr
r�2'source' cannot be used in combination with 'data'rANrrz!The secret is going to be createdrzkubernetes.create_secret�rr�datar(r)r*r+rr,z"The secret is going to be replacedr4z1The secret is already present. Forcing recreationzkubernetes.replace_secretrFTr)r
rrr/r0r1�list)	rrrFr(r)rrrBr!rrr�secret_present�sT
��	
��
�rHcKr@)a	
    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.
    Fr
r�kubernetes.show_configmapNrTrzThe configmap does not existrz$The configmap is going to be deletedzkubernetes.delete_configmapzkubernetes.configmaprrrrzConfigMap deletedr)rrrr�	configmaprrr�configmap_absentsrKc		Ks|iddd�}|r|rt|d�S|duri}td||fi|��}|durRtdr3d|d<d	|d
<|Stdd|||||td�|��}i|d
�|d|�d|��<n'tdr`d|d<d|d
<|St�d�d|d
<tdd|||||td�|��}d|di|d<d|d<|S)a3
    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.
    Fr
rrDNrIrrz$The configmap is going to be createdrzkubernetes.create_configmaprEr+rr,z%The configmap is going to be replacedr4z4The configmap is already present. Forcing recreationzkubernetes.replace_configmaprFTrr.)	rrrFr(r)rrrJr!rrr�configmap_presentBsR
��	
��
rLcKs�|iddd�}td||fi|��}|dur&tdsdnd|d<d	|d
<|Stdr4d|d
<d|d<|Std||fi|��}|d
dksK|d
durld|d<dddd�i|d<|d
durdd|d
<|S|d|d
<|Sd|��|d
<|S)z�
    Ensures that the named pod is absent from the given namespace.

    name
        The name of the pod

    namespace
        The name of the namespace
    Fr
r�kubernetes.show_podNrTrzThe pod does not existrzThe pod is going to be deletedzkubernetes.delete_podrrzkubernetes.podrrrrzIn progressrrr)rrrr�podr!rrr�
pod_absent�s*��rOc

Ks�|iddd�}|s|r|rt|d�S|duri}|duri}td||fi|��}|dur[tdr;d|d<d	|d
<|Stdd||||||td�|��}	i|	d
�|d|�d|��<ntdred|d<|Sd|d
<d|d<|S||d�|d<d|d<|S)a�
    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.
    Fr
rr$NrMrrzThe pod is going to be createdrzkubernetes.create_podr%r+rr,z�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.r-Tr)r
rrr/)
rrr&r'r(r)rrrNr!rrr�pod_present�sJ"���
�rPcKs�|iddd�}td|fi|��}||vr%tdsdnd|d<d	|d
<|Stdr3d|d
<d|d<|Stdd||d
�|��d|d<dddd�i|d<d|d
<|S)z�
    Ensures that the named label is absent from the node.

    name
        The name of the label

    node
        The name of the node
    Fr
r�kubernetes.node_labelsrTNrzThe label does not existrz The label is going to be deleted�kubernetes.node_remove_label��	node_name�
label_namezkubernetes.node_labelrrrrzLabel removed from noderr)r�noderr�labelsrrr�node_label_absentsrXc	Ks�|iddd�}td|fi|��}|�d�d}g}g}|D]}|�|�r+|�|�q|�|�q|sCtds9dnd|d	<d
|d<|StdrQd|d<d|d	<|S|D]}td
d||d�|��qSd|d	<dt|�|d�i|d<d|d<|S)z�
    Ensures the label folder doesn't exist on the specified node.

    name
        The name of label folder

    node
        The name of the node
    Fr
rrQ�/rTNrzThe label folder does not existrz'The label folder is going to be deletedrRrSz#kubernetes.node_label_folder_absentr+rzLabel folder removed from noder)r�strip�
startswith�appendrrG)	rrVrrrWZfolderZlabels_to_dropZ
new_labelsZlabelrrr�node_label_folder_absent's8
���r]cKs�|iddd�}td|fi|��}||vr1tdr#d|d<d|d	<|Std
d|||d�|��n/|||krAd|d<d
|d	<|StdrOd|d<d|d	<|Sd|d	<td
d|||d�|��t�|�}|||<||d�|d|�d|��<d|d<|S)z�
    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.
    Fr
rrQrNrzThe label is going to be setrzkubernetes.node_add_label)rU�label_valuerTTz4The label is already set and has the specified valuez The label is going to be updatedz,The label is already set, changing the value)rTrUr^r+rr,r)rr�copy)rrV�valuerrrWZ
old_labelsrrr�node_label_presentVs>����
ra)r)rNNr
r
)rNNN)�__doc__r_�logging�	getLogger�__name__r0rr
r"r2r6r7r>r?rCrHrKrLrOrPrXr]rarrrr�<module>sLR
	

&
�[
�
Z$(
%
�
N&
�
H)
�T"/

Youez - 2016 - github.com/yon3zu
LinuXploit