Help Center > > API Reference> APIs> ReplicationController> Creating a ReplicationController

Creating a ReplicationController

Updated at: May 07, 2019 GMT+08:00

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 Code.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel