kubernetes@in-cluster : in-cluster name kubernetes-admin@kubernetes : kubeconfig default context name
URL Pattern | Method | 설명 |
---|---|---|
/api/clusters | GET | k8s cluster context 리스트 조회 |
/api/clusters/:cluster/topology | GET | 토플로지 그래프 조회 |
/api/clusters/:cluster/dashboard | GET | Dashboard 데이터 조회 |
$ curl -X GET http://localhost:3001/api/contexts
$ curl -X GET http://localhost:3001/api/clusters/kubernetes@in-cluster/graph/topology
$ curl -X GET http://localhost:3001/api/clusters/kubernetes@in-cluster/dashboard
멀티 클러스터를 지원하는 Kubernetes API Proxy API
kubectl api-resources -o wide
으로 resource와 apiGroup 조회 가능$ kubectl api-resources -o wide
# CRD 경우
$ kubectl get crd
$ kubectl get crd virtualservices.networking.istio.io -o jsonpath="{.spec.group}"
/raw
와 kubernetes-api URL로 구성metadata.selfLink
참조 가능/raw/<Kubernetes-api URL>
:cluster
: Kubeconfig context name:version
: Resource spec. version:resource
: Resource name:apiGroups
: Resource groupsCreate a resource
URL Pattern | Method | 설명 |
---|---|---|
/raw/clusters/:cluster | POST | Applay |
$ curl -X POST -H "Content-Type: application/json" http://localhost:3001/raw/clusters/kubernetes@in-cluster -d @- <<EOF
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"name": "test-namespace"
}
}
EOF
Update a resource
URL Pattern | Method | 설명 | 비고 |
---|---|---|---|
/raw/clusters/:cluster | PATCH | Update |
Content-Type
으로 patch 방식 선택 (
Content-Type : application/merge-patch+json
Content-Type : application/json-patch+json
Content-Type : application/strategic-merge-patch+json
$ curl -X PATCH -H "Content-Type: application/merge-patch+json" http://localhost:3001/raw/clusters/kubernetes@in-cluster/api/v1/namespaces/default/pods/busybox -d @- <<EOF
{
"metadata": {
"labels": {
"app": "busybox-merge"
}
}
}
EOF
$ kubectl get po busybox -n default -o jsonpath="{.metadata.labels}"
$ curl -X PATCH -H "Content-Type: application/json-patch+json" http://localhost:3001/raw/clusters/kubernetes@in-cluster/api/v1/namespaces/default/pods/busybox -d @- <<EOF
[
{
"op": "replace",
"path": "/metadata/labels/app",
"value":"busybox-json"
}
]
EOF
$ kubectl get po busybox -n default -o jsonpath="{.metadata.labels}"
No. | Core | Namespaced | Resources |
---|---|---|---|
1 | O | O | Pod, Service, PersistentVolumeClaim, … |
2 | O | X | Namespace, PersistentVolume, … |
3 | X | O | Deployment, DaemonSet, PodMetrics, Role, RoleBinding, … |
4 | X | X | NodeMetrics, ClusterRole, ClusterRoleBinding, … |
URL | Method | 설명 |
---|---|---|
/raw/clusters/:cluster/api/:version/:resource | GET | non-namespaced 리소스 목록 조회 |
/raw/clusters/:cluster/api/:version/:resource:/:name | GET | non-namespaced 리소스 조회 |
/raw/clusters/:cluster/api/:version/:resource:/:name | DELETE | non-namespaced 리소스 삭제 |
/raw/clusters/:cluster/api/:version/:resource:/:name | PATCH | non-namespaced 리소스 수정 |
/raw/clusters/:cluster/api/:version/namespaces/:resource: | GET | namespaced 리소스 목록조회 |
/raw/clusters/:cluster/api/:version/namespaces/:namespace/:resource/:name | GET | namespaced 리소스 조회 |
/raw/clusters/:cluster/api/:version/namespaces/:namespace/:resource/:name | DELETE | N\namespaced 리소스 삭제 |
/raw/clusters/:cluster/api/:version/namespaces/:namespace/:resource/:name | PATCH | N\namespaced 리소스 수정 |
URL | Method | 설명 |
---|---|---|
/raw/clusters/:cluster/apis/:apiGroup/:version/:resource | GET | non-namespaced 리소스 목록 조회 |
/raw/clusters/:cluster/apis/:apiGroup/:version/:resource:/:name | GET | non-namespaced 리소스 조회 |
/raw/clusters/:cluster/apis/:apiGroup/:version/:resource:/:name | DELETE | non-namespaced 리소스 삭제 |
/raw/clusters/:cluster/apis/:apiGroup/:version/:resource:/:name | PATCH | non-namespaced 리소스 수정 |
/raw/clusters/:cluster/apis/:apiGroup/:version/namespaces/:resource: | GET | namespaced 리소스 목록조회 |
/raw/clusters/:cluster/apis/:apiGroup/:version/namespaces/:namespace/:resource/:name | GET | namespaced 리소스 조회 |
/raw/clusters/:cluster/apis/:apiGroup/:version/namespaces/:namespace/:resource/:name | DELETE | namespaced 리소스 삭제 |
/raw/clusters/:cluster/apis/:apiGroup/:version/namespaces/:namespace/:resource/:name | PATCH | namespaced 리소스 수정 |
# Create
$ curl -X POST -H "Content-Type: application/json" http://localhost:3001/raw/clusters/kubernetes@in-cluster -d @- <<EOF
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"name": "test-namespace"
}
}
EOF
# Get
$ curl -X GET http://localhost:3001/raw/clusters/kubernetes@in-cluster/api/v1/namespaces/test-namespace
# Update
$ curl -X PATCH -H "Content-Type: application/merge-patch+json" http://localhost:3001/raw/clusters/kubernetes@in-cluster/api/v1/namespaces/test-namespace -d @- <<EOF
{
"metadata": {
"labels": {
"istio-injection": "disabled"
}
}
}
EOF
# verify
$ kubectl get ns/test-namespace -o jsonpath={.metadata.labels.istio-injection}
# Delete
$ curl -X DELETE http://localhost:3001/raw/clusters/kubernetes@in-cluster/api/v1/namespaces/test-namespace
# List
$ curl -X GET http://localhost:3001/raw/clusters/kubernetes@in-cluster/api/v1/namespaces
URL Pattern | Method | 설명 |
---|---|---|
/api/v1/clusters/:cluster | GET | summary metrics 조회 |
/api/v1/clusters/:cluster/nodes/:node | GET | Node metrics 조회 |
/api/v1/clusters/:cluster/namespaces/:namespaces/pods/:pod | GET | Pod metrics 조회 |
:cluster
: Kubeconfig context name:node
: Node name:metrics
: cpu
or memory
:pod
: Pod name$ curl -X GET http://localhost:8000/api/v1/clusters/kubernetes@in-cluster
$ curl -X GET http://localhost:8000/api/v1/clusters/kubernetes@in-cluster/nodes/vm-live-01
$ curl -X GET http://localhost:8000/api/v1/clusters/kubernetes@in-cluster/namespaces/default/pods/busybox
clusters
: Kubeconfig context namenamespaces
: Resource namespacepods
: Pod namecontainers
: Container nametermtype
: terminal type(cluster/pod/container)URL Pattern | Method | 설명 |
---|---|---|
termtype/{TERMTYPE} | GET | Web terminal 접속토큰 요청(kubectl) |
namespaces/{NAMESPACE}/pods/{POD}/termtype/{TERMTYPE} | GET | Web terminal 접속토큰 요청(pod) |
namespaces/{NAMESPACE}/pods/{POD}/containers/{CONTAINER}/termtype/{TERMTYPE} | GET | Web terminal 접속토큰 요청(container) |
URL Pattern | Method | 설명 |
---|---|---|
/api/terminal/ws | GET | Web terminal websocket 접속요청 |
/api/v1/config | PATCH | kubeconfig refresh event from backend |