Commit Graph

31 Commits

Author SHA1 Message Date
wxdao
c1263487a5 Upgrade docker sdk 2019-07-25 03:15:28 +00:00
iwilltry42
96c883a10a cleanup tools container using defer 2019-07-17 09:32:46 +02:00
iwilltry42
93fa5630ac create named volume 2019-07-03 16:51:41 +02:00
iwilltry42
ab2c54ca1d add import-image command for importing single image 2019-07-01 11:31:35 +02: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
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
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
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
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
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