Kubectl is the Kubernetes command-line tool, that enables you to run commands against your Kubernetes clusters. Kubectl is one of the first tools you would want configured once you have a Kubernetes cluster, so you can start deploying sample applications on Kubernetes.
You can use kubectl to deploy your containerized applications, inspect and manage cluster resources, view container logs to debug issues etc.
Follow the steps to download and install kubectl on your local machine to access your Kubernetes cluster.
Now that you have kubectl installed, you need to get a valid kubeconfig file for your Kubernetes cluster and then configure kubectl to work with the kubeconfig file, so it can access your Kubernetes cluster.
If using a Platform9 Managed Kubernetes (PMK) Cluster:
If using a different Kubernetes cluster, talk to your cluster administrator to get access to a valid kubeconfig file.
To ensure your local environment is set up to connect to your Kubernetes cluster, run the following command to set up your KUBECONFIG environment variable.
xxxxxxxxxx
export KUBECONFIG=/tmp/sample-kubeconfig.yaml
Verify that the kubeconfig was set up successfully and kubectl can connect to your Kubernetes cluster:
xxxxxxxxxx
kubectl cluster-info
You should see output like this:
Kubernetes master is running at https://192.168.1.12
CoreDNS is running at https://192.168.1.12/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://192.168.1.12/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
Now you have kubectl installed and configured to work with your Kubernetes cluster.
For more information, including a comprehensive list of kubectl operations, see the Kubectl
Reference Documentation.