An Ansible Playbook to automate the configuration of (Ubuntu Linux x86_64 and ARM64) machines to be ready for Kubernetes development. It cuts down the development environment preparation from tedious hours to less than 5 minutes.
The below are installed on all groups (k8sdev
, k8sdevlite
and k8sdevdocker
):
- git
- kubectl
- helm
- skaffold
- k9s
- sops and helm secrets plugin
- azure-cli and kubelogin
- awscli
- kube-ps1
- tmux and .tmux
- kubectx/kubens
- docker-cli
All of the above come with bash completion, whenever applicable.
The below is installed on both k8sdev
and k8sdevdocker
groups:
The below are installed only on the k8sdev
group:
-
Ansible on your controller machine (e.g. laptop) which is typically different from, but could be the same as, the target machine you are preparing. You also need a couple of Ansible collections, install using the command:
ansible-galaxy collection install community.general kubernetes.core
(Make sure that you are using Ansible > v2.9) -
One or more SSH connections to the target machine(s) with public key authentication configured. You can do that by editing your
.ssh/config
. For example:# ~/.ssh/config Host awsdev1 HostName 100.100.100.100 User ubuntu IdentityFile ~/.ssh/id_rsa IdentitiesOnly yes
-
A configured Ansible hosts file with 2 sections called
k8sdev
andk8sdevlite
containing all the machines you want to configure (yes you can configure many machines at once!). For example:# /etc/ansible/hosts [k8sdev] awsdev1 ansible_user=ubuntu 1.2.3.4 ansible_user=anotheruser 5.6.7.8 ansible_user=ubuntu ... [k8sdevlite] ... [k8sdevdocker] ...
The above file can be stored in the default location /etc/ansible/hosts
if the control machine is running Debian/Ubuntu or a similar distro. For other distros or other operating systems, you can store it in any location then supply --inventory <file-location>
to the ansible-playbook
command.
To launch the installation process that will configure all target machines at once, run the following:
git clone https://github.com/hammady/ohmyk8s.git
cd ohmyk8s
ansible-playbook ohmyk8s.yaml -Kv
Note:
ansible-playbook
accepts -v for verbose mode (-vvv for more, -vvvv to enable connection debugging)-K
to collectBECOME password
Sit (or stand!) and watch the results, you should get a report similar to the below if everything goes well:
...
PLAY RECAP *******************************
awsdev1 : ok=56 changed=7 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- This only supports Ubuntu running on either x86_64 or ARM64 architectures. Support for other distributions and architectures is possible but needs some work.
If there are any errors from the above command, please create an issue in this repo or drop me a line at: github at hammady dot net.
If you have any suggestions or enhancements, please feel free to create a PR or discuss with me. Please note that I am a total noob in Ansible, I learned it in the same day I created this repo.