Kubenetes RESTful API

Source: Internet
Author: User
Tags server port k8s

Description
Official API:
http://kubernetes.io/kubernetes/third_party/swagger-ui/#/

Attention:
K8s API is strictly in accordance with the restful style, that is, the same
/api/v1/namespaces/{namespace}/pods
If it's a post, it creates the pod, and if it's delete, it deletes the pod.

This article extracts some of the APIs we need for daily use to provide the agent with A. Pod operation 1. Create a pod

POST  /api/v1/namespaces/{namespace}/pods  //Here our namespaces is default

Type: Application/json
Parameters: Reference official 2. Delete a pod

DELETE  /api/v1/namespaces/{namespace}/pods
3. View pod list
Get  /api/v1/namespaces/{namespace}/pods
4. View the pod with the specified name
Get  /api/v1/namespaces/{namespace}/pods/{name}
two. RC Operation: Replicationcontroller 1. Create an RC
POST  
2. Delete an RC
Delete/api/v1/namespaces/{namespace}/replicationcontrollers/{name}
3. Get RC list
Get/api/v1/namespaces/{namespace}/replicationcontrollers
4. Get the RC with the specified name
Get/api/v1/namespaces/{namespace}/replicationcontrollers/{name}
5. Replace the specified RC
Put/api/v1/namespaces/{namespace}/replicationcontrollers/{name}
three. Service Operation 1. Create a new service
Post/api/v1/namespaces/{namespace}/services
2. Delete a specified service
Delete/api/v1/namespaces/{namespace}/services/{name}
3. Obtain information for a specified service
Get/api/v1/namespaces/{namespace}/services/{name}
4. Display all service lists and information
Get/api/v1/namespaces/{namespace}/services
Four. Node operations (nodes/minion) 1. Create a new node
Post/api/v1/nodes
2. Get the node list for all k8s
Get/api/v1/nodes
3. Delete the specified node
Delete/api/v1/nodes/{name}
4. Get the specified node information
Get/api/v1/nodes/{name}

It is not difficult to find that once the unified style, the RESTful API appears very clear, the path is consistent, only need to change the request method. Five. Practice: Delete a pod via HTTP request

Execute a request specifically, such as deploying the entire k8s environment on 10.1.1.1, and configuring the API server port to 8080.
At this time the machine ran a pod:test-pod.
Let's test the removal of POD by HTTP request instead of KUBECTL delete pod name.

Request Path:

10.1.1.1:8080/api/v1/namespaces/default/pods

Request Method:

HTTP Delete

The test code is as follows:

Cond. Direct HTTP GET display pods information

Http://10.1.1.1:8080/api/v1/namespaces/default/pods

It does list all the information about the pod. Validated the RESTful API

Other information:
Kubernetes authoritative Guide to the Kubernetes API detailed
Http://www.infoq.com/cn/articles/Kubernetes-API?amp&amp&amp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.