diff --git a/content/rancher/v2.x/en/tasks/clusters/using-kubectl-to-access-a-cluster/_index.md b/content/rancher/v2.x/en/tasks/clusters/using-kubectl-to-access-a-cluster/_index.md index d5c8caeb383..b141d888c94 100644 --- a/content/rancher/v2.x/en/tasks/clusters/using-kubectl-to-access-a-cluster/_index.md +++ b/content/rancher/v2.x/en/tasks/clusters/using-kubectl-to-access-a-cluster/_index.md @@ -2,22 +2,43 @@ title: Using kubectl to Access a Cluster weight: 3450 --- -You can access and manage your Kubernetes clusters using the kubectl shell, all within the Rancher GUI. +You can access and manage your Kubernetes clusters using the kubectl two ways: + +- [Accessing Clusters with kubectl Shell](#accessing-clusters-with-kubectl-shell) +- [Accessing Clusters with kubectl CLI and a kubeconfig File](#accessing-clusters-with-kubectl-cli-and-a-kubeconfig-file) + +## Accessing Clusters with kubectl Shell + +You can access and manage your clusters by logging into Rancher and opening the kubectl shell. No further configuration necessary. 1. From the **Global** view, open the cluster that you want to access with kubectl. - -2. Copy the cluster's kubeconfig file to your workstation. - 1. Click **Kubeconfig File**. - 2. Copy the contents displayed to your clipboard. - 3. Paste the contents into a new file on your local computer. Move the file to `~/.kube/config`. - - > **Note:** The default location that kubectl uses for the kubeconfig file is `~/.kube/config`, but you can use any directory and specify it using the `--kubeconfig` flag, as in the sample that follows: - > - > ``` - kubectl --kubeconfig /custom/path/kube.config get pods - ``` - -3. Click **Launch kubectl**. Use the window that opens to interact with your Kubernetes cluster. +2. Click **Launch kubectl**. Use the window that opens to interact with your Kubernetes cluster. For more information on using kubectl, see [Kubernetes Documentation: Overview of kubectl](https://kubernetes.io/docs/reference/kubectl/overview/). + + +## Accessing Clusters with kubectl CLI and a kubeconfig File + +Alternatively, you can access your clusters by installing a kubectl on your workstation, and then directing it toward a kubeconfig file automatically generated by Rancher. After install and configuration, you can access your clusters without logging into Rancher. + +1. Install kubectl on your workstation. For more information, see [Kubernetes Documentation: Install and Set Up kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) + +2. Log into Rancher. From the **Global** view, open the cluster that you want to access with kubectl. + +3. Copy the cluster's kubeconfig file to your workstation. + + 1. Click **Kubeconfig File**. + + 2. Copy the contents displayed to your clipboard. + + 3. Paste the contents into a new file on your local computer. Move the file to ``/.kube/config`. + + >**Note:** The default location that kubectl uses for the kubeconfig file is `~/.kube/config`, but you can use any directory and specify it using the `--kubeconfig` flag, as in the sample that follows: + > + >``` + kubectl --kubeconfig /custom/path/kube.config get pods + ``` +4. From your workstation, launch kubectl. Use it to interact with your kubernetes cluster. + + For more information on using kubectl, see [Kubernetes Documentation: Overview of kubectl](https://kubernetes.io/docs/reference/kubectl/overview/). \ No newline at end of file