Sebastian Karlsson
Sebastian Karlsson

Reputation: 745

Cant access kubernetes pod (minikube)

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
                    }
                ]
            }
        ]
    }
}

Upvotes: 0

Views: 109

Answers (2)

Sebastian Karlsson
Sebastian Karlsson

Reputation: 745

Got it working by setting:

hostNetwork: true

Upvotes: 0

user3183671
user3183671

Reputation:

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-

Upvotes: 1

Related Questions