• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. ReplicationController (Native Kubernetes APIs)
  5. Creating a ReplicationController

Creating a ReplicationController

Function

This API is used to create a ReplicationController object.

  • A label should be attached to the ReplicationController object so the object can be displayed on the App Manager page of CCE console.

    Set the value of the metadata.labels key in the request message body as follows:

    labels:
        cce/appgroup: appname
        name: rcname
    • appname is the containerized application name displayed on the App Manager and can take any value.
    • name is the ReplicationController name and can take any value.
      NOTE:

      On the App Manager page, ReplicartionControllers are listed in alphabetical order of the initial letters of the container cluster names. If the initial letters of several cluster names are the same, the ReplicartionControllers are listed in alphabetical order of the initial letters of the Namespace names. If the initial letters of several Namespace names are the same, the ReplicartionControllers are listed in alphabetical order of the initial letters of the containerized application names.

  • Information similar to the following should be added to the value of metadata.annotations when the ReplicationController is being created, so the ReplicationController creation and update time can be displayed on the App Manager.
    "cce/app-createTimestamp": "2016-09-12-03-22-35",
    "cce/app-description": "",
    "cce/app-updateTimestamp": "2016-09-12-03-22-36"

    The creation and update time added should be converted to UTC+0 time in the format of YYYY-MM-DD-HH-MI-SS and be earlier than the current time, for example, 2016-09-12-03-22-36, indicating 03:22:36 on September 12, 2016.

URI

POST /api/v1/namespaces/{namespace}/replicationcontrollers

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

pretty

No

If 'true', then the output is pretty printed.

namespace

Yes

Object name and auth scope, such as for teams and projects.

Request

Request parameters:

For the description about request parameters, see Table 1.

Example request:

{
    "kind": "ReplicationController",
    "apiVersion": "v1",
    "metadata": {
        "name": "frontend-controller",
        "labels": {
            "cce/group": "frontend-controller",
            "name": "frontend"
        }
    },
    "spec": {
        "replicas": 2,
        "selector": {
            "cce/group": "frontend-controller",
            "name": "frontend"
        },
        "template": {
            "metadata": {
                "labels": {
                    "cce/group": "frontend-controller",
                    "name": "frontend"
                }
            },
            "spec": {
                "volumes": null,
                "containers": [
                    {
                        "name": "php-redis",
                        "image": "redis",
                        "ports": [
                            {
                                "containerPort": 80,
                                "protocol": "TCP"
                            }
                        ],
                        "imagePullPolicy": "IfNotPresent"
                    }
                ],
                "restartPolicy": "Always",
                "dnsPolicy": "ClusterFirst"
            }
        }
    }
}

Response

Response parameters:

For the description about response parameters, see the parameter description in Request.

Example response:

{
    "apiVersion": "v1",
    "kind": "ReplicationController",
    "metadata": {
        "creationTimestamp": "2017-06-23T08:40:52Z",
        "generation": 1,
        "labels": {
            "cce/group": "frontend-controller",
            "name": "frontend"
        },
        "name": "frontend-controller",
        "namespace": "default",
        "resourceVersion": "850929",
        "selfLink": "/api/v1/namespaces/default/replicationcontrollers/frontend-controller",
        "uid": "aa123f3f-57ef-11e7-97f8-fa163e61f3f9"
    },
    "spec": {
        "replicas": 2,
        "selector": {
            "cce/group": "frontend-controller",
            "name": "frontend"
        },
        "template": {
            "metadata": {
                "creationTimestamp": null,
                "labels": {
                    "cce/group": "frontend-controller",
                    "name": "frontend"
                }
            },
            "spec": {
                "containers": [
                    {
                        "image": "redis",
                        "imagePullPolicy": "IfNotPresent",
                        "name": "php-redis",
                        "ports": [
                            {
                                "containerPort": 80,
                                "protocol": "TCP"
                            }
                        ],
                        "resources": {},
                        "terminationMessagePath": "/dev/termination-log"
                    }
                ],
                "dnsPolicy": "ClusterFirst",
                "restartPolicy": "Always",
                "securityContext": {},
                "terminationGracePeriodSeconds": 30
            }
        }
    },
    "status": {
        "availableReplicas": 2,
        "fullyLabeledReplicas": 2,
        "observedGeneration": 1,
        "readyReplicas": 2,
        "replicas": 2
    }
}

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

201

This operation succeeds, and a ReplicationController resource object is returned.

For the description about status codes, see section Status Codes.