我已经安装了minikube,部署了hello-minikube应用程序并打开了端口。基本上,我遵循了https://kubernetes.io/docs/setup/learning-environment/minikube/#quickstart的入门教程。
当我想打开运行minikube service hello-minikube --url
获得的运行部署的应用程序的URL时,问题就开始了。
我得到http://172.17.0.7:31198
并且该URI无法打开,因为该IP在本地不存在。将其更改为http://localhost:31198
也不起作用(因此,我认为向主机文件添加条目将不起作用)。
应用程序正在运行,我可以查询集群并通过http://127.0.0.1:50501/api/v1/namespaces/default/services/hello-minikube
获取信息:
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "hello-minikube",
"namespace": "default",
"selfLink": "/api/v1/namespaces/default/services/hello-minikube",
"uid": "56845ce6-bbba-45e5-a1b6-d094949438cf",
"resourceVersion": "1578",
"creationTimestamp": "2020-03-10T10:33:41Z",
"labels": {
"app": "hello-minikube"
}
},
"spec": {
"ports": [
{
"protocol": "TCP",
"port": 8080,
"targetPort": 8080,
"nodePort": 31198
}
],
"selector": {
"app": "hello-minikube"
},
"clusterIP": "10.108.152.177",
"type": "NodePort",
"sessionAffinity": "None",
"externalTrafficPolicy": "Cluster"
},
"status": {
"loadBalancer": {
}
}
}
λ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-minikube NodePort 10.108.152.177 <none> 8080:31198/TCP 4h34m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 4h42m
如何访问本地主机上minikube k8s集群中部署的应用程序?另外,minikube在机器上作为docker容器运行,并暴露了以下端口32770:2376 32769:8443 32771:22。
答案 0 :(得分:1)