brettops.kubectl
brettops.kubectl role
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.
What does this role provide?
This role does the following:
Installs a stable version of
kubectlto/usr/local/bin/kubectl-X.Y, whereXandYare the major and minor version numbers. It symlinkskubectlto this new installation, so that oldkubectlversions remain available.Installs
kubensandkubectxto simplify managing cluster contexts.Installs
k,kns, andkctxsymlinks to point tokubectl,kubens, andkubectx.Installs everything to
/usr/local/binto avoid interfering with the OS.
Supported platforms
It is currently tested on the following platforms:
Architectures:
x86_64onlyPlatforms:
Debian 11, 10, 9
Fedora 36
Ubuntu 22.04, 20.04, 18.04
Installation
From Ansible Galaxy
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"
From source
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"
Usage
Reference the role in your playbook:
- hosts: all
roles:
- role: brettops.kubectl
ansible-galaxy install brettops.kubectl