Skip to content

Commit 23bd508

Browse files
committed
feat: add service account, pod disruption budget, and network policy templates; update chart metadata and values
1 parent 7c37b48 commit 23bd508

19 files changed

+1376
-519
lines changed

Readme.md

Lines changed: 116 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,217 +1,182 @@
11
# DockerPoc-1
22

3-
A Spring Boot application demonstrating Docker, Kubernetes, and CI/CD best practices with GitHub Actions.
4-
5-
## 🚀 Overview
6-
7-
This project is a Spring Boot application that showcases:
8-
- Docker containerization
9-
- Kubernetes deployment
10-
- CI/CD with GitHub Actions
11-
- Remote debugging capabilities
12-
- Database integration (PostgreSQL)
13-
- API documentation with OpenAPI/Swagger
14-
- Monitoring with Spring Boot Actuator
15-
16-
## 🛠️ Tech Stack
17-
18-
- Java 17
19-
- Spring Boot 3.4.5
20-
- PostgreSQL
21-
- Docker
22-
- Kubernetes
23-
- GitHub Actions
24-
- Maven
25-
- Lombok
26-
- Spring Data JPA
27-
- SpringDoc OpenAPI
28-
- Spring Boot Actuator
29-
30-
## 📋 Prerequisites
31-
32-
- JDK 17
33-
- Maven
34-
- Docker
35-
- Kubernetes cluster (for deployment)
36-
- kubectl (for Kubernetes operations)
37-
- PostgreSQL (for production)
38-
39-
## 🏗️ Project Structure
3+
*A personal endeavor to learn and demonstrate various DevOps concepts: Docker, Kubernetes, Helm, and Terraform — all wrapped around a Spring Boot application.*
404

41-
```
42-
.
43-
├── src/ # Source code
44-
├── K8s_Yaml/ # Kubernetes manifests
45-
│ ├── App/ # Application deployments
46-
│ ├── Config/ # ConfigMaps and Secrets
47-
│ ├── Ingress/ # Ingress configurations
48-
│ ├── Network/ # Network policies
49-
│ ├── Probe/ # Health checks
50-
│ ├── RBAC/ # Role-based access control
51-
│ ├── Schedule/ # Scheduled jobs
52-
│ ├── Storage/ # Persistent storage
53-
│ └── kubevela/ # KubeVela configurations
54-
├── nginx/ # Nginx configurations
55-
├── .github/workflows/ # GitHub Actions workflows
56-
├── Dockerfile # Docker build file
57-
├── docker-compose.yml # Docker Compose configuration
58-
└── pom.xml # Maven configuration
59-
```
5+
---
6+
7+
## ✨ Project Highlights
8+
9+
* **Spring Boot Application:** A simple RESTful API built with Spring Boot, showcasing basic CRUD operations and exposing monitoring endpoints.
10+
* **Docker:** Containerization of the Spring Boot application for consistent environments.
11+
* **Kubernetes:** Deployment and management of the application on a Kubernetes cluster using various manifest types (Deployments, Services, etc.).
12+
* **Helm:** Packaging and deploying the application to Kubernetes using Helm charts for easier management and versioning.
13+
* **Terraform:** Infrastructure as Code (IaC) for provisioning and managing the necessary cloud resources (current state focuses on local configurations, but the structure is in place for cloud integration).
14+
* **CI/CD:** *(Implied/Expandable)* The project structure allows for the integration of CI/CD pipelines to automate builds, tests, and deployments.
15+
16+
---
6017

6118
## 🚀 Getting Started
6219

63-
### Local Development
20+
### 🔧 Prerequisites
6421

65-
1. Clone the repository:
66-
```bash
67-
git clone https://github.com/vishal210893/DockerPoc-1.git
68-
cd DockerPoc-1
69-
```
22+
Ensure the following are installed before you begin:
7023

71-
2. Build the application:
72-
```bash
73-
mvn clean package
74-
```
24+
* JDK 17
25+
* Maven
26+
* Docker
27+
* `kubectl`
28+
* Helm
29+
* Terraform
30+
* A running Kubernetes cluster (Minikube, Docker Desktop with Kubernetes enabled, or a cloud-based cluster)
7531

76-
3. Run with Docker Compose:
77-
```bash
78-
docker-compose up
79-
```
32+
### 📦 Cloning the Repository
33+
34+
```bash
35+
git clone https://github.com/your-username/DockerPoc-1.git
36+
cd DockerPoc-1
37+
```
38+
39+
### 🏗️ Building the Spring Boot Application
40+
41+
```bash
42+
mvn clean package
43+
```
44+
45+
This will create an executable JAR file in the `target` directory.
46+
47+
---
8048

81-
### Remote Debugging
49+
## 🐳 Docker Deployment
8250

83-
The application supports remote debugging on port 5005. To enable debugging:
51+
1. **Build the Docker Image:**
8452

85-
1. Start the application with debug mode:
8653
```bash
87-
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar target/dockerpoc-1.jar
54+
docker build -t dockerpoc-1 .
8855
```
8956

90-
2. Configure your IDE to connect to localhost:5005
57+
This command builds a Docker image named `dockerpoc-1` using the `Dockerfile` in the root directory.
9158

92-
## 🐳 Docker
59+
2. **Run the Docker Container:**
9360

94-
### Building the Image
95-
96-
```bash
97-
docker build -t dockerpoc-1 .
98-
```
61+
```bash
62+
docker run -p 8080:8080 dockerpoc-1
63+
```
9964

100-
### Running the Container
65+
This runs the Docker container and maps port 8080 on your host to port 8080 in the container.
10166

102-
```bash
103-
docker run -p 8005:8005 -p 5005:5005 dockerpoc-1
104-
```
67+
---
10568

10669
## ☸️ Kubernetes Deployment
10770

108-
### Prerequisites
109-
110-
- Kubernetes cluster
111-
- kubectl configured
112-
- Docker image pushed to registry
71+
Kubernetes manifests are located in the `K8s_Yaml` directory.
11372

114-
### Deployment Steps
73+
1. **Apply the Manifests:**
11574

116-
1. Apply Kubernetes configurations:
11775
```bash
11876
kubectl apply -f K8s_Yaml/
11977
```
12078

121-
2. Verify deployment:
79+
This command applies all the Kubernetes configuration files in the `K8s_Yaml` directory to your connected Kubernetes cluster.
80+
81+
2. **Verify the Deployment:**
82+
12283
```bash
12384
kubectl get pods
12485
kubectl get services
12586
```
12687

127-
## 🔄 CI/CD Pipeline
88+
Check the status of your pods and services to ensure the application is running correctly.
12889

129-
The project uses GitHub Actions for CI/CD. The workflow includes:
90+
---
13091

131-
1. Build and test
132-
2. Docker image creation
133-
3. Push to container registry
134-
4. Kubernetes deployment
92+
## 📈 Helm Chart Deployment
13593

136-
## 📊 Monitoring
94+
The Helm chart for this project is located in the `charts/Helm` directory.
13795

138-
The application includes Spring Boot Actuator endpoints for monitoring:
96+
1. **Add the Helm Repository (if hosted):**
97+
If you have hosted your Helm chart in a repository, you can add it using:
13998

140-
- Health check: `/actuator/health`
141-
- Metrics: `/actuator/metrics`
142-
- Info: `/actuator/info`
99+
```bash
100+
helm repo add my-repo https://your-helm-repo-url
101+
helm repo update
102+
```
143103

144-
## 📚 API Documentation
104+
2. **Install the Helm Chart:**
105+
Navigate to the `charts/Helm` directory and install the chart:
145106

146-
OpenAPI/Swagger documentation is available at:
147-
```
148-
http://localhost:8005/swagger-ui.html
149-
```
107+
```bash
108+
cd charts/Helm
109+
helm install dockerpoc-release .
110+
```
150111

151-
## 🔐 Environment Variables
112+
This will deploy the application to your Kubernetes cluster using the configurations defined in the Helm chart.
152113

153-
Key environment variables:
154-
- `SPRING_PROFILES_ACTIVE`: Application profile (default: prod)
155-
- `DB_PASSWORD`: Database password
156-
- `DEBUG_PORT`: Remote debugging port (default: 5005)
114+
3. **Uninstall the Helm Chart:**
115+
To remove the deployment created by Helm:
157116

158-
## 🛡️ Security
117+
```bash
118+
helm uninstall dockerpoc-release
119+
```
159120

160-
- RBAC configurations in `K8s_Yaml/RBAC/`
161-
- Network policies in `K8s_Yaml/Network/`
162-
- Secure secret management
121+
---
163122

164-
## 📝 Logging
123+
## 🏗️ Terraform Configuration
165124

166-
Logs are stored in the `logs/` directory and can be accessed through:
167-
- Container logs
168-
- Kubernetes pod logs
169-
- Spring Boot Actuator endpoints
125+
Terraform files are located in the `Terraform` directory. While the current configuration might be minimal, the intention is to use Terraform for provisioning infrastructure.
170126

171-
## 🔧 Troubleshooting
127+
1. **Initialize Terraform:**
172128

173-
1. Check container logs:
174129
```bash
175-
docker logs <container-id>
130+
cd Terraform
131+
terraform init
176132
```
177133

178-
2. Check Kubernetes pod logs:
134+
2. **Review the Plan:**
135+
179136
```bash
180-
kubectl logs <pod-name>
137+
terraform plan
181138
```
182139

183-
3. Verify Kubernetes resources:
140+
This command shows you the changes Terraform will make to your infrastructure.
141+
142+
3. **Apply the Configuration:**
143+
184144
```bash
185-
kubectl get all
145+
terraform apply
186146
```
187147

148+
This command applies the Terraform configuration to provision the resources.
149+
150+
---
151+
152+
## 🔍 Exploring the Application
153+
154+
Once the application is deployed, you can typically access it through a Service (Kubernetes) or by port-forwarding to a pod. Refer to the specific deployment method's documentation for details.
155+
156+
* **API Endpoints:** The Spring Boot application exposes various REST endpoints.
157+
* **Actuator Endpoints:** Monitoring information is available via Spring Boot Actuator (e.g., `/actuator/health`, `/actuator/metrics`).
158+
* **Swagger UI:** API documentation is available through Swagger UI (commonly `/swagger-ui.html`, depending on your configuration).
159+
160+
---
161+
162+
## 📚 Learning and Exploration
163+
164+
This project is designed as a learning tool. Feel free to explore the code and configurations to understand how the different technologies are integrated. Experiment with different deployment strategies, modify the application, and observe the impact on the deployment process.
165+
166+
---
167+
188168
## 🤝 Contributing
189169

190-
1. Fork the repository
191-
2. Create a feature branch
192-
3. Commit your changes
193-
4. Push to the branch
194-
5. Create a Pull Request
170+
As this is a personal learning project, contributions are not actively sought, but you are welcome to fork the repository and use it for your own learning purposes.
195171

196-
## 📄 License
172+
---
197173

198-
This project is licensed under the MIT License - see the LICENSE file for details.
174+
## 📄 License
199175

200-
## 👥 Authors
176+
This project is licensed under the **MIT License**.
201177

202-
- Vishal Kumar - [vishal210893](https://github.com/vishal210893)
178+
---
203179

204180
## 🙏 Acknowledgments
205181

206-
- Spring Boot team
207-
- Docker community
208-
- Kubernetes community
209-
210-
``` helm
211-
helm repo add vishal210893 https://vishal210893.github.io/DockerPoc-1/
212-
helm repo update vishal210893
213-
helm install dockerpoc-chart vishal210893/dockerpoc-chart --atomic
214-
helm uninstall dockerpoc-chart
215-
kc port-forward svc/ingress-nginx-controller 8080:80 -n ingress-nginx
216-
http://localhost:8080/ingress/dockerpoc/swagger-ui/index.html
217-
```
182+
Thanks to the open-source communities of Spring Boot, Docker, Kubernetes, Helm, and Terraform for providing these incredible tools.

charts/Helm/.helmignore

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# dockerpoc-chart/.helmignore
2-
# Patterns to ignore when building packages.
3-
# This will be ignored by packaging systems like Helm.
4-
1+
# Common ignores
2+
.git/
3+
.github/
4+
.vscode/
55
*.swp
6-
*.swo
7-
*~
8-
*.bak
96
*.tmp
7+
*.log
108
*.orig
11-
notes.md
12-
README.md # If you have a separate README for the chart itself
9+
.idea/
10+
Dockerfile
11+
README*.md

0 commit comments

Comments
 (0)