diff --git a/cmd/cluster/clusterCreate.go b/cmd/cluster/clusterCreate.go index c238a736..543084d7 100644 --- a/cmd/cluster/clusterCreate.go +++ b/cmd/cluster/clusterCreate.go @@ -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")) /****************** diff --git a/cmd/debug/debug.go b/cmd/debug/debug.go index c524790b..19a58b6a 100644 --- a/cmd/debug/debug.go +++ b/cmd/debug/debug.go @@ -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]}) diff --git a/docs/usage/commands/k3d_cluster_create.md b/docs/usage/commands/k3d_cluster_create.md index f784462d..e0969db9 100644 --- a/docs/usage/commands/k3d_cluster_create.md +++ b/docs/usage/commands/k3d_cluster_create.md @@ -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) ``` diff --git a/docs/usage/configfile.md b/docs/usage/configfile.md index 97fa45c0..4f5178fd 100644 --- a/docs/usage/configfile.md +++ b/docs/usage/configfile.md @@ -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: diff --git a/docs/usage/guides/exposing_services.md b/docs/usage/guides/exposing_services.md index 07b4cc7b..33b0d379 100644 --- a/docs/usage/guides/exposing_services.md +++ b/docs/usage/guides/exposing_services.md @@ -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) ... diff --git a/pkg/config/v1alpha3/migrations.go b/pkg/config/v1alpha3/migrations.go index fd1bc6dc..b1068de3 100644 --- a/pkg/config/v1alpha3/migrations.go +++ b/pkg/config/v1alpha3/migrations.go @@ -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:*", }, }) } diff --git a/pkg/config/v1alpha3/schema.json b/pkg/config/v1alpha3/schema.json index 1deb0060..f04bf00e 100644 --- a/pkg/config/v1alpha3/schema.json +++ b/pkg/config/v1alpha3/schema.json @@ -257,7 +257,7 @@ "examples": [ "loadbalancer", "server[*]", - "server[0]", + "server:0", "agent[1]", "all" ]