[英]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.