[英]Cant access kubernetes pod (minikube)
On the image, you can see the service and the pod. 在图像上,您可以看到服务和窗格。
If I execute "curl localhost" inside the container, I get a response, but I am not able to access it from outside. 如果我在容器内执行“ curl localhost”,则会收到响应,但无法从外部访问它。
What is wrong? 怎么了?
This is the file I run "kubectl -f on: 这是我在“ kubectl -f”上运行的文件:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "wordpress-site",
"labels": {
"app": "web"
}
},
"spec": {
"containers": [
{
"name": "wordpress",
"image": "wp:latest",
"imagePullPolicy": "Never",
"ports": [
{
"containerPort": 80
}
]
}
]
}
}
First I would need some more information but with what you gave me I will make the assumption you want to access it from outside the node the pod is. 首先,我需要更多信息,但是根据您给我的信息,我将假设您要从Pod所在的节点之外访问它。 For this problem we can use kubernetes services .
对于这个问题,我们可以使用kubernetes服务 。
You could easy add the service configuration to the yaml file, here is the api reference for doing that: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#-strong-service-apis-strong- 您可以轻松地将服务配置添加到yaml文件,这是执行此操作的api参考: https : //kubernetes.io/docs/reference/produced/kubernetes-api/v1.11/#-strong-service-apis -强大-
Got it working by setting: 通过设置使其工作:
hostNetwork: true hostNetwork:true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.