成功启动gcloud或aws群集后,使用kubernetes Service + Deployment命令(如
)填充它kubectl create -f my-deployment.yaml
如果我停留在同一台机器上,那么一切都很好......但是,如何继续与来自不同本地主机的相同部署群集进行交互? ......我正在努力避免可怕的事情:
kubectl get pods
The connection to the server localhost:8080 was refused - did you specify the right host or port?
答案 0 :(得分:1)
对于亚马逊aws ,只需使用
进行身份验证export AWS_ACCESS_KEY_ID=$(cat ${AWS_ACCOUNT_CONFIGDIR}/id)
export AWS_SECRET_ACCESS_KEY=$(cat ${AWS_ACCOUNT_CONFIGDIR}/key)
$(aws ecr get-login --region ${AWS_REGION} )
然后发出kubectl命令,就好像您从其他主机部署了群集一样
对于谷歌云 :只需登录该不同本地主机上的gcloud即可检索群集凭据
gcloud container --project ${PROJECT_ID} clusters get-credentials ${GKE_CLUSTER} --zone ${GKE_ZONE}
然后kubernetes命令将起作用...按照
kubectl get pods
NAME READY STATUS RESTARTS AGE
chainsaw-deployment-2102970301-q5hyn 2/2 Running 0 2h
mongo-controller-81c3m 1/1 Running 0 2h