205 Commits

Author SHA1 Message Date
Thorsten Klein
5ebe276162
Merge pull request #76 from andyz-dev/no-timeout
[Enhancement] Deprecate --timeout, shift short hand options around
v1.2.2
2019-06-07 15:00:32 +02:00
Andy Zhou
f037e1b225 Deprecate --timeout, shift shot hand options around
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.
2019-06-06 12:26:26 -07:00
Andy Zhou
8a59078c87
Merge pull request #75 from andyz-dev/api-port
[Enhancement] Api port
2019-06-06 06:55:30 -07:00
Andy Zhou
fa18c37155 Simplify Dockerm machine ip handling
Based on review comments from @iwilltry42
2019-06-05 09:18:57 -07:00
Andy Zhou
fc6a01d55a Allow --api-port to take host with either name or IP address
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.
2019-06-03 17:51:55 -07:00
Andy Zhou
1080c0b157 Fix up kubeconfig.yaml with --api-port host 2019-06-03 17:51:55 -07:00
Andy Zhou
a72945af71 Enhance docekr port mapping for --api-port 2019-06-03 17:51:55 -07:00
Andy Zhou
58849e4a01 Make use of the parseApiPort() function when creating cluster 2019-06-03 17:51:55 -07:00
Andy Zhou
1e6ac3cce8 Enhance ClusterSpec
Pass the apiPort sturct directly via ClusterSpec.
2019-06-03 17:22:23 -07:00
Andy Zhou
f0c1b24e0b Add parseApiPort()
Now that --api-port takes a string argument, add a parser function to
handle error checking for this argument.
2019-06-03 17:21:44 -07:00
Andy Zhou
b97ef230bd Refactor
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.
2019-06-03 17:18:51 -07:00
Andy Zhou
1565e43365 Modify --api-port to take a stirng argument
--api-port only takes the port as argument. This patch modifies it to
take a string argument, in the form of host:port.
2019-06-03 17:16:46 -07:00
Andy Zhou
bd58e9b874
Merge pull request #71 from andyz-dev/docker-machine
[Feature] Docker machine
2019-06-01 11:03:42 -07:00
Andy Zhou
f3ec169414 Add docker machine IP to SAN
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.
2019-06-01 10:57:42 -07:00
Andy Zhou
92b5d90216
Merge pull request #72 from andyz-dev/network-name
[Enhancement] Add k3d- prefix to docker network name
2019-05-31 10:39:54 -07:00
Andy Zhou
d1a709365f
Merge pull request #70 from rancher/feature/auto-shell-and-zsh
[Feature] auto mode and zsh support for shell command
2019-05-31 10:39:12 -07:00
iwilltry42
f771dcf8b5 shell flag text 2019-05-31 12:34:44 +02:00
iwilltry42
6a46ef9d94 fix prompt from env 2019-05-31 12:00:00 +02:00
Andy Zhou
1f7d234c80 Add k3d- prefix to docker network name
Should make sense since all container names are with the same prefix.
2019-05-31 02:04:07 -07:00
iwilltry42
f220f0121a get prompt from env depdending on selected shell 2019-05-31 10:52:48 +02:00
iwilltry42
93115400fc add shell struct with prompt differentiation 2019-05-31 09:43:45 +02:00
Andy Zhou
de6e845abd Support docker machine for kubeconfig.yaml
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.
2019-05-29 09:09:13 -07:00
iwilltry42
eb5b88052e add auto mode for shell based on SHELL env var and support zsh 2019-05-29 09:14:36 +02:00
Thorsten Klein
df5cc1da84
Merge pull request #66 from andyz-dev/bash
[Feature] Add Bash shell support
2019-05-29 07:56:49 +02:00
Andy Zhou
a45c0011a6
Merge pull request #69 from larmog/fix-worker-env
Now passes the environment variables to the workers.
2019-05-28 18:10:16 -07:00
Lars Mogren
f2cedfd6cd Now passes the environment variables to the workers. 2019-05-28 22:59:27 +02:00
Andy Zhou
abd9a984eb Add --shell argument
Add subshell argument --shell. Currently, support only bash, which is
also the default value.
2019-05-27 17:16:04 -07:00
Andy Zhou
d63f7d4bf2 Rename bash command to shell
@iwilltry42 suggested to group all shell support under and single
subcommand -- shell.
2019-05-27 17:14:43 -07:00
Andy Zhou
8aaf70f4bf Block recursive bash invocation
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.
2019-05-24 17:16:12 -07:00
Andy Zhou
2971dd6845 Add the ability to execute commands directly with the bash subcommand
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'
2019-05-24 17:16:12 -07:00
Andy Zhou
5c6f2d7dc5 Avoid hard coding the bash path
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.
2019-05-24 17:16:12 -07:00
Andy Zhou
4ef6710e22 Add basic bashShell() function
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
2019-05-24 17:16:12 -07:00
Andy Zhou
9f276a68f3 Add getKubeConfig()
Move the logic of retrive per cluster kube config file into
cli/cluster.go. Simplify the CLI handling code.
2019-05-24 17:16:12 -07:00
Andy Zhou
cdcc5e1de6 Add createKubeconfigFile()
Refactoring. Make createKubeconfigFile() a stand along function, so we
don't have to recreate the file every time we look up the file name.
2019-05-24 17:16:12 -07:00
Andy Zhou
1eff974064 Add getClusterKubeConfigPath()
Minor refactor. Add getClusterKubeConfigOath() to make logic reusable
for later changes.
2019-05-24 17:16:12 -07:00
Andy Zhou
682d86cbd7
Merge pull request #64 from andyz-dev/error-handling
[Enhancement] Improve error handling for CreateCluster()
2019-05-22 11:27:09 -07:00
Andy Zhou
3947baf3bb
Merge pull request #63 from rancher/refactor-docs
[Docs] Prepare for proper documentation
v1.2.2-beta.0
2019-05-21 16:00:13 -07:00
iwilltry42
a3bb1b03f3 clarification 2019-05-22 00:28:23 +02:00
iwilltry42
41ccf89fdc improve section 2019-05-22 00:27:45 +02:00
Thorsten Klein
ea96d375af
Merge pull request #62 from rancher/issue-templates
Update issue templates
2019-05-22 00:22:43 +02:00
Andy Zhou
175ccbe3cd Improve error handling for CreateCluster()
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.
2019-05-21 14:10:11 -07:00
Thorsten Klein
2a4827b944
add docker version 2019-05-21 23:04:12 +02:00
Andy Zhou
6dfb1e054b
Merge pull request #61 from andyz-dev/always-on
[Feature] Implement --always-on flag for the create command
2019-05-21 10:46:00 -07:00
Andy Zhou
b9713c4ac4 Add --auto-restart flag for the create command
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.
2019-05-21 09:31:45 -07:00
iwilltry42
6e42d079f7 refactor documentation 2019-05-21 16:16:33 +02:00
Thorsten Klein
ba7c58ad56 Update issue templates 2019-05-21 16:11:28 +02:00
Andy Zhou
5028f2882f
Merge pull request #60 from andyz-dev/atomic-create
[Enhancement] Atomic create
2019-05-20 23:21:19 -07:00
Andy Zhou
fe93fc8c24
Merge pull request #59 from andyz-dev/timeout
[Enhancement] Deprecate the --timeout option
2019-05-20 23:20:25 -07:00
Andy Zhou
490b7cd864 Atomic create
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.
2019-05-20 19:03:32 -07:00
Andy Zhou
3683eeb181 Deprecate the --timeout option
Use --wait <timeout> instead
2019-05-20 14:07:12 -07:00