Skip to content

Commit 2913837

Browse files
author
Your Name
committed
Add .gitignore, LICENSE, and update README with project details and instructions
1 parent 9690126 commit 2913837

File tree

4 files changed

+310
-7
lines changed

4 files changed

+310
-7
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Vagrant specific
2+
.vagrant/
3+
*.log
4+
5+
# Virtual machine files
6+
*.box
7+
*.vdi
8+
*.vmdk
9+
*.vhd
10+
11+
# OS specific files
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Environment files
16+
.env
17+
*.env
18+
19+
# IDE specific files
20+
.vscode/
21+
.idea/
22+
*.swp
23+
*.swo
24+
25+
# Temporary files
26+
*.tmp
27+
*~

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Vagrant Kubernetes Cluster
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 255 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,255 @@
1-
# vagrant
1+
# Vagrant Kubernetes Cluster
2+
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4+
[![Vagrant](https://img.shields.io/badge/vagrant-%231563FF.svg?style=for-the-badge&logo=vagrant&logoColor=white)](https://www.vagrantup.com/)
5+
[![Kubernetes](https://img.shields.io/badge/kubernetes-%23326ce5.svg?style=for-the-badge&logo=kubernetes&logoColor=white)](https://kubernetes.io/)
6+
[![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white)](https://ubuntu.com/)
7+
8+
This project sets up a local Kubernetes cluster using Vagrant and VirtualBox. It creates two Ubuntu 22.04 virtual machines: one master node and one worker node with automatic installation of Docker, Kubernetes components, and necessary configurations.
9+
10+
## Architecture
11+
12+
```mermaid
13+
graph TB
14+
subgraph Vagrant-Managed Environment
15+
subgraph Master Node
16+
A[Control Plane] --> B[API Server]
17+
B --> C[etcd]
18+
B --> D[Controller Manager]
19+
B --> E[Scheduler]
20+
end
21+
subgraph Worker Node
22+
F[kubelet] --> G[Container Runtime]
23+
H[kube-proxy] --> G
24+
end
25+
B <-.-> F
26+
B <-.-> H
27+
end
28+
style Master Node fill:#f9f,stroke:#333,stroke-width:2px
29+
style Worker Node fill:#bbf,stroke:#333,stroke-width:2px
30+
```
31+
32+
![Cluster Network](https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png)
33+
34+
## Prerequisites
35+
36+
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
37+
- [Vagrant](https://www.vagrantup.com/downloads)
38+
- At least 4GB of RAM available
39+
- At least 20GB of free disk space
40+
41+
## ✨ Features
42+
43+
<table>
44+
<tr>
45+
<td align="center">🔄</td>
46+
<td>Automated VM provisioning with Ubuntu 22.04</td>
47+
</tr>
48+
<tr>
49+
<td align="center">🌐</td>
50+
<td>Pre-configured network settings</td>
51+
</tr>
52+
<tr>
53+
<td align="center">🐳</td>
54+
<td>Automatic installation of Docker and Kubernetes components</td>
55+
</tr>
56+
<tr>
57+
<td align="center">🚀</td>
58+
<td>Ready-to-use Kubernetes cluster setup</td>
59+
</tr>
60+
<tr>
61+
<td align="center">🔒</td>
62+
<td>Secure communication between nodes</td>
63+
</tr>
64+
<tr>
65+
<td align="center">🔍</td>
66+
<td>Easy monitoring and management</td>
67+
</tr>
68+
</table>
69+
70+
## 🖥 Cluster Configuration
71+
72+
> **Note about IP Addressing**: This configuration uses `192.168.63.1` and `192.168.63.2` for the master and worker nodes respectively. You can modify these IPs in the `Vagrantfile` to use any IP addresses from your router's IP range that are outside the DHCP scope. Make sure to choose IPs that won't conflict with other devices on your network.
73+
74+
<table>
75+
<tr>
76+
<th width="50%">Master Node</th>
77+
<th width="50%">Worker Node</th>
78+
</tr>
79+
<tr>
80+
<td>
81+
82+
```yaml
83+
IP: 192.168.63.1
84+
Hostname: master
85+
Memory: 2048MB
86+
CPUs: 2
87+
Role: Control Plane
88+
```
89+
90+
</td>
91+
<td>
92+
93+
```yaml
94+
IP: 192.168.63.2
95+
Hostname: worker
96+
Memory: 2048MB
97+
CPUs: 2
98+
Role: Worker
99+
```
100+
101+
</td>
102+
</tr>
103+
</table>
104+
105+
![Cluster Diagram](https://d33wubrfki0l68.cloudfront.net/2475489eaf20163ec0f54ddc1d92aa8d4c87c96b/e7c81/images/docs/components-of-kubernetes.svg)
106+
107+
## Quick Start
108+
109+
> **💡 Tip**: Before starting, you may want to adjust the IP addresses in the `Vagrantfile` if the default IPs (`192.168.63.1, 192.168.63.2`) conflict with your network setup. Edit the `private_network` IP settings in the Vagrantfile to match your network requirements.
110+
111+
1. Clone this repository:
112+
```bash
113+
git clone <repository-url>
114+
cd vagrant
115+
```
116+
117+
2. Start the cluster:
118+
```bash
119+
vagrant up
120+
```
121+
122+
3. SSH into the master node:
123+
```bash
124+
vagrant ssh master
125+
```
126+
127+
4. SSH into the worker node:
128+
```bash
129+
vagrant ssh worker
130+
```
131+
132+
5. Stop the cluster:
133+
```bash
134+
vagrant halt
135+
```
136+
137+
6. Destroy the cluster:
138+
```bash
139+
vagrant destroy
140+
```
141+
142+
## 🛠 Components Installed
143+
144+
<details>
145+
<summary>Click to expand installed components</summary>
146+
147+
| Component | Version | Description |
148+
|-----------|---------|-------------|
149+
| Docker CE | Latest | Container runtime engine |
150+
| kubelet | Latest | Node agent |
151+
| kubeadm | Latest | Cluster bootstrapping tool |
152+
| kubectl | Latest | Command-line interface |
153+
| containerd | Latest | Container runtime |
154+
| Weave CNI | v2.8.1 | Container Network Interface |
155+
156+
</details>
157+
158+
## Cluster Setup Instructions
159+
160+
After the VMs are up and running, follow these steps to initialize your Kubernetes cluster:
161+
162+
### 1. On Master Node
163+
164+
First, log into the master node:
165+
```bash
166+
vagrant ssh master
167+
```
168+
169+
Pull required Kubernetes images:
170+
```bash
171+
sudo kubeadm config images pull
172+
```
173+
174+
Initialize the cluster:
175+
```bash
176+
sudo kubeadm init --pod-network-cidr=10.201.0.0/16 --apiserver-advertise-address=192.168.63.1
177+
```
178+
179+
### 2. Install CNI (Container Network Interface)
180+
181+
After the cluster initialization, install Weave CNI:
182+
```bash
183+
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
184+
```
185+
186+
### 3. Join Worker Node
187+
188+
Copy the `kubeadm join` command from the master node's initialization output and run it on the worker node with sudo privileges.
189+
190+
### 4. Verify Cluster Status
191+
192+
After joining the worker node, verify the cluster status from the master node:
193+
194+
```bash
195+
# Check node status
196+
kubectl get nodes
197+
```
198+
199+
Expected output (it may take a few minutes for the nodes to be ready):
200+
```
201+
NAME STATUS ROLES AGE VERSION
202+
master Ready control-plane 5m32s v1.30.x
203+
worker Ready <none> 2m14s v1.30.x
204+
```
205+
206+
> **Note**: The nodes may show `NotReady` status initially as the CNI (Container Network Interface) is being configured. Please wait a few minutes for the status to change to `Ready`.
207+
208+
### Troubleshooting
209+
210+
If you encounter issues while joining the worker node, try these steps on both nodes:
211+
212+
1. Reset the cluster configuration:
213+
```bash
214+
sudo kubeadm reset
215+
```
216+
217+
2. Perform system cleanup:
218+
```bash
219+
sudo swapoff -a
220+
sudo systemctl restart kubelet
221+
sudo iptables -F
222+
sudo rm -rf /var/lib/cni/
223+
sudo systemctl restart containerd
224+
sudo systemctl daemon-reload
225+
```
226+
227+
3. After cleanup, retry the cluster initialization on master and join command on worker.
228+
229+
## Default Credentials
230+
231+
- Username: vagrant
232+
- Password: vagrant
233+
234+
## License
235+
236+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
237+
238+
Copyright (c) 2024 Vagrant Kubernetes Cluster
239+
240+
## 📫 Support & Contribution
241+
242+
If you encounter any issues or need assistance:
243+
244+
[![Create Issue](https://img.shields.io/badge/Create-Issue-green.svg)](https://github.com/yourusername/vagrant-kubernetes/issues/new)
245+
[![Pull Request](https://img.shields.io/badge/Pull-Request-blue.svg)](https://github.com/yourusername/vagrant-kubernetes/pulls)
246+
247+
## 📝 License
248+
249+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
250+
251+
---
252+
253+
<div align="center">
254+
Made with ❤️ for the Kubernetes community
255+
</div>

instructions.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
TO SPEED UP THE PROCESS 1ST RUN -
2-
sudo kubeadm config images pull
1+
TO SPEED UP THE PROCESS 1ST RUN in the master NODE-
2+
- sudo kubeadm config images pull
33

4-
TO INIT, RUN -
5-
sudo kubeadm init --pod-network-cidr=10.201.0.0/16 --apiserver-advertise-address=192.168.63.1
4+
TO INIT, RUN in the master NODE-
5+
- sudo kubeadm init --pod-network-cidr=10.201.0.0/16 --apiserver-advertise-address=192.168.63.1
6+
- you wull get a kubeadm join command run that in you master node after Install the CNI
67

78
TO INSTALL CNI (weave) -
8-
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
9+
- kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
910

10-
IF face proble while jioning worker node -
11+
IF face proble while jioning worker node, reatart master node and run below commands-
1112
sudo kubeadm reset
1213

1314
sudo swapoff -a => all nodes.

0 commit comments

Comments
 (0)