[英]How can I give access to statping deployed outside k8s cluster to monitor k8s services uptime?
[英]How to access the application deployed in minikube k8s cluster
我已经安装了 minikube,部署了 hello-minikube 应用程序并打开了端口。 基本上我遵循了https://kubernetes.io/docs/setup/learning-environment/minikube/#quickstart 上的入门教程。
当我想打开运行minikube service hello-minikube --url
获得的运行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
如何访问部署在 localhost 上的 minikube k8s 集群中的应用程序? 此外,minikube 作为 docker 容器在机器上运行,暴露了以下端口 32770:2376 32769:8443 32771:22。
在另一个线程中找到了解决方案——端口转发
kubectl port-forward svc/hello-minikube 31191:8080
第一个端口是您将在机器上(在浏览器中)使用的端口,8080 是运行服务时定义的端口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.