Updated on 2025-12-01 GMT+08:00

Creating a Federated Workload

Function

This API is used to create a federated workload.

URI

POST /v1/clustergroups/{clustergroupid}/unitedworkload

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

clustergroupid

Yes

String

Fleet ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

Identity authentication information. Requests for calling an API can be authenticated using either a token or AK/SK. If token-based authentication is used, this parameter is mandatory and must be set to a user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

kind

No

String

Resource type. Options:

  • Deployment: manages stateless applications.

  • Service: implements service discovery and load balancing.

  • Ingress: manages external HTTP/HTTPS access to services in a cluster.

  • ConfigMap: stores non-sensitive configuration data.

  • Secret: stores sensitive information.

  • Job: runs one-off tasks.

  • StatefulSet: manages stateful applications.

  • DaemonSet: runs a pod on each node.

  • PersistentVolumeClaim: requests and uses persistent storage resources.

apiVersion

No

String

API version

metadata

No

ObjectMeta object

Workload metadata

template

No

Object

Application template to be deployed

propagationPolicy

No

PropagationPolicy object

Policy for propagating resources across clusters

overridePolicy

No

OverridePolicy object

Resource override policy

resourceBinding

No

ResourceBinding object

Binding between resources and propagation policies

Table 4 PropagationPolicy

Parameter

Mandatory

Type

Description

kind

No

String

API type. The value is fixed at PropagationPolicy.

apiVersion

No

String

API version

metadata

No

ObjectMeta object

Basic information

spec

No

PropagationSpec object

Propagation policy description

Table 5 PropagationSpec

Parameter

Mandatory

Type

Description

resourceSelectors

No

Array of ResourceSelector objects

Resource selector, which is used to select resources to be propagated.

propagateDeps

No

Boolean

Whether to automatically propagate the referent.

placement

No

Placement object

Rule for defining the clusters that resources are propagated to

priority

No

Integer

Policy priority. The default value is 0.

schedulerName

No

String

Scheduler name. The default value is default-scheduler.

Table 6 OverridePolicy

Parameter

Mandatory

Type

Description

kind

No

String

API type. The value is fixed at OverridePolicy.

apiVersion

No

String

API version

spec

No

OverrideSpec object

Override policy description

Table 7 OverrideSpec

Parameter

Mandatory

Type

Description

resourceSelectors

No

Array of ResourceSelector objects

Resource selector, which restricts the resource types that the override policy is applied to

overriders

No

Object

Override rule that will be applied to resources

Table 8 ResourceSelector

Parameter

Mandatory

Type

Description

apiVersion

No

String

API version of the target resource

kind

No

String

Type of the target resource

namespace

No

String

Name of the target resource

name

No

String

Namespace of the target resource

Table 9 ResourceBinding

Parameter

Mandatory

Type

Description

kind

No

String

API type. The value is fixed at ResourceBinding.

apiVersion

No

String

API version

metadata

No

ObjectMeta object

Resource metadata

spec

No

ResourceBindingSpec object

Desired resource binding behavior

status

No

ResourceBindingStatus object

Current status of the resource binding

Table 10 ObjectMeta

Parameter

Mandatory

Type

Description

uid

No

String

Resource ID

name

No

String

Resource name

generateName

No

String

If no name is provided, the server uses the prefix to generate a unique name.

namespace

No

String

Namespace

labels

No

Map<String,String>

Label

annotations

No

Map<String,String>

Annotation

creationTimestamp

No

String

Creation time

updateTimestamp

No

String

Update time

resourceVersion

No

String

Internal version of a resource

generation

No

String

Generation of the desired resource state

managedFields

No

Array of ManagedFieldsEntry objects

Fields managed by workflows

ownerReferences

No

Array of OwnerReference objects

Ownership, dependencies, and garbage collection mechanism of objects. It supports resource management by the controller.

Table 11 ManagedFieldsEntry

Parameter

Mandatory

Type

Description

manager

No

String

Manager name

operation

No

String

Operation type that causes this entry being created. The value can only be Apply or Update.

apiVersion

No

String

Resource API version used by a manager for defining fields

time

No

String

Timestamp when this entry was created or last updated

fieldsType

No

String

Field structure format. The value is fixed at "FieldsV1".

fieldsV1

No

Object

Information about the managed fields

Table 12 OwnerReference

Parameter

Mandatory

Type

Description

apiVersion

No

String

API version of the referent

kind

No

String

Type of the referent

name

No

String

Name of the referent

uid

No

String

UID of the referent

controller

No

Boolean

If the value is true, this reference points to the controller that manages the resource.

blockOwnerDeletion

No

Boolean

If the value is true and the owner has a finalizer named foregroundDeletion, the owner cannot be deleted until this reference is removed.

Table 13 ResourceBindingSpec

Parameter

Mandatory

Type

Description

resource

No

Object

Kubernetes resource reference to be propagated

propagateDeps

No

Boolean

Whether to automatically propagate related resources

replicaRequirements

No

Object

Requirements for each replica

replicas

No

Integer

The number of replicas to be created

placement

No

Placement object

Cluster selection rule

clusters

No

Array of TargetCluster objects

Target member cluster list

Table 14 Placement

Parameter

Mandatory

Type

Description

clusterAffinity

No

ClusterAffinity object

Cluster affinity rule

clusterTolerations

No

Array of Toleration objects

Cluster tolerance rule

replicaScheduling

No

Object

The way how to allocate replicas across member clusters

Table 15 ClusterAffinity

Parameter

Mandatory

Type

Description

clusterNames

No

Array of strings

List of cluster names to be selected

exclude

No

Array of strings

List of cluster names to be excluded

Table 16 Toleration

Parameter

Mandatory

Type

Description

key

No

String

Key name of the taint to be tolerated

operator

No

String

Relationship between the key and value. The value can be Exists or Equal. The default value is Equal.

value

No

String

Taint value to be matched. When Operator is set to Exists, Value must be empty.

effect

No

String

Taint effect to be matched. The value can be NoSchedule, PreferNoSchedule, or NoExecute. If the value is empty, all effects are matched.

tolerationSeconds

No

Integer

Duration during which a pod can tolerate a taint. This parameter is valid only for NoExecute.

Table 17 TargetCluster

Parameter

Mandatory

Type

Description

name

No

String

Name of the target cluster

replicas

No

String

The number of replicas created in a cluster

Table 18 ResourceBindingStatus

Parameter

Mandatory

Type

Description

schedulerObservedGeneration

No

Integer

Generation of the resource observed by the scheduler

conditions

No

Array of ConditionStatus objects

Resource status conditions

Table 19 ConditionStatus

Parameter

Mandatory

Type

Description

type

No

String

Status type

status

No

String

Status

observedgeneration

No

Integer

Version of a status object

lastTransitionTime

No

String

Last status update time

reason

No

String

Cause of status

message

No

String

Status information

Response Parameters

Status code: 200

Federated workload created

None

Example Requests

Creating a federated workload

POST https://ucs.myhuaweicloud.com/v1/clustergroups/{clustergroupid}/unitedworkload

{
  "kind" : "Deployment",
  "metadata" : {
    "name" : "test",
    "namespace" : "default"
  },
  "template" : {
    "apiVersion" : "apps/v1",
    "kind" : "Deployment",
    "metadata" : {
      "labels" : {
        "version" : "v1"
      },
      "name" : "test",
      "namespace" : "default"
    },
    "spec" : {
      "selector" : {
        "matchLabels" : {
          "app" : "test",
          "version" : "v1"
        }
      },
      "template" : {
        "metadata" : {
          "labels" : {
            "app" : "test",
            "version" : "v1"
          }
        },
        "spec" : {
          "containers" : [ {
            "name" : "nginx",
            "image" : "xxxxxx",
            "imagePullPolicy" : "IfNotPresent"
          } ],
          "terminationGracePeriodSeconds" : 30,
          "tolerations" : [ {
            "key" : "node.kubernetes.io/not-ready",
            "operator" : "Exists",
            "effect" : "NoExecute",
            "tolerationSeconds" : 300
          }, {
            "key" : "node.kubernetes.io/unreachable",
            "operator" : "Exists",
            "effect" : "NoExecute",
            "tolerationSeconds" : 300
          } ],
          "volumes" : [ ],
          "initContainers" : [ ]
        }
      },
      "serviceName" : "headless-kd3s6e",
      "replicas" : 2,
      "revisionHistoryLimit" : 10,
      "progressDeadlineSeconds" : 600
    }
  },
  "propagationPolicy" : {
    "spec" : {
      "placement" : {
        "clusterAffinity" : {
          "clusterNames" : [ ]
        },
        "replicaScheduling" : {
          "replicaSchedulingType" : "Divided",
          "replicaDivisionPreference" : "Weighted",
          "weightPreference" : {
            "dynamicWeight" : "AvailableReplicas"
          }
        }
      },
      "propagateDeps" : true
    }
  },
  "overridePolicy" : { }
}

Example Responses

None

Status Codes

Status Code

Description

200

Federated workload created

400

Client request error. The server could not execute the request.

403

The server refused the request.

404

Resources not found

500

Internal server error

Error Codes

See Error Codes.