Skip to content
Ansible role for installing Kubernetes
Shell Python
Branch: master
Clone or download
freemanjp Increased minimum Ansible version to 2.6 (#46)
Ansible no longer supports versions earlier than 2.6.
Latest commit ec79950 Jul 21, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.moleculew Increased upper Ansible test range to Ansible 2.8 (#45) Jul 19, 2019
handlers Initial commit after running ansible-galaxy init Nov 5, 2016
meta Increased minimum Ansible version to 2.6 (#46) Jul 21, 2019
molecule Removed duplicate Dockerfiles (#43) May 18, 2019
tasks Resolved apt module syntax deprecation warning (#41) Oct 10, 2018
vars Added controller type (#33) Aug 23, 2018
.editorconfig Added .editorconfig file Nov 5, 2016
.gitattributes Added .gitattributes Nov 5, 2016
.gitignore Added .gitignore Nov 5, 2016
.travis.yml Increased minimum Ansible version to 2.6 (#46) Jul 21, 2019
.yamllint Updated Molecule to 2.20.1 (#42) May 17, 2019
LICENSE Initial commit Nov 5, 2016 Increased minimum Ansible version to 2.6 (#46) Jul 21, 2019
moleculew Updated moleculew to version 0.9.9 (#38) Sep 16, 2018

Ansible Role: Kubernetes

Build Status Ansible Galaxy License

Role to install the Kubernetes container cluster manager.


  • Ansible >= 2.6

  • Linux Distribution

    • Debian Family

      • Ubuntu

        • Xenial (16.04)
        • Bionic (18.04)

Role Variables

The following variables will change the behavior of this role (default values are shown below):

# Node type: determines what features are installed.
# - controller:
#     - kubectl
# - worker:
#     - kubelet
#     - kubernetes-cni
# - master:
#     - kubelet
#     - kubectl
#     - kubernetes-cni
# - admin:
#     - kubelet
#     - kubectl
#     - kubeadm
#     - kubernetes-cni
kubernetes_node_type: worker

# The ID of the APT key for the Kubernetes repository
kubernetes_apt_key_id: 6A030B21BA07F4FB

Example Playbook

- hosts: servers
    - role: gantsign.kubernetes
      kubernetes_node_type: worker

Tab Completion & Aliases for Zsh

Using Ansible

We recommended using the gantsign.antigen role to enable Zsh support for Kubernetes (this must be configured for each user).

- hosts: servers
    - role: gantsign.kubernetes
      kubernetes_node_type: worker

    - role: gantsign.antigen
        - username: example
            - name: oh-my-zsh
            # Use the Oh My Zsh plugin for kubectl
            - name: kubectl
            # Use the GantSign plugin for kubeadm
            - name: kubeadm
              url: gantsign/zsh-plugins
              location: kubeadm

Using Antigen

If you prefer to use Antigen directly add the following to your Antigen configuration:

antigen use oh-my-zsh
antigen bundle kubectl
antigen bundle gantsign/zsh-plugins kubeadm

Important: there's a bug with the current version of Antigen that prevents it working with the kubectl plugin. We recommend using version 2.0.2 of Antigen until the issue is fixed.

Manual configuration

To manually configure Zsh tab completion add the following to your .zshrc:

eval "$(kubectl completion zsh)"
eval "$(kubeadm completion zsh)"

More Roles From GantSign

You can find more roles from GantSign on Ansible Galaxy.

Development & Testing

This project uses Molecule to aid in the development and testing; the role is unit tested using Testinfra and pytest.

To develop or test you'll need to have installed the following:

Because the above can be tricky to install, this project includes Molecule Wrapper. Molecule Wrapper is a shell script that installs Molecule and it's dependencies (apart from Linux) and then executes Molecule with the command you pass it.

To test this role using Molecule Wrapper run the following command from the project root:

./moleculew test

Note: some of the dependencies need sudo permission to install.



Author Information

John Freeman

GantSign Ltd. Company No. 06109112 (registered in England)

You can’t perform that action at this time.