所以我刚刚开始使用 Kubernetes API 服务器,我尝试了这个例子:
from kubernetes import client, config
def main():
# Configs can be set in Configuration class directly or using helper
# utility. If no argument provided, the config will be loaded from
# default location.
config.load_kube_config()
v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
print("%s\t%s\t%s" %
(i.status.pod_ip, i.metadata.namespace, i.metadata.name))
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
这有效,但它返回了我本地 minikube 上的 pod,我想在这里获取 kubernetes 服务器上的 pod:
http://192.168.237.115:8080
我该怎么做?
当我这样做时kubectl config view,我得到了这个:
apiVersion: v1 …Run Code Online (Sandbox Code Playgroud)