Kubernetest REST API

Kubernetest REST API

Kubernetest REST API

Kubernetest REST API

启动proxy

➜  _posts kubectl proxy --port=8080
Starting to serve on 127.0.0.1:8080

查看APIserver

➜ http 127.0.0.1:8080
HTTP/1.1 200 OK
Content-Length: 2644
Content-Type: application/json
Date: Tue, 15 Jan 2019 05:19:42 GMT

{
    "paths": [
        "/api",
        "/api/v1",
        "/apis",
        "/apis/",
        "/apis/admissionregistration.k8s.io",
        "/apis/admissionregistration.k8s.io/v1beta1",
        "/apis/apiextensions.k8s.io",
        "/apis/apiextensions.k8s.io/v1beta1",
        "/apis/apiregistration.k8s.io",
        "/apis/apiregistration.k8s.io/v1",
        "/apis/apiregistration.k8s.io/v1beta1",
        "/apis/apps",
        "/apis/apps/v1",
        "/apis/apps/v1beta1",
        "/apis/apps/v1beta2",
        "/apis/authentication.k8s.io",
        "/apis/authentication.k8s.io/v1",
        "/apis/authentication.k8s.io/v1beta1",
        "/apis/authorization.k8s.io",
        "/apis/authorization.k8s.io/v1",
        "/apis/authorization.k8s.io/v1beta1",
        "/apis/autoscaling",
        "/apis/autoscaling/v1",
        "/apis/autoscaling/v2beta1",
        "/apis/batch",
        "/apis/batch/v1",
        "/apis/batch/v1beta1",
        "/apis/ceph.rook.io",
        "/apis/ceph.rook.io/v1",
        "/apis/certificates.k8s.io",
        "/apis/certificates.k8s.io/v1beta1",
        "/apis/compose.docker.com",
        "/apis/compose.docker.com/v1beta1",
        "/apis/compose.docker.com/v1beta2",
        "/apis/events.k8s.io",
        "/apis/events.k8s.io/v1beta1",
        "/apis/extensions",
        "/apis/extensions/v1beta1",
        "/apis/networking.k8s.io",
        "/apis/networking.k8s.io/v1",
        "/apis/policy",
        "/apis/policy/v1beta1",
        "/apis/rbac.authorization.k8s.io",
        "/apis/rbac.authorization.k8s.io/v1",
        "/apis/rbac.authorization.k8s.io/v1beta1",
        "/apis/rook.io",
        "/apis/rook.io/v1alpha2",
        "/apis/samplecrd.k8s.io",
        "/apis/samplecrd.k8s.io/v1",
        "/apis/storage.k8s.io",
        "/apis/storage.k8s.io/v1",
        "/apis/storage.k8s.io/v1beta1",
        "/healthz",
        "/healthz/autoregister-completion",
        "/healthz/etcd",
        "/healthz/ping",
        "/healthz/poststarthook/apiservice-openapi-controller",
        "/healthz/poststarthook/apiservice-registration-controller",
        "/healthz/poststarthook/apiservice-status-available-controller",
        "/healthz/poststarthook/bootstrap-controller",
        "/healthz/poststarthook/ca-registration",
        "/healthz/poststarthook/generic-apiserver-start-informers",
        "/healthz/poststarthook/kube-apiserver-autoregistration",
        "/healthz/poststarthook/rbac/bootstrap-roles",
        "/healthz/poststarthook/start-apiextensions-controllers",
        "/healthz/poststarthook/start-apiextensions-informers",
        "/healthz/poststarthook/start-kube-aggregator-informers",
        "/healthz/poststarthook/start-kube-apiserver-informers",
        "/logs",
        "/metrics",
        "/openapi/v2",
        "/swagger-2.0.0.json",
        "/swagger-2.0.0.pb-v1",
        "/swagger-2.0.0.pb-v1.gz",
        "/swagger.json",
        "/swaggerapi",
        "/version"
    ]
}

➜  

测试

➜   http 127.0.0.1:8080/apis/networking.k8s.io
HTTP/1.1 200 OK
Content-Length: 241
Content-Type: application/json
Date: Tue, 15 Jan 2019 05:18:09 GMT

{
    "apiVersion": "v1",
    "kind": "APIGroup",
    "name": "networking.k8s.io",
    "preferredVersion": {
        "groupVersion": "networking.k8s.io/v1",
        "version": "v1"
    },
    "serverAddressByClientCIDRs": null,
    "versions": [
        {
            "groupVersion": "networking.k8s.io/v1",
            "version": "v1"
        }
    ]
}

➜  
➜  http 127.0.0.1:8080/api/v1/namespaces/kube-system
HTTP/1.1 200 OK
Content-Length: 293
Content-Type: application/json
Date: Tue, 15 Jan 2019 05:23:03 GMT

{
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
        "creationTimestamp": "2018-11-28T03:12:07Z",
        "name": "kube-system",
        "resourceVersion": "12",
        "selfLink": "/api/v1/namespaces/kube-system",
        "uid": "6358a5aa-f2bb-11e8-92bc-025000000001"
    },
    "spec": {
        "finalizers": [
            "kubernetes"
        ]
    },
    "status": {
        "phase": "Active"
    }
}

➜  

See also