111 Commits

Author SHA1 Message Date
iwilltry42
eac293a263
Overall: helper container images should always use same tag as CLI or fallback to latest 2020-06-18 09:01:04 +02:00
iwilltry42
76d90478f5
Go Module: use v3 for go module compatibility 2020-06-18 07:58:36 +02:00
iwilltry42
3cd1a05b91
Maintenance: move all labels to constants and fix log formatting issues 2020-06-12 19:00:01 +02:00
iwilltry42
2d0ec0a1d0
createNode: fix log output generating nil pointer...
... dereference in addNodeToCluster when cluster does not exist.
Fixes #277
2020-06-12 12:39:36 +02:00
iwilltry42
bdb5a1f858
getKubeconfig: fix condition when no overwriting contexts
Reference: https://github.com/rancher/k3d/pull/268#issuecomment-639829646
2020-06-10 19:20:02 +02:00
Antoine
0862f11324
👌 replace k3d getk3stoken command by --token flag onto command k3d get cluster 2020-06-04 00:56:02 +02:00
Antoine
e3bf18660e
👌 PR review
Use `log.Fatalln(err)` instead of `log.Errorln(err)` + `os.Exit(1)`
Use Label prefix instead of LabelName suffix
Rename all secret occurence with token
2020-06-04 00:49:12 +02:00
Antoine
6d9d5a0cc4
Add get k3stoken feature
Add new command verb `k3stoken` to `k3d get`
Populate cluster secret field
Add test for `k3d get k3stoken` command
Externalize validable flag `--all`, in anticipation to reuse into `getKubeConfig.go`
2020-06-04 00:49:12 +02:00
Antoine
f6eaf25a2e
♻️ Some side effect refactoring
Print usage When no k3d verb was specify
Replace fake Cluster object create into getKubeConfig by realy complete object obtain thanks to cluster.GetCluster() function
Use constant variable for node Label name use into populateClusterFieldsFromLabels() function, in forecast to rename label `k3d.cluster.secret` to `k3d.cluster.token`
2020-06-04 00:49:08 +02:00
iwilltry42
42ee62e552
createNode: add --wait and --timeout flags
- new struct: createNodeOpts for wait and timeout values
- new commands for creating/adding multiple nodes which then wait for
all nodes to be up, if specified
- tests/e2e: new test for adding a master node
2020-06-03 14:55:50 +02:00
iwilltry42
eeaa25dce6
WaitForNodeLogMessage: move default expected messages to constants 2020-06-03 14:16:09 +02:00
iwilltry42
ee8b34d9f6
createNode: do not copy '--cluster-init' when creating a new master node, as this will break the node 2020-06-03 13:40:13 +02:00
iwilltry42
b28f93d207
UpdateLoadbalancerConfig: deduplicate and warn if node is down
- getCluster: now deduplicates the node list (i.e. overwrites existing
nodes in the list with "fresh" nodes and appends new ones)
- UpdateLoadbalancerConfig: print warning if "host not found in
upstream" returned by nginx after updating the config, as it's not a
failure per se, but shouldn't be ignored
2020-06-03 12:52:10 +02:00
iwilltry42
f0d3389a1f
removeNode: update loadbalancer if master
- use idempotent UpdateKubeconfig which takes a fresh list of master
nodes and uses it to update the loadbalancer
- removeNode: use aforementioned function to update the loadbalancer
config when removing a master node
2020-06-02 20:03:42 +02:00
iwilltry42
477fe8b395
Merge branch 'master' of github.com:rancher/k3d into enhancement/use-context 2020-06-02 19:26:20 +02:00
iwilltry42
cf2c839b27
createNode: use default role label and cmd...
...if existing node does not match target role
Fixes #254
2020-05-29 14:03:51 +02:00
iwilltry42
d3766a5a1e
createCluster: also wait for loadbalancer to be up and running before returning 2020-05-29 12:33:22 +02:00
iwilltry42
4710f65b85
Merge branch 'master' of github.com:rancher/k3d into enhancement/use-context 2020-05-29 11:42:47 +02:00
iwilltry42
99f5a6884a
getNodeLogs: accept time.Time parameter
- fixes startCluster's --wait/--timeout functionality
--> now doesn't check all the logs (e.g. from previous run)
----> no more false positives when checking for a specifc log message
only in the current run
2020-05-29 11:21:12 +02:00
iwilltry42
b6e3babb4a
fix: move waiting out of loop (which caused early context cancelation issues) 2020-05-28 14:32:09 +02:00
iwilltry42
332c3a8c9b
startCluster: add --wait and --timeout
- functionality mostly copy-pasted from createCluster
2020-05-28 13:53:20 +02:00
iwilltry42
ba431c6235
Merge branch 'master' of github.com:rancher/k3d into enhancement/use-context 2020-05-26 14:49:45 +02:00
iwilltry42
434cf8e91d
overall: pass context from top to bottom 2020-05-26 14:47:21 +02:00
iwilltry42
21fd427d8a
maintenance: cleanup debug logs 2020-05-26 14:14:55 +02:00
iwilltry42
639daef7fb
Reorder parameters
- runtimes.Runtime should at max. the second function parameter (right
after context.Context)
2020-05-26 12:58:43 +02:00
iwilltry42
0d2c22455d
Overall: use context.Context in top-level exported functions
- package cluster: use context.Context as first function param in every
exported function
- package cmd: pass cmd.Context() to calls to package cluster exported
functions
2020-05-18 12:57:59 +02:00
iwilltry42
fe21c27a32
createNode: add failover solution to get K3S_URL value 2020-05-11 11:32:30 +02:00
iwilltry42
ee8fe0bb35
createNode: add failover solution to get K3S_URL value 2020-05-11 11:32:00 +02:00
iwilltry42
9c9f49646e
MasterLoadBalancer: add nodefilter & extra treatment
- masterlb is now an extra part of the cluster spec
- ports can now be attached to masterlb by using the 'loadbalancer'
nodefilter
- all ports exposed on the masterlb will be proxied to all master nodes
(on the same port)
2020-05-11 10:57:54 +02:00
iwilltry42
4bfac51c7c
createCluster/createNode: use K3S_URL instead of --server 2020-05-11 09:17:48 +02:00
iwilltry42
c061104b53
createNode: copy as many details as possible from existing
- we now use the full containerJSON details when getting a node
- we now use as many details as possible to copy k3d settings from an
existing node when adding a new node to a running cluster
2020-05-11 08:42:44 +02:00
iwilltry42
da8adf5469
createNode: update nginx masterlb with new master node
- if --role=master, update nginx config and reload it
2020-05-09 15:11:06 +02:00
iwilltry42
b7b8f6a5a6
createNode: use any node as blueprint
- if no node with the target role exists in the cluster, just choose any
other (non-proxy) node instead
- to make this work, we also need to add the k3s url label to every node
2020-05-09 14:12:29 +02:00
iwilltry42
3071ec5755
createCluster: add --no-lb flag to disable the load balancer
- does not create the load balancer node
- exposes the API port on the first master node (master-0)
2020-05-09 13:02:02 +02:00
iwilltry42
c6564801f3
getKubeconfig: always return output filepath 2020-05-04 18:26:59 +02:00
iwilltry42
0cdce098bd
createCluster: do not create masterlb if hostnetwork is selected to avoid port collisions 2020-05-04 14:19:30 +02:00
iwilltry42
dec8043edf
createCluster: add masterlb to list of nodes, so it will be considered during rollback 2020-05-04 07:42:45 +02:00
iwilltry42
edeea4540b
getKubeConfig: create output directory path if not exists 2020-05-04 07:32:52 +02:00
iwilltry42
3b77ecd6dd
getLogs: return error if container is not in running state to avoid long unnecessary wait 2020-04-26 17:17:14 +02:00
iwilltry42
2d68ef12e4
deleteCluster: remove cluster details from kubeconfig
- refactoring in pkg/cluster/kubeconfig
- new functions to delete a cluster from kubeconfig
- call RemoveClusterFromDefaultKubeConfig after deleting cluster
2020-04-24 14:44:21 +02:00
iwilltry42
5b637126d7
createCluster: add --update-kubeconfig flag
- enables wait-for-master
- calls GetAndWriteKubeConfig after successful cluster creation to
  update the default kubeconfig with the new cluster's details
- does NOT automatically switch the current-context
- outputs a different line saying, that you can switch context now
2020-04-24 14:02:38 +02:00
iwilltry42
6677f82d5b
getKubeConfig: consider the KUBECONFIG env var when updating default kubeconfig 2020-04-24 07:52:23 +02:00
iwilltry42
cec907e1f3
set current context if empty 2020-04-23 12:01:20 +02:00
iwilltry42
5121ef80a5
create/start/stop cluster: fix how Master-LoadBalancer is treated
- always include the k3d.role label and use LoadBalancerRole for
masterlb
- start masterlb last when starting a stopped cluster so it won't fail
2020-04-22 13:18:26 +02:00
iwilltry42
d9e0e0f914
getKubeConfig: update existing kubeconfigs 2020-04-20 19:16:00 +02:00
iwilltry42
407fcd4e1f
rename to UpdateKubeConfig 2020-04-20 17:22:56 +02:00
iwilltry42
fc1b858325
getKubeConfig: add functionality to update an existing KubeConfig 2020-04-20 10:35:43 +02:00
iwilltry42
df07358f47
getKubeconfig: fix: update context with new authInfo and cluster names 2020-04-16 12:35:37 +02:00
iwilltry42
2a76bba98b
getKubeconfig: modify kubeconfig as an object
Before this change, we simply did a search/replace on the
stringified kubeconfig blob.
Now we're parsing it into a kubeconfig struct and modify the fields
directly in a more controlled manner.
Here's what we change:
- server URL: based on the chosen APIHost and APIPort
- cluster name: default -> k3d-CLUSTERNAME
- user name: default -> admin@k3d-CLUSTERNAME
- context name: default -> admin@k3d-CLUSTERNAME
2020-04-16 11:42:57 +02:00
iwilltry42
469d8ab62d
use default value for apiPort 2020-04-16 09:49:03 +02:00