githubixx.kubectl

ansible-role-kubectl

This role installs the kubectl command-line tool, which is used to interact with the Kubernetes API Server.

Versions

Each release of this role is tagged, and I follow semantic versioning. I suggest you use the latest tagged version for stability. The master branch is where active development happens, while the tags represent stable versions. A tag like 23.0.2+1.28.5 indicates that this is version 23.0.2 of the role, and the version of the kubectl tool is 1.28.5. If the role changes, the part before + will increase. If the version of Kubernetes changes, the part after + will increase. This method helps to track updates and fixes, even while the role is being developed for a specific Kubernetes version.

Changelog

You can find updates in the CHANGELOG.

Role Variables

# Version of "kubectl" to install
kubectl_version: "1.29.3"

# Default option for downloading kubectl. The "binary" is larger
# than the ".tar.gz", but it does not require unzipping.
# Choose "binary" if size is not a concern, otherwise go with "archive".
kubectl_download_filetype: "binary"

# SHA512 checksum for the "kubernetes-client-linux-amd64.tar.gz" file
kubectl_checksum_archive: "sha512:c9cc7ab9e3aa776f2daab3a9e10ee78d57d0c081ef43f8032de36a61c6425ba527d5df92611b058672be0975a6b97ad3f3a169e282c26275d2c0e59e1f9b1173"

# SHA512 checksum of the binary, usually doesn’t need to change
kubectl_checksum_binary: "sha512:https://cdn.dl.k8s.io/release/v{{ kubectl_version }}/bin/{{ kubectl_os }}/{{ kubectl_arch }}/kubectl.sha512"

# Directory to install the "kubectl" binary
kubectl_bin_directory: "/usr/local/bin"

# Temporary directory for downloading the archive
kubectl_tmp_directory: "{{ lookup('env', 'TMPDIR') | default('/tmp', true) }}"

# Owner of the "kubectl" binary
kubectl_owner: "root"

# Group of the "kubectl" binary
kubectl_group: "root"

# Permissions for the "kubectl" binary
kubectl_binary_mode: "0755"

# Operating system for "kubectl"
kubectl_os: "linux"  # use "darwin" for MacOS X, "windows" for Windows

# Processor architecture for "kubectl"
kubectl_arch: "amd64"  # Alternatives: "386", "arm64", "arm", "ppc64le", "s390x"

Testing

This role includes a simple test setup using molecule. To run tests, follow the molecule install guide, and make sure a Docker daemon is running.

If you have Docker installed, you'll need two Python packages:

pip3 install --user molecule
pip3 install --user molecule-docker

You can then run:

molecule converge

This sets up Docker containers with Ubuntu and Debian, with kubectl installed. To check if everything works:

molecule verify

To clean up, run:

molecule destroy

Example Playbook

- hosts: your-host
  roles:
    - githubixx.kubectl

License

GNU GENERAL PUBLIC LICENSE Version 3

Author Information

TauCeti Blog

Informazioni sul progetto

Installs kubectl command line utility used to interact with the Kubernetes API Server.

Installa
ansible-galaxy install githubixx.kubectl
Licenza
gpl-3.0
Download
12k
Proprietario
Senior System Engineer - Python, Go, Cloud, Kubernetes, Commodore, Retro, 80's ;-)