Georg Heiler
Georg Heiler

Reputation: 17676

external access to kubernetes

docker run \
    --volume=/:/rootfs:ro \
    --volume=/sys:/sys:ro \
    --volume=/var/lib/docker/:/var/lib/docker:rw \
    --volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
    --volume=/var/run:/var/run:rw \
    --net=host \
    --pid=host \
    --privileged=true \
    -d \
    gcr.io/google_containers/hyperkube-amd64:v${K8S_VERSION} \
    /hyperkube kubelet \
        --containerized \
        --hostname-override="127.0.0.1" \
        --address="0.0.0.0" \
        --api-servers=http://localhost:8080 \
        --config=/etc/kubernetes/manifests \
        --cluster-dns=10.0.0.10 \
        --cluster-domain=cluster.local \
        --allow-privileged=true --v=2

A curl localhost:8080confirms that the API is running.

But trying to access it with the host's IP like curl dockerHostIp:8080fails:

Failed to connect to ipOfDockerHost port 8080: Connection refused

How can I expose k8s to the outside? (docker-host is an ubuntu server) As far as I understand using --net=host should solve this problem. But it does not work in this case.

Upvotes: 2

Views: 116

Answers (1)

Thibault Deheurles
Thibault Deheurles

Reputation: 1259

When you start kubernetes with docker, you choose between two models:

If you look in these files, you will notice one difference: --insecure-bind-address is different.

When you use --config=/etc/kubernetes/manifests, you ask for a local access only.

You should start with --config=/etc/kubernetes/manifests-multi.

Note that:

  • you will need to start etcd manually when you use --config=/etc/kubernetes/manifests-multi
  • follow this post as docker support is not working for now

Upvotes: 2

Related Questions