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}‘