diff --git a/cmd/cluster/clusterCreate.go b/cmd/cluster/clusterCreate.go index 3042888b..eb7434f9 100644 --- a/cmd/cluster/clusterCreate.go +++ b/cmd/cluster/clusterCreate.go @@ -99,9 +99,9 @@ func NewCmdClusterCreate() *cobra.Command { fmt.Printf("kubectl config use-context %s\n", fmt.Sprintf("%s-%s", k3d.DefaultObjectNamePrefix, cluster.Name)) } else if !updateCurrentContext { if runtime.GOOS == "windows" { - fmt.Printf("$env:KUBECONFIG=(%s kubeconfig get %s)\n", os.Args[0], cluster.Name) + fmt.Printf("$env:KUBECONFIG=(%s kubeconfig write %s)\n", os.Args[0], cluster.Name) } else { - fmt.Printf("export KUBECONFIG=$(%s kubeconfig get %s)\n", os.Args[0], cluster.Name) + fmt.Printf("export KUBECONFIG=$(%s kubeconfig write %s)\n", os.Args[0], cluster.Name) } } fmt.Println("kubectl cluster-info") diff --git a/cmd/kubeconfig/kubeconfigGet.go b/cmd/kubeconfig/kubeconfigGet.go index e724adb7..72ce5f4d 100644 --- a/cmd/kubeconfig/kubeconfigGet.go +++ b/cmd/kubeconfig/kubeconfigGet.go @@ -52,8 +52,9 @@ func NewCmdKubeconfigGet() *cobra.Command { // create new command cmd := &cobra.Command{ Use: "get [CLUSTER [CLUSTER [...]] | --all]", - Short: "Get kubeconfig from cluster(s).", - Long: `Get kubeconfig from cluster(s).`, + Short: "Print kubeconfig(s) from cluster(s).", + Long: `Print kubeconfig(s) from cluster(s).`, + Aliases: []string{"print", "show"}, ValidArgsFunction: util.ValidArgsAvailableClusters, Args: func(cmd *cobra.Command, args []string) error { if (len(args) < 1 && !getKubeconfigFlags.all) || (len(args) > 0 && getKubeconfigFlags.all) { @@ -100,7 +101,7 @@ func NewCmdKubeconfigGet() *cobra.Command { } // add flags - cmd.Flags().BoolVarP(&getKubeconfigFlags.all, "all", "a", false, "Get kubeconfigs from all existing clusters") + cmd.Flags().BoolVarP(&getKubeconfigFlags.all, "all", "a", false, "Output kubeconfigs from all existing clusters") // done return cmd diff --git a/cmd/kubeconfig/kubeconfigMerge.go b/cmd/kubeconfig/kubeconfigMerge.go index 0649c153..3d620153 100644 --- a/cmd/kubeconfig/kubeconfigMerge.go +++ b/cmd/kubeconfig/kubeconfigMerge.go @@ -55,8 +55,8 @@ func NewCmdKubeconfigMerge() *cobra.Command { cmd := &cobra.Command{ Use: "merge [CLUSTER [CLUSTER [...]] | --all]", Aliases: []string{"write"}, - Long: `Merge/Write kubeconfig(s) from cluster(s) into existing kubeconfig/file.`, - Short: "Merge/Write kubeconfig(s) from cluster(s) into existing kubeconfig/file.", + Long: `Write/Merge kubeconfig(s) from cluster(s) into new or existing kubeconfig/file.`, + Short: "Write/Merge kubeconfig(s) from cluster(s) into new or existing kubeconfig/file.", ValidArgsFunction: util.ValidArgsAvailableClusters, Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { diff --git a/docs/usage/commands.md b/docs/usage/commands.md index 479a43e9..f62af154 100644 --- a/docs/usage/commands.md +++ b/docs/usage/commands.md @@ -51,9 +51,9 @@ k3d list NODENAME --no-headers # do not print headers kubeconfig - get (CLUSTERNAME [CLUSTERNAME ...] | --all) # get kubeconfig from cluster(s) and save it into a file in $HOME/.k3d + get (CLUSTERNAME [CLUSTERNAME ...] | --all) # get kubeconfig from cluster(s) and write it to stdout -a, --all # get kubeconfigs from all clusters - merge (CLUSTERNAME [CLUSTERNAME ...] | --all) # get kubeconfig from cluster(s) and merge it/them into an existing kubeconfig + merge | write (CLUSTERNAME [CLUSTERNAME ...] | --all) # get kubeconfig from cluster(s) and merge it/them into into a file in $HOME/.k3d (or whatever you specify via the flags) -a, --all # get kubeconfigs from all clusters --output # specify the output file where the kubeconfig should be written to --overwrite # [Careful!] forcefully overwrite the output file, ignoring existing contents diff --git a/docs/usage/guides/exposing_services.md b/docs/usage/guides/exposing_services.md index 0e6963c8..83328ce3 100644 --- a/docs/usage/guides/exposing_services.md +++ b/docs/usage/guides/exposing_services.md @@ -18,7 +18,7 @@ Therefore, we have to create the cluster in a way, that the internal port 80 (wh 2. Get the kubeconfig file - `#!bash export KUBECONFIG="$(k3d kubeconfig get k3s-default)"` + `#!bash export KUBECONFIG="$(k3d kubeconfig write k3s-default)"` 3. Create a nginx deployment diff --git a/docs/usage/kubeconfig.md b/docs/usage/kubeconfig.md index c28415e1..af893211 100644 --- a/docs/usage/kubeconfig.md +++ b/docs/usage/kubeconfig.md @@ -12,9 +12,10 @@ To get a kubeconfig set up for you to connect to a k3d cluster, you can go diffe ## Getting the kubeconfig for a newly created cluster 1. Create a new kubeconfig file **after** cluster creation - - `#!bash k3d kubeconfig get mycluster` + - `#!bash k3d kubeconfig write mycluster` - *Note:* this will create (or update) the file `$HOME/.k3d/kubeconfig-mycluster.yaml` - - *Tip:* Use it: `#!bash export KUBECONFIG=$(k3d kubeconfig get mycluster)` + - *Tip:* Use it: `#!bash export KUBECONFIG=$(k3d kubeconfig write mycluster)` + - *Note 2*: alternatively you can use `#!bash k3d kubeconfig get mycluster > some-file.yaml` 2. Update your default kubeconfig **upon** cluster creation - `#!bash k3d cluster create mycluster --update-kubeconfig` - *Note:* this won't switch the current-context (append `--switch-context` to do so)