Skip to content

Commit a5c1d3b

Browse files
authored
[Enhancement] Docs: update for v5 (first iteration) (#682)
1 parent 760bcae commit a5c1d3b

17 files changed

+252
-47
lines changed

cmd/cluster/clusterCreate.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,16 @@ func NewCmdClusterCreate() *cobra.Command {
298298
cmd.Flags().StringArrayP("env", "e", nil, "Add environment variables to nodes (Format: `KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]`\n - Example: `k3d cluster create --agents 2 -e \"HTTP_PROXY=my.proxy.com@server:0\" -e \"SOME_KEY=SOME_VAL@server:0\"`")
299299
_ = ppViper.BindPFlag("cli.env", cmd.Flags().Lookup("env"))
300300

301-
cmd.Flags().StringArrayP("volume", "v", nil, "Mount volumes into the nodes (Format: `[SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]`\n - Example: `k3d cluster create --agents 2 -v /my/path@agent[0,1] -v /tmp/test:/tmp/other@server:0`")
301+
cmd.Flags().StringArrayP("volume", "v", nil, "Mount volumes into the nodes (Format: `[SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]`\n - Example: `k3d cluster create --agents 2 -v /my/path@agent:0,1 -v /tmp/test:/tmp/other@server:0`")
302302
_ = ppViper.BindPFlag("cli.volumes", cmd.Flags().Lookup("volume"))
303303

304-
cmd.Flags().StringArrayP("port", "p", nil, "Map ports from the node containers (via the serverlb) to the host (Format: `[HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]`)\n - Example: `k3d cluster create --agents 2 -p 8080:80@agent:0 -p 8081@agent[1]`")
304+
cmd.Flags().StringArrayP("port", "p", nil, "Map ports from the node containers (via the serverlb) to the host (Format: `[HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]`)\n - Example: `k3d cluster create --agents 2 -p 8080:80@agent:0 -p 8081@agent:1`")
305305
_ = ppViper.BindPFlag("cli.ports", cmd.Flags().Lookup("port"))
306306

307-
cmd.Flags().StringArrayP("k3s-node-label", "", nil, "Add label to k3s node (Format: `KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]`\n - Example: `k3d cluster create --agents 2 --k3s-node-label \"my.label@agent[0,1]\" --k3s-node-label \"other.label=somevalue@server:0\"`")
307+
cmd.Flags().StringArrayP("k3s-node-label", "", nil, "Add label to k3s node (Format: `KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]`\n - Example: `k3d cluster create --agents 2 --k3s-node-label \"my.label@agent:0,1\" --k3s-node-label \"other.label=somevalue@server:0\"`")
308308
_ = ppViper.BindPFlag("cli.k3s-node-labels", cmd.Flags().Lookup("k3s-node-label"))
309309

310-
cmd.Flags().StringArrayP("runtime-label", "", nil, "Add label to container runtime (Format: `KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]`\n - Example: `k3d cluster create --agents 2 --runtime-label \"my.label@agent[0,1]\" --runtime-label \"other.label=somevalue@server:0\"`")
310+
cmd.Flags().StringArrayP("runtime-label", "", nil, "Add label to container runtime (Format: `KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]`\n - Example: `k3d cluster create --agents 2 --runtime-label \"my.label@agent:0,1\" --runtime-label \"other.label=somevalue@server:0\"`")
311311
_ = ppViper.BindPFlag("cli.runtime-labels", cmd.Flags().Lookup("runtime-label"))
312312

313313
/* k3s */

docgen/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ The code will output files in [`../docs/usage/commands/`](../docs/usage/commands
66

77
## Run
88

9-
- may required a `replace github.com/rancher/k3d/v4 => PATH/TO/LOCAL/REPO` in the `go.mod`
10-
119
```bash
1210
# ensure that you're in the docgen dir, as the relative path to the docs/ dir is hardcoded
1311
cd docgen
1412

1513
# run
16-
go run ./main.go
14+
./run.sh
1715
```

docgen/go.mod

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ require (
1010
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
1111
github.com/google/gofuzz v1.2.0 // indirect
1212
github.com/rancher/k3d/v4 v4.4.7-0.20210709062205-c5f7884f7870
13-
github.com/spf13/cobra v1.1.3
13+
github.com/sirupsen/logrus v1.8.1
14+
github.com/spf13/cobra v1.2.1
1415
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 // indirect
1516
golang.org/x/oauth2 v0.0.0-20210413134643-5e61552d6c78 // indirect
1617
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 // indirect
1718
k8s.io/utils v0.0.0-20210305010621-2afb4311ab10 // indirect
1819
sigs.k8s.io/structured-merge-diff/v4 v4.1.1 // indirect
1920
)
21+
22+
replace github.com/rancher/k3d/v4 => /PATH/TO/YOUR/REPO/DIRECTORY

docgen/go.sum

+93-18
Large diffs are not rendered by default.

docgen/run.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
REPLACE_PLACEHOLDER="/PATH/TO/YOUR/REPO/DIRECTORY"
4+
5+
CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
[ -d "$CURR_DIR" ] || { echo "FATAL: no current dir (maybe running in zsh?)"; exit 1; }
7+
8+
REPO_DIR=${CURR_DIR%"/docgen"}
9+
10+
echo "$REPO_DIR"
11+
12+
sed -i "s%$REPLACE_PLACEHOLDER%$REPO_DIR%" "$CURR_DIR/go.mod"
13+
14+
go mod tidy
15+
16+
go mod vendor
17+
18+
go run ./main.go

docs/usage/commands/k3d_cluster.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ k3d cluster [flags]
2929
* [k3d](k3d.md) - https://k3d.io/ -> Run k3s in Docker!
3030
* [k3d cluster create](k3d_cluster_create.md) - Create a new cluster
3131
* [k3d cluster delete](k3d_cluster_delete.md) - Delete cluster(s).
32+
* [k3d cluster edit](k3d_cluster_edit.md) - [EXPERIMENTAL] Edit cluster(s).
3233
* [k3d cluster list](k3d_cluster_list.md) - List cluster(s)
3334
* [k3d cluster start](k3d_cluster_start.md) - Start existing k3d cluster(s)
3435
* [k3d cluster stop](k3d_cluster_stop.md) - Stop existing k3d cluster(s)

docs/usage/commands/k3d_cluster_create.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,29 @@ k3d cluster create NAME [flags]
3131
-i, --image string Specify k3s image that you want to use for the nodes
3232
--k3s-arg ARG@NODEFILTER[;@NODEFILTER] Additional args passed to k3s command (Format: ARG@NODEFILTER[;@NODEFILTER])
3333
- Example: `k3d cluster create --k3s-arg "--disable=traefik@server:0"
34+
--k3s-node-label KEY[=VALUE][@NODEFILTER[;NODEFILTER...]] Add label to k3s node (Format: KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]
35+
- Example: `k3d cluster create --agents 2 --k3s-node-label "my.label@agent:0,1" --k3s-node-label "other.label=somevalue@server:0"`
3436
--kubeconfig-switch-context Directly switch the default kubeconfig's current-context to the new cluster's context (requires --kubeconfig-update-default) (default true)
3537
--kubeconfig-update-default Directly update the default kubeconfig with the new cluster's context (default true)
36-
-l, --label KEY[=VALUE][@NODEFILTER[;NODEFILTER...]] Add label to node container (Format: KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]
37-
- Example: `k3d cluster create --agents 2 -l "my.label@agent[0,1]" -l "other.label=somevalue@server:0"`
3838
--network string Join an existing network
3939
--no-hostip Disable the automatic injection of the Host IP as 'host.k3d.internal' into the containers and CoreDNS
4040
--no-image-volume Disable the creation of a volume for importing images
4141
--no-lb Disable the creation of a LoadBalancer in front of the server nodes
4242
--no-rollback Disable the automatic rollback actions, if anything goes wrong
43-
-p, --port [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER] Map ports from the node containers to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])
44-
- Example: `k3d cluster create --agents 2 -p 8080:80@agent:0 -p 8081@agent[1]`
43+
-p, --port [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER] Map ports from the node containers (via the serverlb) to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])
44+
- Example: `k3d cluster create --agents 2 -p 8080:80@agent:0 -p 8081@agent:1`
4545
--registry-config string Specify path to an extra registries.yaml file
4646
--registry-create Create a k3d-managed registry and connect it to the cluster
4747
--registry-use stringArray Connect to one or more k3d-managed registries running locally
48+
--runtime-label KEY[=VALUE][@NODEFILTER[;NODEFILTER...]] Add label to container runtime (Format: KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]
49+
- Example: `k3d cluster create --agents 2 --runtime-label "my.label@agent:0,1" --runtime-label "other.label=somevalue@server:0"`
4850
-s, --servers int Specify how many servers you want to create
4951
--servers-memory string Memory limit imposed on the server nodes [From docker]
5052
--subnet 172.28.0.0/16 [Experimental: IPAM] Define a subnet for the newly created container network (Example: 172.28.0.0/16)
5153
--timeout duration Rollback changes if cluster couldn't be created in specified duration.
5254
--token string Specify a cluster token. By default, we generate one.
5355
-v, --volume [SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]] Mount volumes into the nodes (Format: [SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]
54-
- Example: `k3d cluster create --agents 2 -v /my/path@agent[0,1] -v /tmp/test:/tmp/other@server:0`
56+
- Example: `k3d cluster create --agents 2 -v /my/path@agent:0,1 -v /tmp/test:/tmp/other@server:0`
5557
--wait Wait for the server(s) to be ready before returning. Use '--timeout DURATION' to not wait forever. (default true)
5658
```
5759

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## k3d cluster edit
2+
3+
[EXPERIMENTAL] Edit cluster(s).
4+
5+
### Synopsis
6+
7+
[EXPERIMENTAL] Edit cluster(s).
8+
9+
```
10+
k3d cluster edit CLUSTER [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help help for edit
17+
--port-add [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER] [EXPERIMENTAL] Map ports from the node containers (via the serverlb) to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])
18+
- Example: `k3d node edit k3d-mycluster-serverlb --port-add 8080:80`
19+
```
20+
21+
### Options inherited from parent commands
22+
23+
```
24+
--timestamps Enable Log timestamps
25+
--trace Enable super verbose output (trace logging)
26+
--verbose Enable verbose output (debug logging)
27+
```
28+
29+
### SEE ALSO
30+
31+
* [k3d cluster](k3d_cluster.md) - Manage cluster(s)
32+

docs/usage/commands/k3d_completion.md

+40-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,48 @@ Generate completion scripts for [bash, zsh, fish, powershell | psh]
44

55
### Synopsis
66

7-
Generate completion scripts for [bash, zsh, fish, powershell | psh]
7+
To load completions:
8+
9+
Bash:
10+
11+
$ source <(k3d completion bash)
12+
13+
# To load completions for each session, execute once:
14+
# Linux:
15+
$ k3d completion bash > /etc/bash_completion.d/k3d
16+
# macOS:
17+
$ k3d completion bash > /usr/local/etc/bash_completion.d/k3d
18+
19+
Zsh:
20+
21+
# If shell completion is not already enabled in your environment,
22+
# you will need to enable it. You can execute the following once:
23+
24+
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
25+
26+
# To load completions for each session, execute once:
27+
$ k3d completion zsh > "${fpath[1]}/k3d"
28+
29+
# You will need to start a new shell for this setup to take effect.
30+
31+
fish:
32+
33+
$ k3d completion fish | source
34+
35+
# To load completions for each session, execute once:
36+
$ k3d completion fish > ~/.config/fish/completions/k3d.fish
37+
38+
PowerShell:
39+
40+
PS> k3d completion powershell | Out-String | Invoke-Expression
41+
42+
# To load completions for every new session, run:
43+
PS> k3d completion powershell > k3d.ps1
44+
# and source this file from your PowerShell profile.
45+
846

947
```
10-
k3d completion SHELL [flags]
48+
k3d completion SHELL
1149
```
1250

1351
### Options

docs/usage/commands/k3d_config_migrate.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
```
6-
k3d config migrate INPUT OUTPUT [flags]
6+
k3d config migrate INPUT [OUTPUT] [flags]
77
```
88

99
### Options

docs/usage/commands/k3d_node.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ k3d node [flags]
2929
* [k3d](k3d.md) - https://k3d.io/ -> Run k3s in Docker!
3030
* [k3d node create](k3d_node_create.md) - Create a new k3s node in docker
3131
* [k3d node delete](k3d_node_delete.md) - Delete node(s).
32+
* [k3d node edit](k3d_node_edit.md) - [EXPERIMENTAL] Edit node(s).
3233
* [k3d node list](k3d_node_list.md) - List node(s)
3334
* [k3d node start](k3d_node_start.md) - Start an existing k3d node
3435
* [k3d node stop](k3d_node_stop.md) - Stop an existing k3d node

docs/usage/commands/k3d_node_create.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ k3d node create NAME [flags]
2020
--memory string Memory limit imposed on the node [From docker]
2121
--replicas int Number of replicas of this node specification. (default 1)
2222
--role string Specify node role [server, agent] (default "agent")
23+
--runtime-label strings Specify container runtime labels in format "foo=bar"
2324
--timeout duration Maximum waiting time for '--wait' before canceling/returning.
24-
--wait Wait for the node(s) to be ready before returning.
25+
--wait Wait for the node(s) to be ready before returning. (default true)
2526
```
2627

2728
### Options inherited from parent commands

docs/usage/commands/k3d_node_edit.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## k3d node edit
2+
3+
[EXPERIMENTAL] Edit node(s).
4+
5+
### Synopsis
6+
7+
[EXPERIMENTAL] Edit node(s).
8+
9+
```
10+
k3d node edit NODE [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help help for edit
17+
--port-add [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER] [EXPERIMENTAL] (serverlb only!) Map ports from the node container to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])
18+
- Example: `k3d node edit k3d-mycluster-serverlb --port-add 8080:80`
19+
```
20+
21+
### Options inherited from parent commands
22+
23+
```
24+
--timestamps Enable Log timestamps
25+
--trace Enable super verbose output (trace logging)
26+
--verbose Enable verbose output (debug logging)
27+
```
28+
29+
### SEE ALSO
30+
31+
* [k3d node](k3d_node.md) - Manage node(s)
32+

docs/usage/commands/k3d_node_list.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ List node(s)
77
List node(s).
88

99
```
10-
k3d node list [NAME [NAME...]] [flags]
10+
k3d node list [NODE [NODE...]] [flags]
1111
```
1212

1313
### Options

docs/usage/commands/k3d_node_start.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Start an existing k3d node
77
Start an existing k3d node.
88

99
```
10-
k3d node start NAME [flags]
10+
k3d node start NODE [flags]
1111
```
1212

1313
### Options

docs/usage/configfile.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,14 @@ image: rancher/k3s:v1.20.4-k3s1 # same as `--image rancher/k3s:v1.20.4-k3s1`
6464
network: my-custom-net # same as `--network my-custom-net`
6565
token: superSecretToken # same as `--token superSecretToken`
6666
volumes: # repeatable flags are represented as YAML lists
67-
- volume: /my/host/path:/path/in/node # same as `--volume '/my/host/path:/path/in/node@server:0;agent[*]'`
67+
- volume: /my/host/path:/path/in/node # same as `--volume '/my/host/path:/path/in/node@server:0;agent:*'`
6868
nodeFilters:
6969
- server:0
70-
- agent[*]
70+
- agent:*
7171
ports:
7272
- port: 8080:80 # same as `--port '8080:80@loadbalancer'`
7373
nodeFilters:
7474
- loadbalancer
75-
labels:
76-
- label: foo=bar # same as `--label 'foo=bar@agent[1]'`
77-
nodeFilters:
78-
- agent[1]
7975
env:
8076
- envVar: bar=baz # same as `--env 'bar=baz@server:0'`
8177
nodeFilters:
@@ -101,12 +97,20 @@ options:
10197
extraArgs: # additional arguments passed to the `k3s server|agent` command; same as `--k3s-arg`
10298
- arg: --tls-san=my.host.domain
10399
nodeFilters:
104-
- server[*]
100+
- server:*
101+
nodeLabels:
102+
- label: foo=bar # same as `--k3s-node-label 'foo=bar@agent:1'` -> this results in a Kubernetes node label
103+
nodeFilters:
104+
- agent:1
105105
kubeconfig:
106106
updateDefaultKubeconfig: true # add new cluster to your default Kubeconfig; same as `--kubeconfig-update-default` (default: true)
107107
switchCurrentContext: true # also set current-context to the new cluster's context; same as `--kubeconfig-switch-context` (default: true)
108108
runtime: # runtime (docker) specific options
109109
gpuRequest: all # same as `--gpus all`
110+
labels:
111+
- label: bar=baz # same as `--runtime-label 'bar=baz@agent:1'` -> this results in a runtime (docker) container label
112+
nodeFilters:
113+
- agent:1
110114

111115
```
112116

pkg/config/v1alpha3/schema.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,11 @@
256256
},
257257
"examples": [
258258
"loadbalancer",
259-
"server[*]",
259+
"server:*",
260260
"server:0",
261-
"agent[1]",
261+
"agent:1",
262262
"all"
263263
]
264264
}
265265
}
266-
}
266+
}

0 commit comments

Comments
 (0)