Commit Graph

370 Commits

Author SHA1 Message Date
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
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
Thorsten Klein
ba231f550d
Merge pull request #56 from andyz-dev/list-all
[Enhancement] Make list command always show all clusters. Remove --all option
2019-05-19 13:27:54 +02:00
Andy Zhou
01931b5894 Make list command always show all clusters. Remove --all option
It feels more natural to have the list command show all clusters by
default.
2019-05-18 22:25:24 -07:00
Andy Zhou
cb1daebe41
Merge pull request #52 from andyz-dev/rename
[Enhancement] Rename cli/config.go to cli/cluster.go
2019-05-16 23:52:07 -07:00
Andy Zhou
1a2e961a52
Merge pull request #51 from andyz-dev/makefile
[Enhancement] Makefile: Add lint target and factor the check target
2019-05-16 23:51:44 -07:00
Andy Zhou
abfd6bd18a Makefile: Add lint target and factor the check target 2019-05-16 23:37:46 -07:00
Andy Zhou
10c6eeeea5 Rename cli/config.go to cli/cluster.go
Config.go mainly contains functions around the cluster data structure. Rename
the file to cluster.go
2019-05-16 20:07:09 -07:00
Andy Zhou
89d51a0abc
Merge pull request #49 from andyz-dev/makefile
[Enhancement] Makefile
2019-05-16 00:21:50 -07:00
Andy Zhou
c3c8f0d6f8 Golang format clean up
Changes made by 'make fmt'.
2019-05-16 00:02:10 -07:00
Andy Zhou
ae6c886364 Makefile: Fix SRC defintion
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.
2019-05-16 00:01:47 -07:00
iwilltry42
a3d9f700f8 wording 2019-05-16 08:16:57 +02:00
iwilltry42
4599310da4 add FAQ section 2019-05-16 07:32:44 +02:00
Andy Zhou
62f7071ee5
Merge pull request #40 from andyz-dev/reclaim-volumes
[Enhancement] Automatically reclaim k3s container volumes after a cluster is deleted
2019-05-15 15:42:16 -07:00
Andy Zhou
cd2292ba3a Automatically reclaim k3s container volumes after a cluster is deleted
Thanks @zeerorg for the suggestion on possible container volume leak.

With out this fix the k3s container volumes are left in the reclaimable
state. This experiment confirms it:

$ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              14                  0                   2.131GB             2.131GB (100%)
Containers          0                   0                   0B                  0B
Local Volumes       0                   0                   0B                  0B
Build Cache         0                   0                   0B                  0B

$ bin/k3d create; sleep 5; bin/k3d delete

$ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              14                  0                   2.131GB             2.131GB (100%)
Containers          0                   0                   0B                  0B
Local Volumes       3                   0                   2.366MB             2.366MB (100%)
Build Cache         0                   0                   0B                  0B

In this case, 2.36MB are left in the reclaimable state. This number can be
larger with a larger cluster.

With this fix, output of "docker system df" does not contain the
claimable volume
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              14                  0                   2.131GB             2.131GB (100%)
Containers          0                   0                   0B                  0B
Local Volumes       0                   0                   0B                  0B
Build Cache         0                   0                   0B                  0B
2019-05-15 15:27:47 -07:00
Thorsten Klein
6e1b865f0c
Merge pull request #47 from andyz-dev/Bug42
[bugfix] Bug42
2019-05-15 20:40:11 +02:00
Andy Zhou
3c3c72b4af Check for cluster existence before using a name to create a new cluster
This change improve the error message. It also avoids the tricky situation of
potentially destroying an existing clusters when the same name cluster
creation fails. For more details see issue #42.
2019-05-15 09:56:48 -07:00
Andy Zhou
b48debb176 Refactor getClusters() to make the API easier to use
Simplify the caller of this function in the code base. Also remove
getCluster() since there is no caller of this function any more.
2019-05-15 09:56:48 -07:00
Andy Zhou
dbc93f6818
Merge pull request #46 from andyz-dev/volume
[Enhancement] Allow the volume argument to be specified multiple times
2019-05-15 09:44:23 -07:00
Andy Zhou
a0eb69b73e Allow the volume argument to be specified multiple times
Most k3d arguments are using in "stringSlice" style, allowing the
argument to supplied multiple times. Currently "volume" is an exception
to this style, require multiple arguments to be supplied in a single
argument, separated by comma.

This commit improve the k3d usability by improve the consistency of its
argument style.
2019-05-15 09:35:07 -07:00
iwilltry42
07febe44c0 better readability 2019-05-15 08:40:48 +02:00
iwilltry42
396e4dd196 add exposing to readme 2019-05-15 08:36:36 +02:00
Thorsten Klein
8d70dd261c
Merge pull request #43 from rancher/feature/enhanced-port-mapping
[Feature] Enhanced port mapping (node-specifiers, optional offset, ...)
2019-05-15 08:05:23 +02:00
iwilltry42
6823470ef5 don't allow empty node-specifiers 2019-05-15 07:11:06 +02:00
iwilltry42
8512ac0c8a make server the default node for portmaps 2019-05-14 20:48:48 +02:00
iwilltry42
2640fc13ce make server the default node for portmaps 2019-05-14 16:44:47 +02:00
iwilltry42
c5f410d5ef Merge branch 'master' of https://github.com/rancher/k3d into feature/enhanced-port-mapping 2019-05-14 14:40:16 +02:00
iwilltry42
6d0fc76b22 improve portspec and ndoespec validation 2019-05-14 14:27:30 +02:00
iwilltry42
464d2e23c5 Offset multiplication 2019-05-14 13:13:56 +02:00
iwilltry42
107700dc98 update log messages 2019-05-14 13:12:10 +02:00
iwilltry42
a68d9e7042 generate container names in a func and use it to determine if node-specifier is valid 2019-05-14 11:33:10 +02:00
Thorsten Klein
17fe64147f
Merge pull request #45 from andyz-dev/list-output
[Enhancement] Improve the output of the k3d list command.
2019-05-14 09:58:54 +02:00
Andy Zhou
4674a5d6c8 Improve cluster status display
Before this change, k3d list stopped cluster as "exited", This patch
change it to "stopped".

$ k3d create -n test
$ k3d stop -n test
$ k3d list --all

+------+------------------------------+--------+---------+
| NAME |            IMAGE             | STATUS | WORKERS |
+------+------------------------------+--------+---------+
| test | docker.io/rancher/k3s:v0.5.0 | exited |   0/0   |
+------+------------------------------+--------+---------+

Before this change, k3d report the server status as the cluster status.
This commit output the server status if the server and all worker
containers status agree. Otherwise, the cluster status is reported as "unhealthy".

$ k3d create --workers 2
$ docker ps -a

d14135f5929c        rancher/k3s:v0.5.0   "/bin/k3s agent"         6 seconds ago       Up 5 seconds                                        k3d-k3s-default-worker-1
612d71f3ec23        rancher/k3s:v0.5.0   "/bin/k3s agent"         6 seconds ago       Up 5 seconds                                        k3d-k3s-default-worker-0
7f201731bf45        rancher/k3s:v0.5.0   "/bin/k3s server --h…"   7 seconds ago       Up 6 seconds               0.0.0.0:6443->6443/tcp   k3d-k3s-default-server

$ docker stop d14135f5929c

$ bin/k3d list --all

+-------------+------------------------------+-----------+---------+
|    NAME     |            IMAGE             |  STATUS   | WORKERS |
+-------------+------------------------------+-----------+---------+
| k3s-default | docker.io/rancher/k3s:v0.5.0 | unhealthy |   1/2   |
+-------------+------------------------------+-----------+---------+
2019-05-13 21:16:19 -07:00
Andy Zhou
6292c89ec4 Minor simplification of getCluster()
This make the code easier to read.
2019-05-13 21:12:24 -07:00
Andy Zhou
953578ed11 Avoid output an empty table when no cluster to list
Before this patch:

$ k3d create
$ k3d stop
$ k3d list

+------+-------+--------+---------+
| NAME | IMAGE | STATUS | WORKERS |
+------+-------+--------+---------+
+------+-------+--------+---------+

This commit omits such empty table.
2019-05-13 21:10:38 -07:00
iwilltry42
f77d67aaf0 Merge branch 'master' of https://github.com/rancher/k3d into new-publish 2019-05-13 09:10:11 +02:00
Thorsten Klein
3a2eeba9b1
Merge pull request #41 from andyz-dev/center-align
[Enhancement] Center align list output
2019-05-13 09:10:04 +02:00