All Products
Search
Document Center

:Update a policy instance in a specified ACK cluster

更新时间:Aug 31, 2023

You can call the ModifyPolicyInstance operation to update a policy instance in a specified Container Service for Kubernetes (ACK) cluster.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request syntax

PUT /clusters/cluster_id/policies/policy_name HTTP/1.1
Content-Type:application/json

{
  "action" : "String",
  "instance_name" : "String",
  "namespaces" : [ "String" ]
}

Request parameters

Table 1. Request path parameters
ParameterTypeRequiredExampleDescription
cluster_idStringYesc8155823d057948c69a****

The ID of the cluster that you want to manage.

policy_nameStringYesACKAllowedRepos

The name of the policy.

Table 2. Request body parameters
ParameterTypeRequiredExampleDescription
actionStringNodeny

The action of the policy. Valid values:

  • deny: blocks deployments that match the policy.
  • warn: generates alerts for deployments that match the policy.
instance_nameStringNoallowed-repos-cbhhb

The name of the policy instance that you want to update.

namespaceStringNo["test3","test4"]

The applicable scope of the policy instance.

Default value: "". This indicates all namespaces in the cluster.

parametersMapNo"restrictedNamespaces": [ "test" ]

Parameters of the policy instance. For more information about parameter configuration rules, see Predefined security policies of ACK.

Response syntax

HTTP/1.1 200 OK
Content-Type:application/json

{
  "instances" : [ "String" ]
}

Response parameters

Table 3. Response body parameters
ParameterTypeExampleDescription
instancesArray of String[ "allowed-repos-kqxnc" ]

The policy instance that is updated.

Sample requests

Submit the following sample request to update a policy instance in a specified ACK cluster:

PUT /clusters/c8155823d057948c69a****/policies/ACKAllowedRepos HTTP/1.1
Host:cs.aliyuncs.com
Content-Type:application/json

{
  "action" : "deny",
  "instance_name" : "allowed-repos-cbhhb",
  "namespaces" : [ "[\"test3\",\"test4\"]" ]
}

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ModifyPolicyInstanceResponse>
    <instances>allowed-repos-cbhhb</instances>
</ModifyPolicyInstanceResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "instances" : [ "allowed-repos-cbhhb" ]
}

Error codes

For a list of error codes, visit the API Error Center.