update readme

This commit is contained in:
Bartal Læarsson
2025-03-02 20:53:29 +00:00
parent 91c59d0f0e
commit 8f9c475cfd
2 changed files with 141 additions and 88 deletions
+82 -55
View File
@@ -1,82 +1,109 @@
# Kubernetes Local Development Environment
## Overview
This project provides automation scripts to create and manage local Kubernetes development environments using Multipass VMs. It enables developers to quickly set up fully functional Kubernetes clusters for testing, development, and learning purposes on their local machines.
## Features
- **Kubernetes Cluster**: Automated setup of a multi-node Kubernetes cluster with one control plane and multiple worker nodes
- **Modular Design**: Clean separation of provisioning, configuration, and application deployment
- **Local Storage**: Integration with Rancher's Local Path Provisioner for persistent storage
- **Minimal Requirements**: Runs on your local machine using lightweight Multipass VMs
- **Full Automation**: Simple commands to provision, configure, and clean up environments
- **Production-like Setup**: Mirrors real-world configurations for realistic testing
## Prerequisites
- [Multipass](https://canonical.com/multipass/install) - for VM provisioning
- [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/index.html) - for configuration automation
- SSH tools (OpenSSH client)
- Python 3 (required by Ansible)
## Getting Started
### Setting Up Kubernetes Cluster
## Quick Start
```bash
# Create and provision a Kubernetes cluster
./scripts/provision-kubernetes.sh
# Option 1: Using CLI tool (recommended)
./cli/install.sh # Install the CLI tool
provision # Run interactive provisioning
# To access the cluster
# Option 2: Using scripts directly
./scripts/provision-kubernetes.sh # Create Kubernetes cluster
# Access your cluster
multipass shell controlplane
kubectl get nodes
```
### Cleaning Up
## Overview
This project provides tools to create and manage local Kubernetes development environments using Multipass VMs. It enables you to quickly set up fully functional Kubernetes clusters on your local machine for testing, development, or learning.
## Installation
### Prerequisites
- **Host OS**: Ubuntu 24.04 or WSL Ubuntu 24.04 (scripts have only been tested on these platforms)
- [Multipass](https://canonical.com/multipass/install) - for VM provisioning
- [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/index.html) - for configuration
- SSH tools (OpenSSH client)
- Python 3
### CLI Tool (Recommended)
The CLI tool provides a user-friendly interface for managing your environments:
```bash
# Remove Kubernetes VMs
# Install CLI tool
./cli/install.sh
# Run the tool
provision
```
[CLI Documentation](./cli/README.md) - Detailed CLI usage and development
### Manual Scripts
Alternatively, you can use the scripts directly:
```bash
# Create Kubernetes cluster
./scripts/provision-kubernetes.sh
# Clean up Kubernetes VMs
./scripts/cleanup-kubernetes.sh
```
## Using Your Kubernetes Cluster
After provisioning, you can access your cluster:
```bash
# Connect to control plane node
multipass shell controlplane
# Check cluster status
kubectl get nodes
kubectl get pods -A
```
## Architecture
### Kubernetes Environment
- **1 Control Plane + 3 Worker Nodes**: Fully functional Kubernetes cluster
- **Calico CNI**: For pod networking (v3.29.1)
- **Local Path Provisioner**: For persistent storage
- **Customizable Resources**: Adjust CPU, memory, and disk in `ansible/defaults/kubernetes.yml`
- **Control Plane (controlplane)**: Manages the Kubernetes cluster
- **Worker Nodes (node01, node02, node03)**: Run your containerized applications
- **Networking**: Configured with Calico CNI plugin (v3.29.1)
- **Storage**: Local Path Provisioner for development persistent volumes
## Features
- **Production-like Setup**: Mimics real-world cluster structure
- **Local Storage**: Support for PersistentVolumes via Local Path Provisioner
- **Modular Design**: Clean separation of provisioning and configuration
- **Full Automation**: Simple commands to provision, configure, and clean up
## Configuration
Customize cluster settings by modifying:
Customize the cluster by modifying:
- `ansible/defaults/kubernetes.yml` - for Kubernetes configurations
- VM resources are configurable (CPU, memory, disk)
- Network settings, DNS, and more can be adjusted
## Technical Details
The project uses Ansible for configuration management with a modular structure:
- **Playbooks**: Orchestrate the entire setup process
- **Tasks**: Modular, reusable configuration steps
- **Inventories**: Automatically generated during provisioning
Kubernetes setup includes:
- Container runtime (containerd) configuration
- Kubernetes components (kubelet, kubeadm, kubectl)
- CNI networking (Calico v3.29.1)
- Storage provisioning (Rancher Local Path Provisioner)
- Comprehensive validation and testing
- `ansible/defaults/kubernetes.yml` - Kubernetes and VM settings
- VM resources (CPU, memory, disk)
- Network settings, CNI plugin, and more
## Troubleshooting
If you encounter issues:
1. Check the Ansible logs for detailed error messages
1. Check Ansible logs for detailed error messages
2. Verify VM status with `multipass list`
3. Ensure all prerequisites are properly installed
4. For Kubernetes-specific issues, shell into the control plane and use `kubectl` to investigate
3. For Kubernetes issues, use `kubectl` commands on the control plane
4. Ensure all prerequisites are properly installed
5. **Note**: This project has only been tested on Ubuntu 24.04 and WSL Ubuntu 24.04. Using other operating systems may result in compatibility issues.
## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
## License
[MIT License](LICENSE)