cmd.Flags().BoolVar(&createClusterOpts.WaitForMaster,"wait",true,"Wait for the master(s) to be ready before returning. Use '--timeout DURATION' to not wait forever.")
cmd.Flags().BoolVar(&createClusterOpts.WaitForMaster,"wait",true,"Wait for the master(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",false,"Directly update the default kubeconfig with the new cluster's context")
cmd.Flags().BoolVar(&updateDefaultKubeconfig,"update-default-kubeconfig",false,"Directly update the default kubeconfig with the new cluster's context")
cmd.Flags().BoolVar(&updateCurrentContext,"switch",false,"Directly switch the default kubeconfig's current-context to the new cluster's context (implies --update-default-kubeconfig)")
cmd.Flags().BoolVar(&updateCurrentContext,"switch-context",false,"Directly switch the default kubeconfig's current-context to the new cluster's context (implies --update-default-kubeconfig)")
cmd.Flags().BoolVar(&createClusterOpts.DisableLoadBalancer,"no-lb",false,"Disable the creation of a LoadBalancer in front of the master nodes")
cmd.Flags().BoolVar(&createClusterOpts.DisableLoadBalancer,"no-lb",false,"Disable the creation of a LoadBalancer in front of the master nodes")
log.Fatalln("Failed to mark flag --output as filename")
log.Fatalln("Failed to mark flag --output as filename")
}
}
cmd.Flags().BoolVarP(&getKubeconfigFlags.targetDefault,"default-kubeconfig","d",false,fmt.Sprintf("Update the default kubeconfig ($KUBECONFIG or %s)",clientcmd.RecommendedHomeFile))
cmd.Flags().BoolVarP(&getKubeconfigFlags.targetDefault,"merge-default-kubeconfig","d",false,fmt.Sprintf("Merge into the default kubeconfig ($KUBECONFIG or %s)",clientcmd.RecommendedHomeFile))
cmd.Flags().BoolVarP(&writeKubeConfigOptions.UpdateExisting,"update","u",true,"Update conflicting fields in existing KubeConfig")
cmd.Flags().BoolVarP(&writeKubeConfigOptions.UpdateExisting,"update","u",true,"Update conflicting fields in existing kubeconfig")
cmd.Flags().BoolVarP(&writeKubeConfigOptions.UpdateCurrentContext,"switch","s",true,"Switch to new context")
cmd.Flags().BoolVarP(&writeKubeConfigOptions.UpdateCurrentContext,"switch-context","s",true,"Switch to new context")
cmd.Flags().BoolVar(&writeKubeConfigOptions.OverwriteExisting,"overwrite",false,"[Careful!] Overwrite existing file, ignoring its contents")
cmd.Flags().BoolVar(&writeKubeConfigOptions.OverwriteExisting,"overwrite",false,"[Careful!] Overwrite existing file, ignoring its contents")
cmd.Flags().BoolVarP(&getKubeconfigFlags.all,"all","a",false,"Get kubeconfigs from all existing clusters")
cmd.Flags().BoolVarP(&getKubeconfigFlags.all,"all","a",false,"Get kubeconfigs from all existing clusters")
--token # specify a cluster token (default: auto-generated)
--token # specify a cluster token (default: auto-generated)
--timeout # specify a timeout, after which the cluster creation will be interrupted and changes rolled back
--timeout # specify a timeout, after which the cluster creation will be interrupted and changes rolled back
--update-default-kubeconfig # enable the automated update of the default kubeconfig with the details of the newly created cluster (also sets '--wait=true')
--update-default-kubeconfig # enable the automated update of the default kubeconfig with the details of the newly created cluster (also sets '--wait=true')
--switch # (implies --update-default-kubeconfig) automatically sets the current-context of your default kubeconfig to the new cluster's context
--switch-context # (implies --update-default-kubeconfig) automatically sets the current-context of your default kubeconfig to the new cluster's context
-v, --volume # specify additional bind-mounts
-v, --volume # specify additional bind-mounts
--wait # enable waiting for all master nodes to be ready before returning
--wait # enable waiting for all master nodes to be ready before returning
-w, --workers # specify how many worker nodes you want to create
-w, --workers # specify how many worker nodes you want to create
@ -53,9 +53,9 @@ k3d
-a, --all # get kubeconfigs from all clusters
-a, --all # get kubeconfigs from all clusters
--output # specify the output file where the kubeconfig should be written to
--output # specify the output file where the kubeconfig should be written to
- *Note:* this won't switch the current-context (append `--switch` to do so)
- *Note:* this won't switch the current-context (append `--switch-context` to do so)
3. Update your default kubeconfig **after** cluster creation
3. Update your default kubeconfig **after** cluster creation
- `#!bash k3d get kubeconfig mycluster --default`
- `#!bash k3d get kubeconfig mycluster --merge-default-kubeconfig`
- *Note:* this won't switch the current-context (append `--switch` to do so)
- *Note:* this won't switch the current-context (append `--switch-context` to do so)
4. Update a different kubeconfig **after** cluster creation
4. Update a different kubeconfig **after** cluster creation
- `#!bash k3d get kubeconfig mycluster --output some/other/file.yaml`
- `#!bash k3d get kubeconfig mycluster --output some/other/file.yaml`
- *Note:* this won't switch the current-context
- *Note:* this won't switch the current-context
@ -29,7 +29,7 @@ To get a kubeconfig set up for you to connect to a k3d cluster, you can go diffe
!!! info "Switching the current context"
!!! info "Switching the current context"
None of the above options switch the current-context by default.
None of the above options switch the current-context by default.
This is intended to be least intrusive, since the current-context has a global effect.
This is intended to be least intrusive, since the current-context has a global effect.
You can switch the current-context directly with the `get kubeconfig` command by adding the `--switch` flag.
You can switch the current-context directly with the `get kubeconfig` command by adding the `--switch-context` flag.
## Removing cluster details from the kubeconfig
## Removing cluster details from the kubeconfig
@ -39,6 +39,6 @@ It will also delete the respective kubeconfig file in `$HOME/.k3d/` if it exists
## Handling multiple clusters
## Handling multiple clusters
`k3d get kubeconfig` let's you specify one or more clusters via arguments _or_ all via `--all`.
`k3d get kubeconfig` let's you specify one or more clusters via arguments _or_ all via `--all`.
All kubeconfigs will then be merged into a single file if `--default` or `--output` is specified.
All kubeconfigs will then be merged into a single file if `--merge-default-kubeconfig` or `--output` is specified.
If none of those two flags was specified, a new file will be created per cluster and the merged path (e.g. `$HOME/.k3d/kubeconfig-cluster1.yaml:$HOME/.k3d/cluster2.yaml`) will be returned.
If none of those two flags was specified, a new file will be created per cluster and the merged path (e.g. `$HOME/.k3d/kubeconfig-cluster1.yaml:$HOME/.k3d/cluster2.yaml`) will be returned.
Note, that with multiple cluster specified, the `--switch` flag will change the current context to the cluster which was last in the list.
Note, that with multiple cluster specified, the `--switch-context` flag will change the current context to the cluster which was last in the list.