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
Co-authored-by: Thorsten Klein <iwilltry42@gmail.com>
@iwilltry42 pointed out that currnet error path calls os.Exit(1), which
does follow the normal CLI framework. This patch implements this
suggestion.
Add a closure fucntion deleteCluster() to reduce code duplication.
When creating clusters with the --auto-restart flag, any running cluster
will remain "running" up on docker daemon restart.
By default, without this flag, a "running" cluster becomes "stopped"
after docker daemon restart.
Clusters stopped with 'k3d stop' command will remain stopped after
docker daemon restart regardless the settings of this flag.
Before this commit, when creating a cluster was not successful, some
resource may be lingering behind. This commit fixes those cases.
Now the cluster creation model is easier to understand. Either a cluster
is successfully created, or all resources created will be cleaned up.
The intention is to keep the "atomic create" model going forward for
k3d.
Current SRC definition only picks up main.go, not all golang source code
of the project. Fix so that 'make fmt" and 'make simplify' can work as
expected.