
    H                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	Jr
  SSKJr  SSKJr  SS	KJr  SS
KJr   " S S\R$                  \
R$                  \R&                  5      rg)zMSets configuration properties of the Policy Controller component deployments.    )absolute_import)division)unicode_literals)protos)base)command)deployment_configs)flags)
exceptionsc                   B    \ rS rSrSrSrSr\S 5       rS r	S r
S rSrg	)
Set   a  Sets configuration of the Policy Controller components.

Customizes on-cluster components of Policy Controller. Supported
properties may be set with this command, or removed with 'remove'. These
components are managed as individual kubernetes deployments (e.g. 'admission')
in the gatekeeper-system namespace.

When setting cpu or memory limits and requests, Kubernetes-standard resource
units are used.

All properties set using this command will overwrite previous properties, with
the exception of tolerations which can only be added, and any number may be
added. To edit a toleration, use 'remove' to first delete it, and then 'set'
the desired toleration.

## EXAMPLES

To set the replica count for a component:

  $ {command} admission replica-count 3

To set the replica count for a component across all fleet memberships:

  $ {command} admission replica-count 3 --all-memberships

To set a toleration with key 'my-key' on a component (which is an 'Exists'
operator):

  $ {command} admission toleration my-key

To set a toleration with key 'my-key' and 'my-value' on a component (which is
an 'Equal' operator):

  $ {command} admission toleration my-key=my-value

To set a toleration with key 'my-key' and 'my-value' on a component, along
with the effect 'NoSchedule' (which is an 'Equal' operator):

  $ {command} admission toleration my-key=my-value --effect=NoSchedule

To set a memory limit:

  $ {command} audit memory-limit 4Gi

To set a memory request:

  $ {command} mutation memory-request 2Gi

To set a cpu limit:

  $ {command} admission cpu-limit 500m

To set a cpu request:

  $ {command} audit cpu-request 250m

To set anti-affinity to achieve high availability on the mutation deployment:

  $ {command} mutation pod-affinity anti
policycontrollerc                 6   [         R                  " US5      nUR                  5         UR                  S[        R
                  SS9  UR                  S[        R                  SS9  UR                  SSS	9  UR                  S
[        R                  [        SS9  g )Nzset deployment configuration
deploymentzuThe PolicyController deployment component (e.g. "admission",  "audit" or "mutation") upon which to set configuration.)choiceshelppropertyzProperty to be set.valuezUThe value to set the property to. Valid input varies based on the property being set.)r   z--effectz&Applies only to "toleration" property.)r   typer   )	r
   	PocoFlagsadd_membershipsadd_argumentr   G8R_COMPONENTSSUPPORTED_PROPERTIESK8S_SCHEDULING_OPTIONSstr)clsparser	cmd_flagss      >lib/surface/container/fleet/policycontroller/deployment/set.pyArgsSet.Args^   s    (FGI
))G	   //"  
 0   115	      c           	          U R                  U5      nUR                  5        VVs0 s H  u  p4X0R                  XA5      _M     nnnU R                  U5      $ s  snnf N)
path_specsitemssetupdate_specs)selfargsspecspathspecupdated_specss         r!   RunSet.Run~   sO    OOD!EBG++-P-JDT88D//-MP]++ Qs   Ac                    [         R                  " UR                  R                  R                  5      nUR                  UR                  U R                  R                  5       5      nU R                  UUR                  UR                  UR                  5      X2R                  '   [         R                  " U R                  R                  R                  5       U5      nXQR                  R                  l        U$ r&   )r   additional_properties_to_dictr   policyControllerHubConfigdeploymentConfigsgetr   messages0PolicyControllerPolicyControllerDeploymentConfigset_deployment_configr   r   effectset_additional_propertiesPolicyControllerHubConfigDeploymentConfigsValue)r+   r/   r,   cfgsdeployment_cfgdcvs         r!   r)   Set.set   s    //77IID XXFFHN
 !66

	D 
*
*//FFH$C IL33EKr$   c                 D   US:X  a"  [         R                  " U R                  XU5      $ Ub  [        R                  " S5      eUS:X  a!  [         R
                  " U R                  X5      $ US:X  a!  [         R                  " U R                  X5      $ US:X  a!  [         R                  " U R                  X5      $ US:X  a!  [         R                  " U R                  X5      $ US:X  a  [         R                  " X5      $ US:X  a!  [         R                  " U R                  X5      $ g )	N
tolerationz6"effect" flag only accepted when setting a toleration.z	cpu-limitzcpu-requestzmemory-limitzmemory-requestzreplica-countzpod-affinity)r   add_tolerationr8   r   Errorupdate_cpu_limitupdate_cpu_requestupdate_mem_limitupdate_mem_requestupdate_replica_countupdate_pod_affinity)r+   r@   propr   r;   s        r!   r:   Set.set_deployment_config   s   |&&
--  
B  {((NN}**4==.PP~((NN**4==.PP,,^CC~++
--  r$    N)__name__
__module____qualname____firstlineno____doc__feature_namemf_nameclassmethodr"   r1   r)   r:   __static_attributes__rO   r$   r!   r   r      s5    ;z $,' >,0r$   r   N)rT   
__future__r   r   r   7googlecloudsdk.api_lib.container.fleet.policycontrollerr   3googlecloudsdk.command_lib.container.fleet.featuresr   =googlecloudsdk.command_lib.container.fleet.membershipfeaturesmf_base;googlecloudsdk.command_lib.container.fleet.policycontrollerr   r	   r   r
   googlecloudsdk.corer   UpdateCommandPocoCommandr   rO   r$   r!   <module>rb      sM    T &  ' J D Y O h M *U$

g33W5H5H Ur$   