How to install kubectl on macOS using Homebrew

How to install kubectl on macOS using Homebrew

This post provides a step-by-step guide with a list of commands on how to install kubectl on macOS using Homebrew.

This post provides a step-by-step guide with a list of commands on how to install kubectl on macOS using Homebrew.

What is kubectl?

“The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.” ~ Kubernetes.io

What is Homebrew?

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system. It is known as the missing package manager for macOS.

Quick Commands

The following is the single command required to install kubectl on macOS using Homebrew.

$ brew install kubectl

Brew Commands

This section provides a quick set of commands on how to install kubectl on macOS using Homebrew. It is assumed that Homebrew is already installed. If not, please follow this link.

$ brew update             # Fetch latest version of homebrew and formula.
$ brew search kubectl     # Searches all known formulae for a partial or exact match.
$ brew info kubectl       # Displays information about the given formulae.
$ brew install kubectl    # Install the given formulae.
$ brew cleanup            # Remove any older versions from the cellar.

Validate Installation

The following command can be used to validate that the installation was successful, and also to ensure the version you installed is up-to-date.

# Print the client version information for the current context.
$ kubectl version --client

Summary

Congratulations! You have successfully installed kubectl on macOS making use of Homebrew. Follow me on any of the different social media platforms and feel free to leave comments.