所以我剛開始使用Kubernetes API服務器,我試過了這個例子: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豆莢,我想這是莢在這裏的kubernetes服務器: 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
我知道這是本地羣集我設立。我想知道如何修改此做出API請求kubernetes服務器上http://192.168.237.115:8080
所以這是我所得到的,當我做'kubectl配置視圖':'apiVersion:V1 集羣: - 集羣: 證書頒發機構:/home/piyush/.minikube/ca.crt 服務器:HTTPS: //192.168.99.100:8443 名稱:minikube 背景: - 背景: 集羣:minikube 用戶:minikube 名稱:minikube 當前上下文:minikube 類型:配置 喜好:{} 用戶: - 名稱:minikube 用戶: 客戶端證書:/home/piyush/.minikube/apiserver.crt client-key:/home/piyush/.minikube/apiserver.key' –
我知道我必須修改這個來添加集羣。但是我對證書頒發機構有什麼價值? –
您可以先更新原始問題中的配置文件嗎? – BMW