• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference 2.0
  4. Kubernetes API
  5. ReplicationController
  6. Creating a ReplicationController

Creating a ReplicationController

Function

This API is used to create a ReplicationController object.

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:

{
    "apiVersion": "v1",
    "kind": "ReplicationController",
    "metadata": {
        "labels": {
            "name": "rc-test"
        },
        "name": "rc-test",
        "namespace": "default"
    },
    "spec": {
        "replicas": 1,
        "selector": {
            "name": "rc-test"
        },
        "template": {
            "metadata": {
                "labels": {
                    "name": "rc-test"
                }
            },
            "spec": {
                "containers": [
                    {
                        "image": "172.16.5.235:20202/test/nginx",
                        "name": "pod-test"
                    }
                ],
                "dnsPolicy": "ClusterFirst",
                "imagePullSecrets": [
                    {
                        "name": "default-secret"
                    }
                ],
                "restartPolicy": "Always"
            }
        }
    }
}

Response

Response parameters:

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

Example response:

{
    "kind": "ReplicationController",
    "apiVersion": "v1",
    "metadata": {
        "name": "rc-test",
        "namespace": "default",
        "selfLink": "/api/v1/namespaces/default/replicationcontrollers/rc-test",
        "uid": "4aabff80-fc1d-11e7-9c3c-fa163eb8ad1a",
        "resourceVersion": "484580",
        "generation": 1,
        "creationTimestamp": "2018-01-18T07:00:39Z",
        "labels": {
            "name": "rc-test"
        },
        "enable": true
    },
    "spec": {
        "replicas": 1,
        "selector": {
            "name": "rc-test"
        },
        "template": {
            "metadata": {
                "creationTimestamp": null,
                "labels": {
                    "name": "rc-test"
                },
                "enable": true
            },
            "spec": {
                "containers": [
                    {
                        "name": "pod-test",
                        "image": "172.16.5.235:20202/test/nginx",
                        "resources": {},
                        "terminationMessagePath": "/dev/termination-log",
                        "terminationMessagePolicy": "File",
                        "imagePullPolicy": "Always"
                    }
                ],
                "restartPolicy": "Always",
                "terminationGracePeriodSeconds": 30,
                "dnsPolicy": "ClusterFirst",
                "securityContext": {},
                "imagePullSecrets": [
                    {
                        "name": "default-secret"
                    }
                ],
                "schedulerName": "default-scheduler"
            }
        }
    },
    "status": {
        "replicas": 0
    }
}

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.