KubeSphere api硬件资源接口获取的玩法
参考资料KubeSphere Api DocumentsAPI 文档 - 监控指标说明 - 《KubeSphere v2.0 使用手册》 - 书栈网 · BookStack架构KubeSphere API 服务器为 API 对象验证和配置数据。API 服务器为 REST 操作提供服务,并为集群的共享状态提供前端,其他所有组件通过它进行交互。使用 KubeSphere APIKubeSphere 3
参考资料
API 文档 - 监控指标说明 - 《KubeSphere v2.0 使用手册》 - 书栈网 · BookStack
架构
KubeSphere API 服务器为 API 对象验证和配置数据。API 服务器为 REST 操作提供服务,并为集群的共享状态提供前端,其他所有组件通过它进行交互。
使用 KubeSphere API
KubeSphere 3.0 将 ks-apigateway 和 ks-account 功能移动至 ks-apiserver 中,使架构更加紧凑和清晰。要使用 KubeSphere API,您需要将 ks-apiserver 暴露给您的客户端。
步骤 1:暴露 KubeSphere API 服务
如果您要在集群内部访问 KubeSphere,可以跳过以下内容,使用 KubeSphere API 服务器 Endpoint http://ks-apiserver.kubesphere-system.svc
即可。
如果从集群外部访问,您需要先将 KubeSphere API 服务器 Endpoint 暴露给集群外部。
暴露 Kubernetes 服务的方式有很多。本示例使用 NodePort
来演示。使用以下命令将 ks-apiserver
的服务类型变更为 NodePort
。
$ kubectl -n kubesphere-system patch service ks-apiserver -p '{"spec":{"type":"NodePort"}}'
$ kubectl -n kubesphere-system get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE etcd ClusterIP 10.233.34.220 <none> 2379/TCP 44d ks-apiserver NodePort 10.233.15.31 <none> 80:31407/TCP 49d ks-console NodePort 10.233.3.45 <none> 80:30880/TCP 49d
现在,您可以从集群外部通过 URL(例如 http://[node ip]:31407
)访问 ks-apiserver
,其中 [node ip]
是您集群中任意节点的 IP 地址。
1.获取秘钥
http://250.250.250.250/oauth/token
Content-Type application/x-www-form-urlencoded
grant_type password
username test
password 66666
{
"access_token": "eyJhbGci6iJhY2Nlc3NfdG9rZW4iLCJleHAiOjE2MjIwMDMzNDUsImlhdCI6MTYyMTk5NjE0NSwiaXNzIjoia3ViZXNwaGVyZSIsIm5iZiI6MTYyMTk5NjE0NX0.l5HneqGFqS8F4ZMR6mql0FBdD2uqDsEkhEAEaky1u9I",
"token_type": "Bearer",
"refresh_token": "eyJhbGciOiJIUzI1NiIsIn6va2VuX3R5cGUiOiJyZWZyZXNoX3Rva2VuIiwiZXhwIjoxNjIyMDEwNTQ1LCJpYXQiOjE2MjE5OTYxNDUsImlzcyI6Imt1YmVzcGhlcmUiLCJuYmYiOjE2MjE5OTYxNDV9.an8MBlHmbby_zDURlQeG08N83rFw2h3dUWJjRZuw8xU",
"expires_in": 7200
}
获取节点信息:GET
http://6.6.6.6.6.6.6.6.6.6.6.6.6./kapis/resources.kubesphere.io/v1alpha3/nodes
Authorization
Bearer eyJhbGciOiJIUzI63ViZXNwaGVyZSIsIm5iZiI6MTYyMTk5NjE0NX0.l5HneqGFqS8F4ZMR6mql0FBdD2uqDsEkhEAEaky1u9I
Cluster
指标名 | 说明 | 单位 |
---|---|---|
cluster_cpu_utilisation | 集群 CPU 使用率 | |
cluster_cpu_usage | 集群 CPU 用量 | Core |
cluster_cpu_total | 集群 CPU 总量 | Core |
cluster_load1 | 集群 1 分钟 CPU 平均负载[^1] | |
cluster_load5 | 集群 5 分钟 CPU 平均负载 | |
cluster_load15 | 集群 15 分钟 CPU 平均负载 | |
cluster_memory_utilisation | 集群内存使用率 | |
cluster_memory_available | 集群可用内存 | Byte |
cluster_memory_total | 集群内存总量 | Byte |
cluster_memory_usage_wo_cache | 集群内存使用量[^2] | Byte |
cluster_net_utilisation | 集群网络数据传输速率 | Byte/s |
cluster_net_bytes_transmitted | 集群网络数据发送速率 | Byte/s |
cluster_net_bytes_received | 集群网络数据接受速率 | Byte/s |
cluster_disk_read_iops | 集群磁盘每秒读次数 | 次/s |
cluster_disk_write_iops | 集群磁盘每秒写次数 | 次/s |
cluster_disk_read_throughput | 集群磁盘每秒读取数据量 | Byte/s |
cluster_disk_write_throughput | 集群磁盘每秒写入数据量 | Byte/s |
cluster_disk_size_usage | 集群磁盘使用量 | Byte |
cluster_disk_size_utilisation | 集群磁盘使用率 | |
cluster_disk_size_capacity | 集群磁盘总容量 | Byte |
cluster_disk_size_available | 集群磁盘可用大小 | Byte |
cluster_disk_inode_total | 集群 inode 总数 | |
cluster_disk_inode_usage | 集群 inode 已使用数 | |
cluster_disk_inode_utilisation | 集群 inode 使用率 | |
cluster_node_online | 集群节点在线数 | |
cluster_node_offline | 集群节点下线数 | |
cluster_node_offline_ratio | 集群节点下线比例 | |
cluster_node_total | 集群节点总数 | |
cluster_pod_count | 集群中调度完成[^3] Pod 数量 | |
cluster_pod_quota | 集群各节点 Pod 最大容纳量[^4]总和 | |
cluster_pod_utilisation | 集群 Pod 最大容纳量使用率 | |
cluster_pod_running_count | 集群中处于 Running 阶段[^5]的 Pod 数量 | |
cluster_pod_succeeded_count | 集群中处于 Succeeded 阶段的 Pod 数量 | |
cluster_pod_abnormal_count | 集群中异常 Pod [^6]数量 | |
cluster_pod_abnormal_ratio | 集群中异常 Pod 比例 [^7] | |
cluster_ingresses_extensions_count | 集群 Ingress 数 | |
cluster_cronjob_count | 集群 CronJob 数 | |
cluster_pvc_count | 集群 PersistentVolumeClaim 数 | |
cluster_daemonset_count | 集群 DaemonSet 数 | |
cluster_deployment_count | 集群 Deployment 数 | |
cluster_endpoint_count | 集群 Endpoint 数 | |
cluster_hpa_count | 集群 Horizontal Pod Autoscaler 数 | |
cluster_job_count | 集群 Job 数 | |
cluster_statefulset_count | 集群 StatefulSet 数 | |
cluster_replicaset_count | 集群 ReplicaSet 数 | |
cluster_service_count | 集群 Service 数 | |
cluster_secret_count | 集群 Secret 数 | |
cluster_namespace_count | 集群 Namespace 数 |
更多推荐
所有评论(0)