【发布时间】:2018-05-18 05:05:28
【问题描述】:
所以我刚刚开始使用 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()
这有效,但它返回了我本地 minikube 上的 pod,我想在这里获取 kubernetes 服务器上的 pod:
http://192.168.237.115:8080
我该怎么做?
当我做 kubectl config view 时,我得到了这个:
apiVersion: v1
clusters:
- cluster:
certificate-authority: /home/piyush/.minikube/ca.crt
server: https://192.168.99.100:8443
name: minikube
contexts:
- context:
cluster: minikube
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: /home/piyush/.minikube/apiserver.crt
client-key: /home/piyush/.minikube/apiserver.key
我知道这是针对我设置的本地集群的。我想知道如何修改它以向http://192.168.237.115:8080上的kubernetes服务器发出api请求
【问题讨论】:
标签: python kubernetes