Hi
I have a question about --publish option. How can we publish multiple ports when we create the cluster? It is not clear for me what is the format of the input to publish multiple ports.
Thanks
Hey there,
You use --api-port (once) to specify the published port of the Kubernetes API-Server (6443 by default).
Then you use the --publish flag as often as you want to publish any number of additional ports.
Example: k3d create --api-port 6448 --publish 8976:8976 --publish 6789:6789 -n test-ports
This will show up in docker like this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0bc54618c54e rancher/k3s:v0.7.0 "/bin/k3s server --h…" 3 seconds ago Up 2 seconds 0.0.0.0:6448->6448/tcp, 0.0.0.0:6789->6789/tcp, 0.0.0.0:8976->8976/tcp k3d-test-ports-server
Be aware though, that there are some pitfalls when using the --publish flags while creating a multi-node cluster (because you cannot map the same host port to multiple containers/nodes).
Does that answer your question good enough? :+1:
Thanks for your answer. Yes it is perfect and answers my question.
Most helpful comment
Thanks for your answer. Yes it is perfect and answers my question.