-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LoadBalancer assigned Docker bridge IP, inaccessible externally #162
Comments
If you are running on macOS or you just want the port to be locally accessible then you have to create port bindings on the node service to map each individual port you want exposed. like services:
node:
ports:
- 1234:80 That will map localhost:1234 to 80, which is the ingress load balancer (traefix). So now Below is what I tested on my laptop (running ubuntu 18.04 and docker 18.09.1) and it worked version: '3'
services:
server:
image: rancher/k3s:v0.1.0
command: server --disable-agent
environment:
- K3S_CLUSTER_SECRET=somethingtotallyrandom
- K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml
- K3S_KUBECONFIG_MODE=666
volumes:
- k3s-server:/var/lib/rancher/k3s
# This is just so that we get the kubeconfig file out
- .:/output
ports:
- 6443:6443
node:
image: rancher/k3s:v0.1.0
hostname: node1
tmpfs:
- /run
- /var/run
ports:
- 1234:80
privileged: true
environment:
- K3S_URL=https://server:6443
- K3S_CLUSTER_SECRET=somethingtotallyrandom
volumes:
k3s-server: {}
Even though it says |
Sorry, I realise I didn't explain the last part well:
Because I couldn't see the containers being run by K3s/containerd I was mistaken about where they were running (I thought the privileged agent container was running them on the host). Since the services:
node:
...
ports:
- 80:80
- 443:443 Sysadmin/DevOps is not my speciality, but I'm finding K3s is an amazing learning tool 🙂 |
I don't have a great fix for this yet. This is bigger kubernetes ingress issues in that ingress routes based on hostname so you need to setup hosts. Personally what I do for development is run ngrok. ngrok (if you haven't heard of it) gives you a public URL like http://10657ace.ngrok.io. So just run
and then whatever hostname they give you put that as the hostname in the ingress. A final approach would just be to not put a hostname at all in your ingress definitions. This is bad for multitenancy but for development it should just route all the traffic and ignore whatever hostname you use. |
Closing issue. I think the issue I'm having is a misunderstanding with Kubernetes, rather than anything K3s specific. |
I can confirm that following the approach describe by @ibuildthecloud it is possible to reach a service deployed on k3s via ingress. k3s version: 0.3.0
docker-compose.yaml (note: only a SINGLE node - notice the port mapping 8081:80 - host:ingress controller)
nginx-demo-deploy.yaml
nginx-demo-svc.yaml
nginx-demo-ing
HTHs Fraser. |
Describe the bug
Following the
docker-compose.yaml
installation method for K3s, the Traefik LoadBalancer is assigned an IP of the Docker bridge network forEXTERNAL-IP
but never binds the ports from containerd to the host machine making it inaccessible from the outside world.It's possibly related to #72, but I don't know enough to be sure.
Reproducible Steps
docker-compose.yaml
file below).1.1.1.1
with8.8.8.8
:kubectl -n kube-system get configmap coredns -o json | sed -e 's/1.1.1.1/8.8.8.8/g' | kubectl -n kube-system replace -f -
kubectl apply -f whoami.yaml
Expected behavior
The LoadBalancer to be assigned an IP address from a network interface of the host, rather than a bridge network - so that services can be accessed through ports 80/443 on the host.
Additional context
lsb_release -a
docker version
cat docker-compose.yaml
ip a
cat whoami.yaml
kubectl -n kube-system get all | grep -v Terminating
curl -X GET -H "Host: whoami.example.com" "http://172.20.0.3"
Making request
curl -X GET -H "Host: whoami.example.com" "http://${EXTERNAL_IP}"
is never able to connect.The text was updated successfully, but these errors were encountered: