Commit Graph

370 Commits

Author SHA1 Message Date
iwilltry42
a0c0c3ff9d add --api-port and --port-auto-offset 2019-05-13 09:08:32 +02:00
iwilltry42
7d6ae201e9 make node-specifier mandatory 2019-05-13 08:12:09 +02:00
iwilltry42
58b1682e32 Merge branch 'master' of https://github.com/rancher/k3d into new-publish 2019-05-13 07:54:07 +02:00
iwilltry42
0670a0e11b resovle conflicts 2019-05-13 07:53:23 +02:00
iwilltry42
a881a87ef6 go fmt 2019-05-13 07:50:05 +02:00
Andy Zhou
2f07bdb78a Center align list output
Make list output center aligne. It is slightly eaier to read.

Before the commit:

$ bin/k3d list --all

+-------------+------------------------------+---------+---------+
|    NAME     |            IMAGE             | STATUS  | WORKERS |
+-------------+------------------------------+---------+---------+
| k3s-default | docker.io/rancher/k3s:v0.5.0 | running | 2/2     |
+-------------+------------------------------+---------+---------+

After this commit:

$ bin/k3d list --all

+-------------+------------------------------+---------+---------+
|    NAME     |            IMAGE             | STATUS  | WORKERS |
+-------------+------------------------------+---------+---------+
| k3s-default | docker.io/rancher/k3s:v0.5.0 | running |   2/2   |
+-------------+------------------------------+---------+---------+

In this output, only the last cell shows up differently.
2019-05-12 16:01:49 -07:00
Thorsten Klein
5b73df5f43
Merge pull request #38 from zeerorg/delete_Create
[Enhancement] Delete a cluster if it encounters error when starting (@zeerorg)
2019-05-10 11:43:38 +02:00
Rishabh Gupta
787d6608ba Delete a cluster if it is not started due to port conflicts or any other unforseen error
Signed-off-by: Rishabh Gupta <r.g.gupta@outlook.com>
2019-05-10 13:10:55 +05:30
iwilltry42
0c8cdc004a Merge branch 'master' of https://github.com/rancher/k3d into new-publish 2019-05-09 15:36:27 +02:00
Andy Zhou
32cc70b599
Merge pull request #32 from andyz-dev/publish
[Feature] Add --publish/--add-port flag for port mappings
2019-05-09 01:09:40 -07:00
iwilltry42
d0f905d2fa readme on go install 2019-05-09 09:52:51 +02:00
iwilltry42
fd720b0887 move hostname check to util 2019-05-09 08:05:39 +02:00
Thorsten Klein
4c14a8e5b2
Merge pull request #35 from andyz-dev/clustername
[Bugfix] Default cluster name and hostname checks
2019-05-09 07:55:55 +02:00
Andy Zhou
93f72e672a Make sure the culster name is valid before creating it.
MAke sure the cluster name is a RFC 1123 compliant host name, since the
cluster name is used as base for expanding into a auto generated
host names for k3s nodes.
2019-05-08 15:57:32 -07:00
Andy Zhou
4ebf34218b Consolidate the default cluster name into as single definition
To ensure all reference of the default cluster name are the same.
Not having to check for typos will make it easier to maintain.
2019-05-08 11:30:56 -07:00
iwilltry42
15b1326456 [bugfix] default name without underscore 2019-05-08 18:28:38 +02:00
iwilltry42
124a45688f working version 2019-05-08 15:29:57 +02:00
iwilltry42
d35f12a77e init 2019-05-08 13:37:24 +02:00
Andy Zhou
65f2820b3f Support publishing ports for the worker nodes
All ports exposed by --publish will also be exported for all worker
nodes. The host port will be auto indexed based worker id.

For example: with the following command option:

k3d create --publish  80:80  --publish 90:90/udp --workers 1

The exposed ports will be:

host TCP port 80  -> k3s server TCP 80
host TCP port 90  -> k3s server TCP 90
host UDP port 81 -> k3s worker 0 UDP 80
host UDP port 91 -> k3s worker 0 UDP 90
2019-05-08 01:45:16 -07:00
Andy Zhou
988fbdbdc5 Refactor createWorker() API
Use postfix as int instead string. This make the following patch easier
to read.
2019-05-08 01:45:16 -07:00
Andy Zhou
f70a8b42f7 Add support for the --publish option for create subcommand
Inspired by the docker CLI, --publish take same input as docker CLI and
provides similar functions. For the k3s cluster server node, it behaves
the same as docker cli; it exports the k3d server ports to the host
ports.

Handling for worker nodes will be added in the subsequent patches.

This option can be used mutiple times for exposing more ports.

--add-port is an alias to this option.
2019-05-08 01:45:16 -07:00
Andy Zhou
6fe75640bb Add the PublishedPorts helping class
This class holds the parsed results of the --publish options. Its
methods helps the create clones of class, with mutations applied.

Currently, there are two methods: Offset() change the host ports by a
fixed amount.  Addport() adds one additional port to the class.
2019-05-07 11:38:00 -07:00
Thorsten Klein
0c332faf2b
Merge pull request #30 from rancher/feature/custom-image-flag
[Feature] add --image/-i flag to specify custom k3s image/tag (start deprecation of --version flag)
2019-05-07 14:55:00 +02:00
iwilltry42
40fb583160 better image and version flags 2019-05-07 09:09:05 +02:00
iwilltry42
4fbda454f7 remove todo 2019-05-06 08:32:18 +02:00
iwilltry42
9ac81982e2 [Enhancement] set hostnames for nodes 2019-05-06 08:26:10 +02:00
iwilltry42
e78a548da2 [Feature] add --image/-i flag to specify custom k3s image 2019-05-06 08:13:11 +02:00
Thorsten Klein
a0d9089a6f
Merge pull request #27 from ibuildthecloud/pull
[ENHANCEMENT] Only pull image if the image is not found and always force remove containers (thanks @ibuildthecloud )
2019-05-04 08:19:33 +02:00
Thorsten Klein
6570d969a3
Merge pull request #26 from ibuildthecloud/network
[ENHANCEMENT] Only create network if not found (thanks @ibuildthecloud )
2019-05-04 08:14:59 +02:00
Thorsten Klein
19c9903aa4
Merge pull request #24 from cartyc/default-version
[BUGFIX] go install: use latest tag as default k3s version (thanks to @cartyc)
2019-05-04 08:12:38 +02:00
Darren Shepherd
13aaec64ed Only create network if not found 2019-05-03 21:13:22 -07:00
Chris Carty
e82e95a23d update default K3sVersion to use latest tag 2019-05-03 22:04:39 -04:00
Darren Shepherd
7c76f4621a Always to force delete 2019-05-03 17:14:16 -07:00
Darren Shepherd
c86518e3d4 Only pull image if the image is not found 2019-05-03 17:13:41 -07:00
iwilltry42
a9b55a2c11 Merge PR #22 fixing 'get-kubeconfig' (thanks @andyz-dev and thanks @cloudnautique for PR #21) 2019-05-03 07:59:53 +02:00
iwilltry42
1294b5b3a6 Merge branch 'imporve-error-message' of https://github.com/andyz-dev/k3d into andyz-dev-imporve-error-message 2019-05-03 07:59:25 +02:00
Chris Carty
f9afbc5b9a updated location of K3sVersion 2019-05-02 22:39:37 -04:00
Chris Carty
508f9715ee added default version 2019-05-02 22:11:50 -04:00
Andy Zhou
2267924578 cli: Improve error message for 'k3d get-kubeconfig'
Before this change, command:
 $ k3d create -name test
 $ k3d get-kubeconfig

Produces the following error message:

	panic: runtime error: index out of range

	goroutine 1 [running]:
	github.com/rancher/k3d/cli.GetKubeConfig(0xc00031a160, 0x0, 0x0)
		/Users/azhou/projs/k3d/cli/commands.go:335 +0x105d
	github.com/urfave/cli.HandleAction(0x13e7ca0, 0x148f0b0, 0xc00031a160, 0xc000304000, 0x0)
		/Users/azhou/projs/rcloud/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:490 +0xc8
	github.com/urfave/cli.Command.Run(0x1477cb5, 0xe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1480cd8, 0x23, 0x0, ...)
		/Users/azhou/projs/rcloud/pkg/mod/github.com/urfave/cli@v1.20.0/command.go:210 +0x996
	github.com/urfave/cli.(*App).Run(0xc0000bc1a0, 0xc00000e060, 0x2, 0x2, 0x0, 0x0)
		/Users/azhou/projs/rcloud/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:255 +0x6af
	main.main()
		/Users/azhou/projs/k3d/main.go:185 +0x11e0

This patch improve the error message by avoid the panic. Now the output
becomes:

	019/05/02 12:05:30 No server container for cluster k3s_default
2019-05-02 12:17:36 -07:00
iwilltry42
cb6d8a77af Merge branch 'master' of https://github.com/rancher/k3d into development 2019-05-02 07:26:24 +02:00
Thorsten Klein
60c622e822
Merge pull request #20 from andyz-dev/makefile-cleanup
Makefile cleanup
2019-05-02 07:18:27 +02:00
Andy Zhou
ba80a9113c Makefile: Add the install-tools target
ith a fresh checked out k3d tree without required tools installed, Any make command gives the following error message:

    Makefile:71: *** recipe commences before first target.  Stop.

Basically, the section around line 71 are not properly formed makefile rules. This error is hidden when required tools
are installed. The error can be re-exposed with the "make extra-clean" command.

The install-tools target is intended to be invoked when installing the development tree for the fist time.
2019-05-01 16:59:49 -07:00
Andy Zhou
6bb72b1fdc Makefile: Add extra-clean to help with testing Makefile
The extra-clean target removes the dependent packages that k3d requires. This makes testing
makefile rules that install those packages easier.

This target helps to expose a bug that the next patch fixes.
2019-05-01 16:56:05 -07:00
iwilltry42
942e667b24 add some comments 2019-04-29 08:19:01 +02:00
iwilltry42
5e28779339 Merge branch 'development' of https://github.com/rancher/k3d 2019-04-27 22:45:07 +02:00
Thorsten Klein
705ef69dd9
Merge pull request #12 from rancher/use-docker-sdk
Replace docker commands with docker sdk
2019-04-26 07:13:05 +02:00
iwilltry42
068172aa1a fix output order for logs 2019-04-23 15:20:06 +02:00
Thorsten Klein
ce4f9d238f
Merge pull request #16 from mmatur/fix/readme
Fix bad go get command in the readme
2019-04-23 12:37:09 +02:00
Michael
a906856e0a
fix readme 2019-04-23 12:16:50 +02:00
iwilltry42
e9206a74b2 make start/stop functions start/stop workers as well 2019-04-23 11:22:59 +02:00