Cant access kubernetes pod (minikube)

8/7/2018

This is how the service & pod looks like in kubernetes

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.

What is wrong?

This is the file I run "kubectl -f on:

{
    "apiVersion": "v1",
    "kind": "Pod",
    "metadata": {
        "name": "wordpress-site",
        "labels": {
            "app": "web"
        }
    },
    "spec": {
        "containers": [
            {
                "name": "wordpress",
                "image": "wp:latest",
                "imagePullPolicy": "Never",
                "ports": [
                    {
                        "containerPort": 80
                    }
                ]
            }
        ]
    }
}
-- Sebastian Karlsson
docker
kubernetes
nginx
wordpress

2 Answers

8/7/2018

Got it working by setting:

hostNetwork: true

-- Sebastian Karlsson
Source: StackOverflow

8/7/2018

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. For this problem we can use kubernetes services.

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-

--
Source: StackOverflow