kubernetes api 서버에 요청하는 예시이다.
$ APISERVER=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')
$ TOKEN=$(kubectl get secret $(kubectl get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode )
$ curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
{
"kind": "APIVersions",
"versions": [
"v1"
],
"serverAddressByClientCIDRs": [
{
"clientCIDR": "0.0.0.0/0",
"serverAddress": "10.194.26.99:6443"
}
]
}
$ curl $APISERVER/version --header "Authorization: Bearer $TOKEN" --insecure
{
"major": "1",
"minor": "11",
"gitVersion": "v1.11.5",
"gitCommit": "753b2dbc622f5cc417845f0ff8a77f539a4213ea",
"gitTreeState": "xx",
"buildDate": "xxxx",
"goVersion": "go1xxxx",
"compiler": "gc",
"platform": "linux/amd64"
}
이제 swaggerapi를 호출한다. 어떤 api가 나오는지 보여준다. 다양한 api를 호출할 수 있다.
$ curl $APISERVER/swaggerapi --header "Authorization: Bearer $TOKEN" --insecure
{
"swaggerVersion": "1.2",
"apis": [
{
"path": "/version",
"description": "git code version from which this is built"
},
{
"path": "/apis",
"description": "get available API versions"
},
{
"path": "/logs",
"description": "get log files"
},
{
"path": "/api/v1",
"description": "API at /api/v1"
},
{
"path": "/api",
"description": "get available API versions"
},
{
"path": "/apis/authentication.k8s.io/v1",
"description": "API at /apis/authentication.k8s.io/v1"
},
{
"path": "/apis/authentication.k8s.io/v1beta1",
"description": "API at /apis/authentication.k8s.io/v1beta1"
},
{
"path": "/apis/authentication.k8s.io",
"description": "get information of a group"
},
{
"path": "/apis/authorization.k8s.io/v1",
"description": "API at /apis/authorization.k8s.io/v1"
},
{
"path": "/apis/authorization.k8s.io/v1beta1",
"description": "API at /apis/authorization.k8s.io/v1beta1"
},
{
"path": "/apis/authorization.k8s.io",
"description": "get information of a group"
},
{
"path": "/apis/autoscaling/v1",
"description": "API at /apis/autoscaling/v1"
},
{
"path": "/apis/autoscaling/v2beta1",
"description": "API at /apis/autoscaling/v2beta1"
},
{
"path": "/apis/autoscaling",
"description": "get information of a group"
},
{
"path": "/apis/batch/v1",
"description": "API at /apis/batch/v1"
},
{
"path": "/apis/batch/v1beta1",
"description": "API at /apis/batch/v1beta1"
},
{
"path": "/apis/batch",
"description": "get information of a group"
},
{
"path": "/apis/certificates.k8s.io/v1beta1",
"description": "API at /apis/certificates.k8s.io/v1beta1"
},
{
"path": "/apis/certificates.k8s.io",
"description": "get information of a group"
},
{
"path": "/apis/extensions/v1beta1",
"description": "API at /apis/extensions/v1beta1"
},
{
"path": "/apis/extensions",
"description": "get information of a group"
},
{
"path": "/apis/networking.k8s.io/v1",
"description": "API at /apis/networking.k8s.io/v1"
},
{
"path": "/apis/networking.k8s.io",
"description": "get information of a group"
},
{
"path": "/apis/policy/v1beta1",
"description": "API at /apis/policy/v1beta1"
},
{
"path": "/apis/policy",
"description": "get information of a group"
},
{
"path": "/apis/rbac.authorization.k8s.io/v1",
"description": "API at /apis/rbac.authorization.k8s.io/v1"
},
{
"path": "/apis/rbac.authorization.k8s.io/v1beta1",
"description": "API at /apis/rbac.authorization.k8s.io/v1beta1"
},
{
"path": "/apis/rbac.authorization.k8s.io",
"description": "get information of a group"
},
{
"path": "/apis/scheduling.k8s.io/v1beta1",
"description": "API at /apis/scheduling.k8s.io/v1beta1"
},
{
"path": "/apis/scheduling.k8s.io",
"description": "get information of a group"
},
{
"path": "/apis/storage.k8s.io/v1",
"description": "API at /apis/storage.k8s.io/v1"
},
{
"path": "/apis/storage.k8s.io/v1beta1",
"description": "API at /apis/storage.k8s.io/v1beta1"
},
{
"path": "/apis/storage.k8s.io",
"description": "get information of a group"
},
{
"path": "/apis/apps/v1",
"description": "API at /apis/apps/v1"
},
{
"path": "/apis/apps/v1beta2",
"description": "API at /apis/apps/v1beta2"
},
{
"path": "/apis/apps/v1beta1",
"description": "API at /apis/apps/v1beta1"
},
{
"path": "/apis/apps",
"description": "get information of a group"
},
{
"path": "/apis/admissionregistration.k8s.io/v1beta1",
"description": "API at /apis/admissionregistration.k8s.io/v1beta1"
},
{
"path": "/apis/admissionregistration.k8s.io/v1alpha1",
"description": "API at /apis/admissionregistration.k8s.io/v1alpha1"
},
{
"path": "/apis/admissionregistration.k8s.io",
"description": "get information of a group"
},
{
"path": "/apis/events.k8s.io/v1beta1",
"description": "API at /apis/events.k8s.io/v1beta1"
},
{
"path": "/apis/events.k8s.io",
"description": "get information of a group"
}
],
"apiVersion": "",
"info": {
"title": "",
"description": ""
}
}