An Ansible role to install
kubectl
to a workstation.
Installing kubectl
is not the hardest task in the world, but installing it
consistently and repeatedly across many platforms and enabling auto-completion
and symlinks and plugins and companion tools correctly is an accumulating
challenge.
This project is the first of a series of Ansible roles for solving these simple challenges.
This role does the following:
-
Installs a stable version of
kubectl
to/usr/local/bin/kubectl-X.Y
, whereX
andY
are the major and minor version numbers. It symlinkskubectl
to this new installation, so that oldkubectl
versions remain available. -
Installs
kubens
andkubectx
to simplify managing cluster contexts. -
Installs
k
,kns
, andkctx
symlinks to point tokubectl
,kubens
, andkubectx
. -
Installs everything to
/usr/local/bin
to avoid interfering with the OS.
It is currently tested on the following platforms:
-
Architectures:
x86_64
only -
Platforms:
-
Debian 11, 10, 9
-
Fedora 36
-
Ubuntu 22.04, 20.04, 18.04
-
Add the following to your requirements.yml
file:
- name: brettops.kubectl
You can also use a specific version:
- name: brettops.kubectl
version: "0.1.0"
Add the following to your requirements.yml
file:
- name: brettops.kubectl
src: git+https://gitlab.com/brettops/ansible/roles/kubectl.git
You can also use a specific version:
- name: brettops.kubectl
src: git+https://gitlab.com/brettops/ansible/roles/kubectl.git
version: "0.1.0"
Reference the role in your playbook:
- hosts: all
roles:
- role: brettops.kubectl