Commit Graph

20 Commits

Author SHA1 Message Date
Andy Zhou
abfd6bd18a Makefile: Add lint target and factor the check target 2019-05-16 23:37:46 -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
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
iwilltry42
a0c0c3ff9d add --api-port and --port-auto-offset 2019-05-13 09:08:32 +02:00
iwilltry42
0670a0e11b resovle conflicts 2019-05-13 07:53:23 +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
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
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
942e667b24 add some comments 2019-04-29 08:19:01 +02:00
iwilltry42
6c072fb6d9 connect workers and server via own docker network 2019-04-18 16:08:15 +02:00
iwilltry42
7d5964c3b9 fix image not being pulled if reader is not being used 2019-04-18 14:42:41 +02:00
iwilltry42
b0b08d2119 bring back env vars, enable booting workers and base list output on docker data instead of dirs 2019-04-16 11:12:05 +02:00
iwilltry42
7eec5b061b use docker sdk wherever possible 2019-04-15 15:48:43 +02:00