gantsign.kubernetes
Ansible Role: Kubernetes
This Ansible role installs the Kubernetes container cluster manager.
Requirements
- Ansible Core version 2.12 or higher
- A Linux Distribution, specifically:
- Debian Family
- Ubuntu:
- Bionic (18.04)
- Focal (20.04)
- Ubuntu:
- Debian Family
Role Variables
You can change how this role behaves using the following variables (default values are listed):
# Node type: this decides what features to install.
# Options:
# - controller: installs kubectl
# - worker: installs kubelet and kubernetes-cni
# - master: installs kubelet, kubectl, and kubernetes-cni
# - admin: installs kubelet, kubectl, kubeadm, and kubernetes-cni
kubernetes_node_type: worker
# Optional: APT key ID for the Kubernetes repository
kubernetes_apt_key_id:
Example Playbook
- hosts: servers
roles:
- role: gantsign.kubernetes
kubernetes_node_type: worker
Tab Completion & Aliases for Zsh
Using Ansible
For better Zsh support for Kubernetes, it's recommended to use the gantsign.antigen role (needs to be set up for each user).
- hosts: servers
roles:
- role: gantsign.kubernetes
kubernetes_node_type: worker
- role: gantsign.antigen
users:
- username: example
antigen_libraries:
- name: oh-my-zsh
antigen_bundles:
# Plugin for kubectl
- name: kubectl
# Plugin for kubeadm
- name: kubeadm
url: gantsign/zsh-plugins
location: kubeadm
Using Antigen
If you prefer to use Antigen directly, add this to your Antigen setup:
antigen use oh-my-zsh
antigen bundle kubectl
antigen bundle gantsign/zsh-plugins kubeadm
Note: There's a bug in the current Antigen version that affects the kubectl
plugin. It's best to use version 2.0.2
of Antigen until it's fixed.
Manual configuration
To set up Zsh tab completion manually, add this to your .zshrc
:
eval "$(kubectl completion zsh)"
eval "$(kubeadm completion zsh)"
More Roles From GantSign
You can find additional roles from GantSign on Ansible Galaxy.
Development & Testing
This project uses the following tools:
- Molecule for testing scenarios
- Testinfra for testing changes remotely
- pytest as the testing framework
- Tox for managing Python virtual environments for linting and testing
- pip-tools for managing dependencies
A Visual Studio Code Dev Container is available for developing and testing this role.
License
MIT
Author Information
John Freeman
GantSign Ltd.
Company No. 06109112 (registered in England)
Role for installing Kubernetes.
ansible-galaxy install gantsign.kubernetes