https://github.com/mlouguid/k8s-Ansible
Install and configure k8b using Ansible.
https://github.com/mlouguid/k8s-Ansible
ansible k8s kubernetes
Last synced: over 1 year ago
JSON representation
Install and configure k8b using Ansible.
- Host: GitHub
- URL: https://github.com/mlouguid/k8s-Ansible
- Owner: mlouguid
- Created: 2024-12-10T10:32:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-20T22:38:34.000Z (over 1 year ago)
- Last Synced: 2025-01-20T23:24:19.938Z (over 1 year ago)
- Topics: ansible, k8s, kubernetes
- Homepage:
- Size: 458 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kubernetes Deployment Using Ansible
This guide outlines the steps to deploy Kubernetes on a target machine or cluster using Ansible. The playbook automates the installation and configuration of Kubernetes components on the target system.
## Prerequisites
Before you begin, ensure the following prerequisites are met:
- A **control machine** where Ansible is installed.
You can install Ansible using the following commands:
- For Ubuntu/Debian:
```bash
sudo apt update
sudo apt install ansible
```
- A **target machine** (or multiple nodes) where:
- Python 3 is installed and accessible.
- `sudo` privileges are available for the user running the Ansible playbook.
## Step 1: Setting Up the Inventory File
Create an inventory file to define the hosts (target machine) for Kubernetes deployment. The following example shows how to configure the target machine IP:
```yaml
all:
children:
kubernetes:
hosts:
localhost:
ansible_connection: local
ansible_python_interpreter: /usr/bin/python3
```
## Step 2: Cloning the Project
Clone the Kubernetes deployment project from the repository (or use your own project):
```
git clone https://github.com/mlouguid/k8b-Ansible.git
cd k8b-Ansible
```
## Step 3: Kubernetes Role Structure
Ensure your kubernetes role has the following directory structure:
```
roles/
└── kubernetes/
├── tasks/
│ ├── main.yml
│ ├── install_k8s.yml
│ ├── containerd.yml
│ └── kube_prereqs.yml
├── handlers/
└── main.yml
```
## step 4: deploy the playbook
```
ansible-playbook kubernetes_playbook.yml -i inventories/local/hosts --limit=kubernetes --ask-become-pass
```