install kubectl ubuntu code example

Example 1: install kubernetes on ubuntu

# Installing Kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client
# Installing Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube
sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/
minikube start --driver=none 
# If this fails with a message "requires conntrack to be installed in root's path"
sudo apt install conntrack
# then try again
sudo minikube start --driver=none
#check the status
sudo minikube status
# Output:
#host: Running
#kubelet: Running
#apiserver: Running
#kubeconfig: Configured

#It is suggested (by minikube) to change the ownership and
#permissions of ~/.kube and ~/.minikube after the installation.

sudo chown -R $USER $HOME/.kube
sudo chown -R $USER $HOME/.minikube

Example 2: bash install kubectl

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client

Example 3: install kubectl

curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/bin/kubectl # you can replace /usr/bin for some dir in your PATH

Example 4: kubectl install on ubuntu

curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"

Example 5: kubectl download

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl

Example 6: install kubectl ubuntu

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl