document using new nodefilter syntax with : instead of [] for indexing
This commit is contained in:
parent
edfd54c6d5
commit
d41b49d423
@ -295,23 +295,23 @@ func NewCmdClusterCreate() *cobra.Command {
|
||||
cmd.Flags().String("api-port", "", "Specify the Kubernetes API server port exposed on the LoadBalancer (Format: `[HOST:]HOSTPORT`)\n - Example: `k3d cluster create --servers 3 --api-port 0.0.0.0:6550`")
|
||||
_ = ppViper.BindPFlag("cli.api-port", cmd.Flags().Lookup("api-port"))
|
||||
|
||||
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]\"`")
|
||||
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\"`")
|
||||
_ = ppViper.BindPFlag("cli.env", cmd.Flags().Lookup("env"))
|
||||
|
||||
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]`")
|
||||
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`")
|
||||
_ = ppViper.BindPFlag("cli.volumes", cmd.Flags().Lookup("volume"))
|
||||
|
||||
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]`")
|
||||
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]`")
|
||||
_ = ppViper.BindPFlag("cli.ports", cmd.Flags().Lookup("port"))
|
||||
|
||||
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]\"`")
|
||||
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\"`")
|
||||
_ = ppViper.BindPFlag("cli.k3s-node-labels", cmd.Flags().Lookup("k3s-node-label"))
|
||||
|
||||
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]\"`")
|
||||
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\"`")
|
||||
_ = ppViper.BindPFlag("cli.runtime-labels", cmd.Flags().Lookup("runtime-label"))
|
||||
|
||||
/* k3s */
|
||||
cmd.Flags().StringArray("k3s-arg", nil, "Additional args passed to k3s command (Format: `ARG@NODEFILTER[;@NODEFILTER]`)\n - Example: `k3d cluster create --k3s-arg \"--disable=traefik@server[0]\"")
|
||||
cmd.Flags().StringArray("k3s-arg", nil, "Additional args passed to k3s command (Format: `ARG@NODEFILTER[;@NODEFILTER]`)\n - Example: `k3d cluster create --k3s-arg \"--disable=traefik@server:0\"")
|
||||
_ = cfgViper.BindPFlag("cli.k3sargs", cmd.Flags().Lookup("k3s-arg"))
|
||||
|
||||
/******************
|
||||
|
@ -67,7 +67,7 @@ func NewCmdDebugLoadbalancer() *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.AddCommand(&cobra.Command{
|
||||
Use: "get-config",
|
||||
Use: "get-config CLUSTERNAME",
|
||||
Args: cobra.ExactArgs(1), // cluster name
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
c, err := client.ClusterGet(cmd.Context(), runtimes.SelectedRuntime, &types.Cluster{Name: args[0]})
|
||||
|
@ -25,23 +25,23 @@ k3d cluster create NAME [flags]
|
||||
- Example: `k3d cluster create --servers 3 --api-port 0.0.0.0:6550`
|
||||
-c, --config string Path of a config file to use
|
||||
-e, --env KEY[=VALUE][@NODEFILTER[;NODEFILTER...]] Add environment variables to nodes (Format: KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]
|
||||
- Example: `k3d cluster create --agents 2 -e "HTTP_PROXY=my.proxy.com@server[0]" -e "SOME_KEY=SOME_VAL@server[0]"`
|
||||
- Example: `k3d cluster create --agents 2 -e "HTTP_PROXY=my.proxy.com@server:0" -e "SOME_KEY=SOME_VAL@server:0"`
|
||||
--gpus string GPU devices to add to the cluster node containers ('all' to pass all GPUs) [From docker]
|
||||
-h, --help help for create
|
||||
-i, --image string Specify k3s image that you want to use for the nodes
|
||||
--k3s-arg ARG@NODEFILTER[;@NODEFILTER] Additional args passed to k3s command (Format: ARG@NODEFILTER[;@NODEFILTER])
|
||||
- Example: `k3d cluster create --k3s-arg "--disable=traefik@server[0]"
|
||||
- Example: `k3d cluster create --k3s-arg "--disable=traefik@server:0"
|
||||
--kubeconfig-switch-context Directly switch the default kubeconfig's current-context to the new cluster's context (requires --kubeconfig-update-default) (default true)
|
||||
--kubeconfig-update-default Directly update the default kubeconfig with the new cluster's context (default true)
|
||||
-l, --label KEY[=VALUE][@NODEFILTER[;NODEFILTER...]] Add label to node container (Format: KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]
|
||||
- Example: `k3d cluster create --agents 2 -l "my.label@agent[0,1]" -l "other.label=somevalue@server[0]"`
|
||||
- Example: `k3d cluster create --agents 2 -l "my.label@agent[0,1]" -l "other.label=somevalue@server:0"`
|
||||
--network string Join an existing network
|
||||
--no-hostip Disable the automatic injection of the Host IP as 'host.k3d.internal' into the containers and CoreDNS
|
||||
--no-image-volume Disable the creation of a volume for importing images
|
||||
--no-lb Disable the creation of a LoadBalancer in front of the server nodes
|
||||
--no-rollback Disable the automatic rollback actions, if anything goes wrong
|
||||
-p, --port [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER] Map ports from the node containers to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])
|
||||
- Example: `k3d cluster create --agents 2 -p 8080:80@agent[0] -p 8081@agent[1]`
|
||||
- Example: `k3d cluster create --agents 2 -p 8080:80@agent:0 -p 8081@agent[1]`
|
||||
--registry-config string Specify path to an extra registries.yaml file
|
||||
--registry-create Create a k3d-managed registry and connect it to the cluster
|
||||
--registry-use stringArray Connect to one or more k3d-managed registries running locally
|
||||
@ -51,7 +51,7 @@ k3d cluster create NAME [flags]
|
||||
--timeout duration Rollback changes if cluster couldn't be created in specified duration.
|
||||
--token string Specify a cluster token. By default, we generate one.
|
||||
-v, --volume [SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]] Mount volumes into the nodes (Format: [SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]
|
||||
- Example: `k3d cluster create --agents 2 -v /my/path@agent[0,1] -v /tmp/test:/tmp/other@server[0]`
|
||||
- Example: `k3d cluster create --agents 2 -v /my/path@agent[0,1] -v /tmp/test:/tmp/other@server:0`
|
||||
--wait Wait for the server(s) to be ready before returning. Use '--timeout DURATION' to not wait forever. (default true)
|
||||
```
|
||||
|
||||
|
@ -19,7 +19,7 @@ Using a config file is as easy as putting it in a well-known place in your file
|
||||
|
||||
- All options in config file: `k3d cluster create --config /home/me/my-awesome-config.yaml` (must be `.yaml`/`.yml`)
|
||||
- With CLI override (name): `k3d cluster create somename --config /home/me/my-awesome-config.yaml`
|
||||
- With CLI override (extra volume): `k3d cluster create --config /home/me/my-awesome-config.yaml --volume '/some/path:/some:path@server[0]'`
|
||||
- With CLI override (extra volume): `k3d cluster create --config /home/me/my-awesome-config.yaml --volume '/some/path:/some:path@server:0'`
|
||||
|
||||
## Required Fields
|
||||
|
||||
@ -64,9 +64,9 @@ image: rancher/k3s:v1.20.4-k3s1 # same as `--image rancher/k3s:v1.20.4-k3s1`
|
||||
network: my-custom-net # same as `--network my-custom-net`
|
||||
token: superSecretToken # same as `--token superSecretToken`
|
||||
volumes: # repeatable flags are represented as YAML lists
|
||||
- volume: /my/host/path:/path/in/node # same as `--volume '/my/host/path:/path/in/node@server[0];agent[*]'`
|
||||
- volume: /my/host/path:/path/in/node # same as `--volume '/my/host/path:/path/in/node@server:0;agent[*]'`
|
||||
nodeFilters:
|
||||
- server[0]
|
||||
- server:0
|
||||
- agent[*]
|
||||
ports:
|
||||
- port: 8080:80 # same as `--port '8080:80@loadbalancer'`
|
||||
@ -77,9 +77,9 @@ labels:
|
||||
nodeFilters:
|
||||
- agent[1]
|
||||
env:
|
||||
- envVar: bar=baz # same as `--env 'bar=baz@server[0]'`
|
||||
- envVar: bar=baz # same as `--env 'bar=baz@server:0'`
|
||||
nodeFilters:
|
||||
- server[0]
|
||||
- server:0
|
||||
registries: # define how registries should be created or used
|
||||
create: true # creates a default registry to be used with the cluster; same as `--registry-create`
|
||||
use:
|
||||
|
@ -62,10 +62,10 @@ Therefore, we have to create the cluster in a way, that the internal port 80 (wh
|
||||
|
||||
1. Create a cluster, mapping the port `30080` from `agent-0` to `localhost:8082`
|
||||
|
||||
`#!bash k3d cluster create mycluster -p "8082:30080@agent[0]" --agents 2`
|
||||
`#!bash k3d cluster create mycluster -p "8082:30080@agent:0" --agents 2`
|
||||
|
||||
- **Note 1**: Kubernetes' default NodePort range is [`30000-32767`](https://kubernetes.io/docs/concepts/services-networking/service/#nodeport)
|
||||
- **Note 2**: You may as well expose the whole NodePort range from the very beginning, e.g. via `k3d cluster create mycluster --agents 3 -p "30000-32767:30000-32767@server[0]"` (See [this video from @portainer](https://www.youtube.com/watch?v=5HaU6338lAk))
|
||||
- **Note 2**: You may as well expose the whole NodePort range from the very beginning, e.g. via `k3d cluster create mycluster --agents 3 -p "30000-32767:30000-32767@server:0"` (See [this video from @portainer](https://www.youtube.com/watch?v=5HaU6338lAk))
|
||||
- **Warning**: Docker creates iptable entries and a new proxy process per port-mapping, so this may take a very long time or even freeze your system!
|
||||
|
||||
... (Steps 2 and 3 like above) ...
|
||||
|
@ -64,7 +64,7 @@ func MigrateV1Alpha2(input configtypes.Config) (configtypes.Config, error) {
|
||||
cfg.Options.K3sOptions.ExtraArgs = append(cfg.Options.K3sOptions.ExtraArgs, K3sArgWithNodeFilters{
|
||||
Arg: arg,
|
||||
NodeFilters: []string{
|
||||
"server[*]",
|
||||
"server:*",
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -73,7 +73,7 @@ func MigrateV1Alpha2(input configtypes.Config) (configtypes.Config, error) {
|
||||
cfg.Options.K3sOptions.ExtraArgs = append(cfg.Options.K3sOptions.ExtraArgs, K3sArgWithNodeFilters{
|
||||
Arg: arg,
|
||||
NodeFilters: []string{
|
||||
"agent[*]",
|
||||
"agent:*",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -257,7 +257,7 @@
|
||||
"examples": [
|
||||
"loadbalancer",
|
||||
"server[*]",
|
||||
"server[0]",
|
||||
"server:0",
|
||||
"agent[1]",
|
||||
"all"
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user