How to Install Kubernetes on Ubuntu, macOS, and Windows
What is Kubernetes?
Kubernetes (or K8s) is an open-source container orchestration system for automating computer application deployment, scaling, and management. Kubernetes manages and runs Docker containers on numerous hosts. The project was started by Google and is supported by many companies, including Microsoft, RedHat, IBM.
There are two main versions of Kubernetes, a production environment and a learning environment. The following instructions are for installing a simple Kubernetes learning framework. The tools used to deploy this type of environment are Minikube and Kubectl.
What is Minikube?
Minikube is a tool that allows us to run a Kubernetes setup locally within a virtual machine. It lets us run a single-node Kubernetes cluster on our personal computer to try out Kubernetes or essential development work.
What is Kubectl?
Kubectl is a command-line tool for Kubernetes that allows us to run commands on our Kubernetes cluster. We can also use kubectl to deploy applications, check and manage cluster resources, and view logs.
Installing Kubectl on Ubuntu 20
There are two options for the official installation of kubectl on the Linux system.
- The first option is to install the kubectl binary using the curl commands on any versions of Linux.
- The second option uses the built-in package manager apt in Ubuntu. As a best practice, the second option is recommended.
As always, we update all our packages and install the https transport protocol.
root@host:~$ apt-get update && apt-get install -y apt-transport-https
Install GPG Repository Security Key
First, download the gpg security key for the repository.
root@host:~$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
OK
root@host:~$
Now, we add the key and apply it.
root@host:~$ echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
root@host:~$
Finally, update the package manager repository again.
root@host:~$ apt-get update
Install Kubectl
Now we can install kubectl using the following command.
root@host:~$ apt-get install -y kubectl
Next, we will verify that it has been installed using the version command.
root@host:~$ kubectl version --client
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.1", GitCommit:"206bcadf021e76c27513500ca24182692aabd17e", GitTreeState:"clean", BuildDate:"2020-09-09T11:26:42Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}
root@host:~$
Additional Kubectl Configuration
Install Shell Autocompletion
Kubectl supports autocompletion input in Bash and Zsh (Autocompletion is used to complete a partially typed command). This feature saves us time when typing long commands.
We need to install the bash-completion package so that we can add the kubectl auto-completion script. Install it with this command.
root@host:~$ apt-get install -y bash-completion
Reading package lists... Done
Building dependency tree
Reading state information... Done
bash-completion is already the newest version (1:2.10-1ubuntu1).
bash-completion set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@host:~$
For the commands in ~ /.bashrc to work, use the following command in the terminal to implement it.
root@host:~$ source /usr/share/bash-completion/bash_completion
root@host:~$
To verify we have the package installed correctly, run the following command.
root@host:~$ type _init_completion
Enable Shell Autocompletion
Now, we add a script to the ~/.bashrc file with the following command:
root@host:~$ echo 'source <(kubectl completion bash)' >>~/.bashrc
root@host:~$
Next, add the script to the directory /etc/bash_completion.d
root@host:~$ kubectl completion bash >/etc/bash_completion.d/kubectl
root@host:~$
After restarting the OS, you should have an AutoComplete input to kubectl.
Install Kubectl on macOS
We will use Homebrew on macOS to install kubectl.
Install Kubectl
Use the following installation command in the terminal.
admin@MacBook-Pro-4 ~ % brew install kubectl
Verify Installation
To check that the installation was successful, run the following command.
admin@MacBook-Pro-4 ~ % kubectl version --client
We can check our version of bash using this command.
admin@MacBook-Pro-4 ~ % bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.
admin@MacBook-Pro-4 ~ %
Update Bash
Now we will update bash with Homebrew by running the following command.
admin@MacBook-Pro-4 ~ % brew install bash
Verify Update
Check it has been updated using this command.
admin@MacBook-Pro-4 ~ % /usr/local/bin/bash --version
GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.5.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
admin@MacBook-Pro-4 ~ %
Install Bash Completion
Install bash-completion using this command.
admin@MacBook-Pro-4 ~ % brew install bash-completion@2
Now, add the following line to the ~/.bashrc file.
admin@MacBook-Pro-4 ~ % export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
admin@MacBook-Pro-4 ~ %
Next, add the script to the directory.
admin@MacBook-Pro-4 ~ % kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl
admin@MacBook-Pro-4 ~ %
The autocompletion for kubectl on macOS is now ready for use.
Install Kubectl on Windows Server 2019
There are multiple installation options on Windows. The best option is to install using Chocolatey in Powershell. We will use the third-party package manager Chocolatey. Start Windows PowerShell (Admin) by right-click on start and select Windows PowerShell (Admin). Install Chocolatey (choco) by entering the following command in PowerShell.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Next, check the installation was successful using this command.
PS C:\Users\Administrator> choco
Chocolatey v0.10.15
Please run 'choco -?' or 'choco <command> -?' for help menu.
PS C:\Users\Administrator>
Now we install kubectl on Windows with the following command. Choose “Y” when agreeing to the installation.
PS C:\Users\Administrator> choco install kubernetes-cli
Enter the version command to verify that everything is installed
PS C:\Users\Administrator> kubectl version --client
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.1", GitCommit:"206bcadf021e76c27513500ca24182692aabd17e", GitTreeState:"clean", BuildDate:"2020-09-09T11:26:42Z", GoVersion:"go1.15", Compiler:"gc", Platform:"windows/amd64"}
PS C:\Users\Administrator>
You have successfully installed kubectl on Windows Server 2019.
Install Minikube
After we install kubectl, we need to install Minikube. Minikube is the tool that allows us to quickly run a single-node version of K8s locally in a virtual machine.
Ubuntu 20
First, we need to check if our computer supports VT-x / AMD-v virtualization using this command.
root@host:~$ grep -E --color 'vmx|svm' /proc/cpuinfo
Everyone will have different information in the output (based on your CPU type), but we should verify that we see the vmx or svm flags. If so, the CPU is capable of running hardware virtualization.
Next, we install Virtualbox as the hypervisor (Virtualbox is a software product for virtualizing OS Windows, Linux, FreeBSD, macOS, Solaris, etc.).Install Virtualbox with this command.
root@host:~$ apt install virtualbox virtualbox-ext-pack
Now, we download Minikube using the direct link and make the Minikube executable using the chmod command.
root@host:~$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \ && chmod +x minikube
Then, we move the file to the bin directory.
root@host:~$ cp minikube-linux-amd64 /usr/local/bin/minikube
To verify we have everything installed enter the command:
root@host:~$ minikube version
minikube version: v1.13.0
commit: 0c5e9de4ca6f9c55147ae7f90af97eff5befef5f-dirty
root@host:~$
Minikube installation on macOS
Verify Virtualization possibility with this command:
admin@MacBook-Pro-4 ~ % sysctl -a | grep -E --color 'machdep.cpu.features|VMX'
You should have something similar to the following output.
Then install HyperKit. This is a popular hypervisor popular. It's used for lightweight virtual machines and container deployments. We install it using brew.
admin@MacBook-Pro-4 ~ % brew install hyperkit
To verify installation, use the version command.
admin@MacBook-Pro-4 ~ % hyperkit -v
hyperkit: 0.20200224
Homepage: https://github.com/docker/hyperkit
License: BSD
admin@MacBook-Pro-4 ~ %
We can also install minikube using brew.
admin@MacBook-Pro-4 ~ % brew install minikube
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/minikube-1.13.0.catalina.bo
==> Pouring minikube-1.13.0.catalina.bottle.1.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
zsh completions have been installed to:
/usr/local/share/zsh/site-functions
==> Summary
🍺 /usr/local/Cellar/minikube/1.13.0: 8 files, 62.2MB
admin@MacBook-Pro-4 ~ %
Check that minikube has been installed using the version command:
admin@MacBook-Pro-4 ~ % minikube version
minikube version: v1.13.0
commit: 0c5e9de4ca6f9c55147ae7f90af97eff5befef5f
admin@MacBook-Pro-4 ~ %
Minikube installation on Windows Server 2019
First, we need to check if virtualization is supported on the server. Enter the following command:
PS C:\Users\Administrator> systeminfo
Host Name: WIN-SG77QKRNOA6
OS Name: Microsoft Windows Server 2019 Standard
OS Version: 10.0.17763 N/A Build 17763
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
OS Build Type: Multiprocessor Free
Registered Owner: Windows User
Registered Organization:
Product ID: 00429-70000-00000-AA065
Original Install Date: 9/13/2020, 6:53:39 AM
System Boot Time: 9/13/2020, 7:31:43 AM
System Manufacturer: innotek GmbH
System Model: VirtualBox
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: AMD64 Family 23 Model 113 Stepping 0 AuthenticAMD ~3593 Mhz
BIOS Version: innotek GmbH VirtualBox, 12/1/2006
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume1
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
Time Zone: (UTC-08:00) Pacific Time (US & Canada)
Total Physical Memory: 2,048 MB
Available Physical Memory: 1,242 MB
Virtual Memory: Max Size: 3,200 MB
Virtual Memory: Available: 2,468 MB
Virtual Memory: In Use: 732 MB
Page File Location(s): C:\pagefile.sys
Domain: WORKGROUP
Logon Server: \\WIN-SG77QKRNOA6
Network Card(s): 1 NIC(s) Installed.
[01]: Intel(R) PRO/1000 MT Desktop Adapter
Connection Name: Ethernet
DHCP Enabled: Yes
DHCP Server: 192.168.50.1
IP address(es)
[01]: 192.168.50.167
[02]: fe80::b115:cdee:3a22:1b65
Hyper-V Requirements: VM Monitor Mode Extensions: Yes
Virtualization Enabled In Firmware: Yes
Second Level Address Translation: No
Data Execution Prevention Available: Yes
PS C:\Users\Administrator>
Pay attention to these lines:
Hyper-V Requirements:
VM Monitor Mode Extensions: Yes
Virtualization Enabled In Firmware: Yes
Second Level Address Translation: No
Data Execution Prevention Available: Yes
Now install Hypervisor using choco.
PS C:\Users\Administrator> choco install virtualbox
Install minikube using choco.
PS C:\Users\Administrator> choco install minikube
Check that Minikube has been installed using the version command.
PS C:\Users\Administrator> minikube version
minikube version: v1.13.0
commit: 0c5e9de4ca6f9c55147ae7f90af97eff5befef5f-dirty
PS C:\Users\Administrator>
This completes the minikube installation on Windows Server.
Conclusion
In this article, we discussed how to install and configure minikube and kubectl on Linux, macOS, and Windows. We provided the command line instructions to aid users in walking through a local installation of minikube and kubectl, allowing a user to test a locally installed version of Kubernetes.
Get Started Today!
We pride ourselves on being The Most Helpful Humans In Hosting™!
Our experienced Hosting Solutions advisors are always available to show you how you can take advantage of these techniques today!
We are available 24 hours a day, 7 days a week 365 days a year, via our ticketing systems at support@liquidweb.com, by phone (at 800-580-4986) or via a LiveChat or whatever method you prefer.
Related Articles:

About the Author: Margaret Fitzgerald
Margaret Fitzgerald previously wrote for Liquid Web.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
Best authentication practices for email senders
Read ArticleWhat is SDDC VMware?
Read Article2024 cPanel and Plesk pricing breakdown
Read ArticleCentOS Linux 7 EOL — everything you need to know
Read ArticleHow to install Node.js on Linux (AlmaLinux)
Read Article