Welcome to Terranetes, the easy and straightforward way to set up your Kubernetes cluster using Ansible and Terraform! No need for complex tools like KubeSpray or KopsβTerranetes is here to streamline the process with just a few Ansible tasks. π
Everything is Logical and based on a vars file - each variable runs a set of tasks (can be used alone or mixed):
for example:
1. you can use prepare and init master
2. you can just use prepare and add worker
3. Just Calico and metrics server
4. join some worker node on the other side of the planet to your cluster that you built without terranetes
5. maybe you just want to create with terraform - can do that too
6. sky is the limit (I've tried to break the flow or a cluster with multiple test, haven't been successful yet)
- Prerequisites
- Getting Started
- Running the Playbook
- What the Playbook Does
- Verifying the Setup
- Conclusion
Before you begin, ensure you have the following:
- A server with an updated version of Ansible installed.
- Terraform installed on your machine.
- Ansible Galaxy collection for community modules:
ansible-galaxy collection install community.general
. - HCLOUD token (or any cloud provider - I'm using hetzner here)
-
Clone the repository (if you haven't already):
git clone [email protected]:sinanejadebrahim/terranetes.git cd terranetes # update the provider.tf file in terranetes/files/ with your token
-
Install the required Ansible Galaxy collection:
ansible-galaxy collection install community.general
-
change vars.yml file:
everyhing is based on this file
To set up your Kubernetes cluster, simply run the following command:
ansible-playbook playbook.yml
No inventory file is needed! Terranetes dynamically updates the inventory with hosts created by Terraform.
-
Terraform Setup:
- Uses Terraform to build your servers.
-
Prerequisites Installation:
- Installs all necessary prerequisites on your servers for Kubernetes.
-
Kubernetes Master Initialization:
- can initialize the master node.
-
Worker Nodes Addition:
- can add worker nodes to your cluster .
-
Apply Calico and Metrics Server:
- can apply Calico and the Metrics Server to your cluster.
Once the playbook completes, SSH into your master node (you can find it in the file terraform-hosts.ini after the playbook runs) and run:
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl get nodes
You should see all nodes up and running perfectly! π
With Terranetes, setting up a Kubernetes cluster has never been easier. Enjoy your new cluster and happy container orchestration! π³β¨
For any issues or contributions, feel free to open an issue or submit a pull request. Happy hacking! π¨βπ»π©βπ»
- I already know this could look much better with variables,templates, etc... contributions are appreciated
- no shade to Kops or kubeSpray people, you're awesome , i'm just too lazy to check out all those files and that's why i made this.