It turns out that docker client only pays attention to the following
environment variables:
DOCKER_HOST to set the url to the docker server.
DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest.
DOCKER_CERT_PATH to load the TLS certificates from.
DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default.
A miss configured DOCKER_MACHINE_NAME won't affect docker client, so k3d
should just ignore the error.
Currently, when the 'docker-machine' command fails, we only logs
"exit status 1'
Which is not very helpful in root cause analysis.
With this patch, the 'docker-machine' command's stderr output is also
logged.
# To cause docker-machine command fail
$ export DOCKER_MACHINE_NAME=xx
$ k3d create
2019/06/13 16:45:31 Created cluster network with ID 6fc91e0e5e912443e6b847f113a6a0bb85ccd610e5232592296d4b199f0347cf
2019/06/13 16:45:31 Error executing 'docker-machine ip'
2019/06/13 16:45:31 Docker machine "xx" does not exist. Use "docker-machine ls" to list machines. Use "docker-machine create" to add a new one.
exit status 1
We have been giving user warnings about --timeout going away for a
while. Now fully deprecate it.
Use -t for --wait option
Move -w from --wait to --workers. Many users of K3d generate multi-node
clusters, -w will make their life easier.
To allow some flexibilities in how user specifies the --api-port
argument. In case the 'host' is an string, We will try to convert
it into an IP address for port mapping. IP address is also allowed.
The APIs of createServer() and createWorker() takes too many arguments.
It is getting harder to maintain.
Use a new struct ClusterSpec to make API simpler. This also reduces
some code duplications.
When running on a docker machine, the default X598 certificate does not
allow access via docker machine's IP. This patch fixes this by adding
"--tls-san <docker machine IP>" to the K3S server argument list.
The kubeconfig.yaml generated by K3S uses local host as the host name by
default. It won't work when running with docker machine.
This patch detects if the docker environment is set up with docker
machine. If it is, then replace the host name to the IP address of
the docker machine.
In theory, we can execute 'k3d bash' again within an cluster shell. I
can't think of any practical value for allowing this capability.
On the contrary, this can lead to confusion to the user.
This patch adds a simple mechanism to detect and block recursive bash
invocation.
In addition to provide an interactive shell, this patch adds the
'--command' and '-c' options to allow user to issue a command in the
context of a cluster.
For example:
$ k3d bash -c 'kubectl cluster-info'
OS distribution and user may choose to install bash in different path.
This patch uses bash found by "$PATH" environment, rather than hard code
the bash path.
This patch also handle the case 'bash' are not found. Mostly likely due
to bash not being supported by the platform, or it is not installed.
Add the basic frame work for supporting spawning a bash shell by cli
command.
With this change, we can spawn a bash shell in the context of a cluster
$ k3d create -n my-cluster
$ k3d bash -n my-cluster
[my-cluster] $>
// execute commands with KUBECONFIG already set up
[my-cluster] $> kubectl get pods