cmd.Flags().StringP("image","i",fmt.Sprintf("%s:%s",k3d.DefaultK3sImageRepo,version.GetK3sVersion(false)),"Specify k3s image that you want to use for the nodes")
cmd.Flags().StringP("image","i",fmt.Sprintf("%s:%s",k3d.DefaultK3sImageRepo,version.GetK3sVersion(false)),"Specify k3s image that you want to use for the nodes")
cmd.Flags().String("network","","Join an existing network")
cmd.Flags().String("network","","Join an existing network")
cmd.Flags().String("token","","Specify a cluster token. By default, we generate one.")
cmd.Flags().String("token","","Specify a cluster token. By default, we generate one.")
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]\"`")
cmd.Flags().StringArrayP("port","p",nil,"Map ports from the node containers 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 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().BoolVar(&createClusterOpts.WaitForServer,"wait",true,"Wait for the server(s) to be ready before returning. Use '--timeout DURATION' to not wait forever.")
cmd.Flags().BoolVar(&createClusterOpts.WaitForServer,"wait",true,"Wait for the server(s) to be ready before returning. Use '--timeout DURATION' to not wait forever.")
cmd.Flags().DurationVar(&createClusterOpts.Timeout,"timeout",0*time.Second,"Rollback changes if cluster couldn't be created in specified duration.")
cmd.Flags().DurationVar(&createClusterOpts.Timeout,"timeout",0*time.Second,"Rollback changes if cluster couldn't be created in specified duration.")
cmd.Flags().BoolVar(&updateDefaultKubeconfig,"update-default-kubeconfig",true,"Directly update the default kubeconfig with the new cluster's context")
cmd.Flags().BoolVar(&updateDefaultKubeconfig,"update-default-kubeconfig",true,"Directly update the default kubeconfig with the new cluster's context")
- `--api-port 6550` is not required for the example to work. It's used to have `k3s`'s API-Server listening on port 6550 with that port mapped to the host system.
- `--api-port 6550` is not required for the example to work. It's used to have `k3s`'s API-Server listening on port 6550 with that port mapped to the host system.
@ -56,11 +56,11 @@ 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
1. Create a cluster, mapping the port 30080 from agent-0 to localhost:8082
- **Note**: Kubernetes' default NodePort range is [`30000-32767`](https://kubernetes.io/docs/concepts/services-networking/service/#nodeport)
- **Note**: Kubernetes' default NodePort range is [`30000-32767`](https://kubernetes.io/docs/concepts/services-networking/service/#nodeport)
- **Note**: 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**: 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))
This file is a regular [k3s registries configuration file](https://rancher.com/docs/k3s/latest/en/installation/private-registry/), and looks like this:
This file is a regular [k3s registries configuration file](https://rancher.com/docs/k3s/latest/en/installation/private-registry/), and looks like this:
@ -61,7 +61,7 @@ configs:
Finally, we can create the cluster, mounting the CA file in the path we specified in `ca_file`:
Finally, we can create the cluster, mounting the CA file in the path we specified in `ca_file`: