To run commands against your Kubernetes cluster form your system they have made a command line tool called KubeCTL. With this tool its possible to maintain al your Kubernetes administration. In this article i describe how to install KubeCtl on Windows and Linux. Including creating a config file for connecting to your Kubernetes cluster.
Contents
How to Install KubeCTL on Linux
- Download the KubeCtl files.
1 |
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl |
- Change the permissions
1 |
sudo chmod +x ./kubectl |
- Add to your environment.
1 |
sudo mv ./kubectl /usr/local/bin/kubectl |
- Check if KubeCtl is installed correctly.
1 |
kubectl version --client |
How to configure KubeCTL on Linux?
To make use of KubeCTL against your Kubernetes clusters you need to specify a connection context. This connection context is mostly saved in a KubeCTL configuration file. Configuration files are placed in different directories for each operating system.
- The KubeCtl configuration file on Linux is located on the following location
1 |
$HOME/.kube/config |
- Configure the configuration file as follow:
1 2 |
mkdir $HOME/.kube nano $HOME/.kube/config |
How to Install KubeCTL on Windows
1 2 3 4 |
$DestiPath = "C:\Kubectl" Install-Script -Name install-kubectl -Scope CurrentUser -Force install-kubectl.ps1 -DownloadLocation $DestiPath $env:path = $env:path + ";$DestiPath" |
How to configure KubeCTL on Windows
1 2 3 |
#Creating a KubeCTL config file. Make sure it hasn't the .txt extention. New-Item -path $env:HOMEPATH\.kube\config notepad $env:HOMEPATH\.kube\config |
Place your Kubernetes cluster config here.