1.7. Policy API


1.7.1. Overview

This documentation is for the Policy resource for Red Hat Advanced Cluster Management for Kubernetes. The Policy resource has four possible requests: create, query, delete and update.

1.7.1.1. Version information

Version : 2.0.0

1.7.1.2. Contact information

Contact Email : apiteam@swagger.io

1.7.1.3. License information

License : Apache 2.0
License URL : http://www.apache.org/licenses/LICENSE-2.0.html
Terms of service : http://swagger.io/terms/

1.7.1.4. URI scheme

BasePath : /kubernetes/apis
Schemes : HTTPS

1.7.1.5. Tags

  • policy.open-cluster-management.io/v1 : Create and manage policies

1.7.1.6. External Docs

Description : Find out more about Swagger.
URL : http://swagger.io

1.7.2. Paths

1.7.2.1. Create a policy

POST /policy.open-cluster-management.io/v1/v1alpha1/namespaces/{namespace}/policies/{policy_name}
Copy to Clipboard Toggle word wrap
1.7.2.1.1. Description

Create a policy.

1.7.2.1.2. Parameters
Expand
TypeNameDescriptionSchema

Header

COOKIE
required

Authorization: Bearer {ACCESS_TOKEN} ; ACCESS_TOKEN is the user access token.

string

Path

namespace
required

Namespace that you want to use, for example, default.

string

Body

body
required

Parameters describing the policy to be created.

Application

1.7.2.1.3. Responses
Expand
HTTP CodeDescriptionSchema

200

Success

No Content

403

Access forbidden

No Content

404

Resource not found

No Content

500

Internal service error

No Content

503

Service unavailable

No Content

1.7.2.1.4. Consumes
  • application/json
1.7.2.1.5. Tags
  • policy.open-cluster-management.io
1.7.2.1.6. Example HTTP request
1.7.2.1.6.1. Request body
{
  "apiVersion": "policy.open-cluster-management.io/v1/v1alpha1",
  "kind": "Policy",
  "metadata": {
    "name": "test-policy-swagger",
    "description": "Example body for Policy API Swagger docs"
  },
  "spec": {
    "remediationAction": "enforce",
    "namespaces": {
      "include": [
        "default"
      ],
      "exclude": [
        "kube*"
      ]
    },
    "policy-templates": {
    "kind": "ConfigurationPolicy",
    "apiVersion": "policy.open-cluster-management.io/v1alpha1",
    "complianceType": "musthave",
    "metadata": {
      "namespace": null,
      "name": "test-role"
    },
    "selector": {
      "matchLabels": {
        "cloud": "IBM"
      }
    },
    "spec" : {
      "object-templates": {
        "complianceType": "mustHave",
        "objectDefinition": {
          "apiVersion": "rbac.authorization.k8s.io/v1",
          "kind": "Role",
          "metadata": {
            "name": "role-policy",
          },
          "rules": [
            {
              "apiGroups": [
                "extensions",
                "apps"
              ],
              "resources": [
                "deployments"
              ],
              "verbs": [
                "get",
                "list",
                "watch",
                "delete"
              ]
            },
            {
              "apiGroups": [
                "core"
              ],
              "resources": [
                "pods"
              ],
              "verbs": [
                "create",
                "update",
                "patch"
              ]
            },
            {
              "apiGroups": [
                "core"
              ],
              "resources": [
                "secrets"
              ],
              "verbs": [
                "get",
                "watch",
                "list",
                "create",
                "delete",
                "update",
                "patchß"
              ],
            },
          ],
        },
      },
    },
  },
Copy to Clipboard Toggle word wrap

1.7.2.2. Query all policies

GET /policy.open-cluster-management.io/v1/v1alpha1/namespaces/{namespace}/policies/{policy_name}
Copy to Clipboard Toggle word wrap
1.7.2.2.1. Description

Query your policies for more details.

1.7.2.2.2. Parameters
Expand
TypeNameDescriptionSchema

Header

COOKIE
required

Authorization: Bearer {ACCESS_TOKEN} ; ACCESS_TOKEN is the user access token.

string

Path

namespace
required

Namespace that you want to apply the policy to, for example, default.

string

1.7.2.2.3. Responses
Expand
HTTP CodeDescriptionSchema

200

Success

No Content

403

Access forbidden

No Content

404

Resource not found

No Content

500

Internal service error

No Content

503

Service unavailable

No Content

1.7.2.2.4. Consumes
  • application/json
1.7.2.2.5. Tags
  • policy.open-cluster-management.io

1.7.2.3. Query a single policy

GET /policy.open-cluster-management.io/v1/v1alpha1/namespaces/{namespace}/policies/{policy_name}
Copy to Clipboard Toggle word wrap
1.7.2.3.1. Description

Query a single policy for more details.

1.7.2.3.2. Parameters
Expand
TypeNameDescriptionSchema

Header

COOKIE
required

Authorization: Bearer {ACCESS_TOKEN} ; ACCESS_TOKEN is the user access token.

string

Path

policy_name
required

Name of the policy that you want to query.

string

Path

namespace
required

Namespace that you want to use, for example, default.

string

1.7.2.3.3. Responses
Expand
HTTP CodeDescriptionSchema

200

Success

No Content

403

Access forbidden

No Content

404

Resource not found

No Content

500

Internal service error

No Content

503

Service unavailable

No Content

1.7.2.3.4. Tags
  • policy.open-cluster-management.io

1.7.2.4. Delete a policy

DELETE /policy.open-cluster-management.io/v1/v1alpha1/namespaces/{namespace}/policies/{policy_name}
Copy to Clipboard Toggle word wrap
1.7.2.4.1. Parameters
Expand
TypeNameDescriptionSchema

Header

COOKIE
required

Authorization: Bearer {ACCESS_TOKEN} ; ACCESS_TOKEN is the user access token.

string

Path

policy_name
required

Name of the policy that you want to delete.

string

Path

namespace
required

Namespace that you want to use, for example, default.

string

1.7.2.4.2. Responses
Expand
HTTP CodeDescriptionSchema

200

Success

No Content

403

Access forbidden

No Content

404

Resource not found

No Content

500

Internal service error

No Content

503

Service unavailable

No Content

1.7.2.4.3. Tags
  • policy.open-cluster-management.io

1.7.3. Definitions

1.7.3.1. Policy

Expand
NameDescriptionSchema

apiVersion
required

The versioned schema of Policy.

string

kind
required

String value that represents the REST resource.

string

metadata
required

Describes rules that define the policy.

object

spec

Expand
NameDescriptionSchema

remediationAction
optional

Value that represents how violations are handled as defined in the resource.

string

namespace
required

Value that represents which namespaces the policy is applied.

string

policy-templates

Expand
NameDescriptionSchema

apiVersion
required

The versioned schema of Policy.

string

kind
optional

String value that represents the REST resource.

string

complianceType
required

The compliance standard.

string

metadata
required

Describes rules that define the policy.

object

clusterConditions
optional

Section to define labels.

string

rules
optional

 

string

selector

Expand
NameDescriptionSchema

matchLabels
optional

The label that is required for the policy to be applied to a namespace.

object

cloud
optional

The label that is required for the policy to be applied to a cloud provider.

string

rules

Expand
NameDescriptionSchema

apiGroups
required

List of APIs that the rule applies to.

string

resources
required

A list of resource types.

object

verbs
required

A list of verbs.

string

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat