k8s获取apiversion下面的对应可用资源

2021-01-29 13:15

阅读:570

标签:versions   mon   amp   service   获取   jsonp   set   bind   groups   

1.shell脚本执行
for v in curl -ks https://<k8s-master>:<port>/apis | jq -r .groups[].versions[].groupVersion;
do
for r in curl -ks "https://<k8s-master>:<port>/apis/${v}" | jq -r ‘.resources[]?.kind‘ | sort -u;
do echo ${r} - ${v};
done ;
done

输出结果大概如下:
APIService - apiregistration.k8s.io/v1
APIService - apiregistration.k8s.io/v1beta1
DaemonSet - extensions/v1beta1
Deployment - extensions/v1beta1
DeploymentRollback - extensions/v1beta1
...
Role - rbac.authorization.k8s.io/v1
RoleBinding - rbac.authorization.k8s.io/v1
ClusterRole - rbac.authorization.k8s.io/v1beta1
ClusterRoleBinding - rbac.authorization.k8s.io/v1beta1
Role - rbac.authorization.k8s.io/v1beta1
RoleBinding - rbac.authorization.k8s.io/v1beta1

2.命令获取
kubectl get roles --all-namespaces -o jsonpath=‘{.items[*].apiVersion}‘

k8s获取apiversion下面的对应可用资源

标签:versions   mon   amp   service   获取   jsonp   set   bind   groups   

原文地址:https://blog.51cto.com/lemonnews/2449991


评论


亲,登录后才可以留言!