Sunday, June 16, 2019

Kubernetes APIs to get Details about PODS, Nodes, eviction of POD, deletion of POD

Get the list of  Kubernetes APIs
http://127.0.0.1:8080

http://127.0.0.1:8080/api/v1/

Kubernetes API to get List of Nodes:
http://127.0.0.1:8080/api/v1/nodes

Kubernetes API to get details of the Node:
http://127.0.0.1:8080/api/v1/nodes/minikube

Kubernetes API to get the List of PODs:
http://127.0.0.1:8080/api/v1/pods

Kubernetes API to get particular POD detail:
"myapp1-59677d87cb-k22bx" is name of POD
http://127.0.0.1:8080/api/v1/namespaces/default/pods/myapp1-59677d87cb-k22bx

Kubernetes API for Eviction of POD:
"myapp1-59677d87cb-k22bx" is name of POD
POST: http://127.0.0.1:8080/api/v1/namespaces/default/pods/myapp1-59677d87cb-k22bx/eviction
JSON TO SEND:
{
  "apiVersion": "policy/v1beta1",
  "kind": "Eviction",
  "metadata": {
    "name": "myapp1-59677d87cb-k22bx",
    "namespace": "default"
  }
}

Kubernetes API for deletion of POD:
"myapp1-59677d87cb-6bcxv" is name of pod
DELETE: http://127.0.0.1:8080/api/v1/namespaces/default/pods/myapp1-59677d87cb-6bcxv

Kubernetes API to get list of Services:
http://127.0.0.1:8080/api/v1/services

Kubernetes API to get the detail about particular Service:
"myapp1" is the service name
http://127.0.0.1:8080/api/v1/namespaces/default/services/myapp1

Kubernetes API to get list of Deployments:
http://127.0.0.1:8080/apis/apps/v1/namespaces/default/deployments

Kubernetes API to Get Patricular Deployment:
http://127.0.0.1:8080/apis/extensions/v1beta1/namespaces/default/deployments/myapp1/scale
Note: Copy the received JSON and use in in the put call to scale the deployment

Kubernetes API for Scaling of Deployments:
"myapp1" is the name of deployment.
PUT: http://127.0.0.1:8080/apis/extensions/v1beta1/namespaces/default/deployments/myapp1/scale

JSON TO PASS:
{
    "kind": "Scale",
    "apiVersion": "extensions/v1beta1",
    "metadata": {
        "name": "myapp1",
        "namespace": "default",
        "selfLink": "/apis/extensions/v1beta1/namespaces/default/deployments/myapp1/scale",
        "uid": "f3e43146-88ec-11e9-b34a-080027912a01",
        "resourceVersion": "16289",
        "creationTimestamp": "2019-06-07T06:24:49Z"
    },
    "spec": {
        "replicas": 4
    },
    "status": {
        "replicas": 4,
        "selector": {
            "run": "myapp1"
        },
        "targetSelector": "run=myapp1"
    }
}

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...