curl 方式获取k8s 中的deployments

curl \
--header "Authorization: Bearer eyJhbGciOiJSUzI1NiIs_OVpAqcsnBZeqwwiwfkFWiykIobYEMgbMzbXa27r02Q_mGnqGzA6PiUq1SKDTq_SlBhAO_dCdnaZ6eOJ71ew" \
--insecure  \
-X GET https://10.20.12.13:6443/apis/apps/v1/namespaces/flink-dev/deployments

 python获取k8s api

import requests

headers = {
    'Authorization': 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IERVlsdjlVMWxNd3dIOHJEMUVBV1phMEhuUkFaNUt1Z1EifQ.eyJpc3MiOiJrdWJlcmw',
}

response = requests.get('https://10.20.12.13:6443:6443/apis/apps/v1/namespaces/flink-dev/deployments', headers=headers, verify=False)


print(response.json())

获取 k8s pods日志接口

GET /api/v1/namespaces/{namespace}/pods/{name}/log

更多方式获取k8s 集群信息 kube/config

python(shell\curl )通过k8s API获取pods、deployment、namespace等集群信息

神奇网站 curl 转python请求

curl转python请求

 

更多接口参考
https://support.huaweicloud.com/api-cci/readCoreV1NamespacedPodLog.html

https://www.cnblogs.com/moonwang/p/15599213.html

 

python3.5通过api管理k8s-创建删除deployment,service

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐