Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
a075303
initial- commit
sugesh-cloudops Mar 11, 2025
f6cb21a
update ci file with config changes
sugesh-cloudops Mar 11, 2025
c469fdd
update github account token
sugesh-cloudops Mar 11, 2025
d79ae86
add distribution
sugesh-cloudops Mar 11, 2025
f3798be
mvn test removed
sugesh-cloudops Mar 11, 2025
8f694c3
skip test
sugesh-cloudops Mar 11, 2025
b5f62d7
update manifest file k8s path and remove PR for main branch
sugesh-cloudops Mar 11, 2025
3a2f961
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
a19937c
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
48fb0bc
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
e5fc41f
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
fa31bf1
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
6f507d9
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
a10f251
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
a81c1d8
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
70a4008
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
39312c5
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
8bbce7a
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
a41a85d
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
d3b3621
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
266b3f8
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
27bced8
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
2601503
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
dd5b022
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
8653d47
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
1b2ff74
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
4cbdf95
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
669e70e
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
05a020c
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
a47fc80
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
a4accb0
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
4aa7f2e
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
aa7ff95
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
5a9ca9a
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
c73759f
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
f3bf599
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
48ca45f
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
40db147
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
c6d8f2f
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
d912013
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
4345a05
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
1539a66
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
3032ecb
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
e82eb36
Update Git ci changes, helm changes for monitoring and argocd
sugesh-cloudops Mar 11, 2025
553f11d
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
8219996
commented update to k8s
sugesh-cloudops Mar 11, 2025
44c88c8
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
2226466
[CI]: Update devops-coding-challenge image tag
sugesh-cloudops Mar 11, 2025
40914e1
update helm changes
sugesh-cloudops Mar 11, 2025
8f59f75
hem changes
sugesh-cloudops Mar 11, 2025
cd7fc23
Helm changes
Mar 11, 2025
dc70e63
helm changeset create my-release . --install --namespace my-namespace
sugesh-cloudops Mar 11, 2025
db88c1e
helm changes
sugesh-cloudops Mar 11, 2025
bc1119e
helm pv changes
sugesh-cloudops Mar 11, 2025
ff644a1
revert to deployment
sugesh-cloudops Mar 11, 2025
ace83a3
application.yaml file change- db
sugesh-cloudops Mar 11, 2025
af2958c
application.yml changes
sugesh-cloudops Mar 11, 2025
7e34398
update pvc
sugesh-cloudops Mar 11, 2025
ff9f318
update pvc
sugesh-cloudops Mar 11, 2025
6091546
remove pvc
sugesh-cloudops Mar 11, 2025
985b5d1
helm changes
Mar 11, 2025
f9ac178
helm changes
sugesh-cloudops Mar 11, 2025
e06e8b2
db
sugesh-cloudops Mar 11, 2025
e289da4
success changes- add missing url
Mar 12, 2025
4578a88
Update terraform files added gitignore for terraform backend statefiles
sugesh-cloudops Mar 12, 2025
9fa5850
add database secrets
Mar 12, 2025
74f45a5
Modified Solution- readme
sugesh-cloudops Mar 12, 2025
50f96f5
update readme
sugesh-cloudops Mar 12, 2025
ee5a3d1
update readme
sugesh-cloudops Mar 12, 2025
949f9cb
readme
sugesh-cloudops Mar 12, 2025
a10c77b
verify ARN identity
sugesh-cloudops Mar 12, 2025
abff835
readme
sugesh-cloudops Mar 12, 2025
b786cf8
readme update
sugesh-cloudops Mar 12, 2025
31590d2
Readme changes
sugesh-cloudops Mar 12, 2025
f5d9558
Create IAM role for GithubActions - Terraform
sugesh-cloudops Mar 14, 2025
ee6a030
Update IAM role to allow access to the GitHub Actions workflow file
sugesh-cloudops Mar 14, 2025
30ca0fb
enable debug mode
sugesh-cloudops Mar 14, 2025
3cbaa73
update CI
sugesh-cloudops Mar 14, 2025
5f568ad
Update crewmeister-ci.yml | remove debug
sugesh-cloudops Mar 14, 2025
ba459b5
Update crewmeister-ci.yml Rerun
sugesh-cloudops Mar 14, 2025
390499f
update ci
sugesh-cloudops Mar 14, 2025
1eec270
Update crewmeister-ci.yml ARN debug
sugesh-cloudops Mar 14, 2025
e8dd226
Update crewmeister-ci.yml | Analyze token
sugesh-cloudops Mar 14, 2025
6a1ea5e
Update crewmeister-ci.yml | debug
sugesh-cloudops Mar 14, 2025
f16197b
Update crewmeister-ci.yml | debug
sugesh-cloudops Mar 14, 2025
76cb389
Update crewmeister-ci.yml | remove cli
sugesh-cloudops Mar 14, 2025
68bfa3d
Update crewmeister-ci.yml | Permission
sugesh-cloudops Mar 14, 2025
d4f41f2
Update crewmeister-ci.yml
sugesh-cloudops Mar 14, 2025
27bc400
Update crewmeister-ci.yml | Pass the credentials to helm deployment
sugesh-cloudops Mar 14, 2025
2b690ea
Update crewmeister-ci.yml | debug
sugesh-cloudops Mar 14, 2025
f76fb86
Update crewmeister-ci.yml
sugesh-cloudops Mar 14, 2025
3257520
Update crewmeister-ci.yml
sugesh-cloudops Mar 14, 2025
4c63b24
Update crewmeister-ci.yml | update kubeconfig
sugesh-cloudops Mar 15, 2025
8d94b9c
Update crewmeister-ci.yml Rerun
sugesh-cloudops Mar 15, 2025
f2afda6
Update crewmeister-ci.yml | Fix AWS credentials
sugesh-cloudops Mar 15, 2025
dc96634
Update crewmeister-ci.yml
sugesh-cloudops Mar 15, 2025
7eb020e
Update crewmeister-ci.yml
sugesh-cloudops Mar 15, 2025
bebe347
Update crewmeister-ci.yml
sugesh-cloudops Mar 15, 2025
8242851
Update crewmeister-ci.yml
sugesh-cloudops Mar 15, 2025
b31071d
Update crewmeister-ci.yml
sugesh-cloudops Mar 15, 2025
9a87751
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
152972c
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
58faed9
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
ee0e34e
Update crewmeister-ci.yml | verify kubectl
sugesh-cloudops Mar 16, 2025
8e5e426
Update crewmeister-ci.yml test
sugesh-cloudops Mar 16, 2025
2411372
Update crewmeister-ci.yml attach policy
sugesh-cloudops Mar 16, 2025
ac96d32
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
e21ec8c
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
25e3a82
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
9cb85c0
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
96a4c3e
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
c5727a3
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
b09e1a5
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
a0a7396
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
be20438
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
75e583f
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
6f8430f
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
849a086
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
7291324
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
b5916fd
CI, updated with EKS update
sugesh-cloudops Mar 16, 2025
0deb6ee
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
9b1a2ac
Update crewmeister-ci.yml
sugesh-cloudops Mar 16, 2025
eef4540
Terraform update | CI update for eks-cluster
sugesh-cloudops Mar 16, 2025
dd378ec
Update Readme
sugesh-cloudops Mar 16, 2025
930907d
Merge remote-tracking branch 'origin/main' into feature/branch
sugesh-cloudops Mar 16, 2025
7068d92
remove unused folder
sugesh-cloudops Mar 16, 2025
cd22e3b
docs: refresh README with Helm, Kustomize, TLS, and AWS Secrets details
sugesh-cloudops Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
102 changes: 102 additions & 0 deletions .github/workflows/crewmeister-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: crewmeister-ci

on:
push:
branches:
- main
- feature/*

permissions:
id-token: write
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Build with Maven
run: mvn clean install -DskipTests

code-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Run Code Quality Checks
run: mvn verify

docker:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/feature/')

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract Git SHA
run: echo "IMAGE_TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build and Push Docker Image
run: |
docker buildx build --platform linux/amd64 \
-t ${{ secrets.DOCKER_USERNAME }}/devops-coding-challenge:${{ env.IMAGE_TAG }} --push .

updatek8s:
runs-on: ubuntu-latest
needs: docker
outputs:
aws_access_key_id: ${{ steps.auth.outputs.aws_access_key_id }}
aws_secret_access_key: ${{ steps.auth.outputs.aws_secret_access_key }}
aws_session_token: ${{ steps.auth.outputs.aws_session_token }}
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Configure AWS Credentials (OIDC)
id: auth
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
audience: sts.amazonaws.com

- name: Verify AWS Identity
run: aws sts get-caller-identity

- name: Update kubeconfig for EKS
run: aws eks update-kubeconfig --name ${{ secrets.EKS_CLUSTER_NAME }} --region ${{ secrets.AWS_REGION }}

- name: Deploy Helm Chart
run: |
helm upgrade --install my-app ./k8s/helm \
--namespace dev \
-f ./k8s/values/dev-values.yaml \
--set image.tag=${{ env.sha_tag }} \
--set aws.region=${{ secrets.AWS_REGION }} \

18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ build/

### VS Code ###
.vscode/
# Terraform State Files
*.tfstate
*.tfstate.backup
errored.tfstate

# Ignore Terraform lock file
.terraform.lock.hcl

# Ignore Terraform Caches and Modules
.terraform/
.terraform/*

# Ignore any sensitive variable files
*.auto.tfvars
*.tfvars.json

# Ignore generated logs or debug files
crash.log
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Build Stage
FROM eclipse-temurin:17-jdk-jammy AS builder

WORKDIR /app

# Copy Maven wrapper and pom.xml separately for better caching
COPY mvnw pom.xml ./
COPY .mvn .mvn

# Download dependencies (cache-friendly)
RUN ./mvnw dependency:go-offline

# Copy source code
COPY src ./src

# Package the application
RUN ./mvnw clean package -DskipTests

# Runtime Stage (minimal image)
FROM eclipse-temurin:17-jre-jammy

# Create a non-root user to run the app securely
RUN groupadd -r appgroup && useradd -r -g appgroup appuser

WORKDIR /app

# Copy jar from builder
COPY --from=builder /app/target/*.jar app.jar

# Change ownership for security purposes
RUN chown appuser:appgroup app.jar

USER appuser

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "app.jar"]
190 changes: 153 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,179 @@
# Crewmeister Challenge
# 🚀 Spring Boot + MySQL on Kubernetes

## Background
A production-grade Kubernetes deployment for a Spring Boot application backed by MySQL, built with security, scalability, and automation in mind.

At Crewmeister, our development team is continuously growing. We aim to hire the best educated, motivated, and enthusiastic people in the field who have fun building up Crewmeister in our vision to empower small businesses to thrive in a digital world. For this quest, we are continuously getting new applicants from all over the world. To filter which candidates could be a good fit, we provide our candidates with a coding challenge that we manually review and evaluate.
---

## 📆 Stack Overview

| Layer | Tech/Tool |
|------------------------|-----------|
| Application | Spring Boot (Java 17) |
| Database | MySQL (StatefulSet + PVC) |
| Secrets Management | AWS Secrets Manager + External Secrets Operator |
| Kubernetes Templating | Helm |
| Env-specific Overrides | Kustomize |
| CI/CD Pipeline | GitHub Actions |
| Observability | Prometheus-ready integration hooks |

---

## ✨ Key Features

| Feature | Description |
|----------------------------------|-------------|
| ✅ Dockerized Spring Boot | With Flyway DB migrations |
| ✅ MySQL via StatefulSet | With persistent volumes |
| ✅ AWS Secrets Manager | Centralized secret storage |
| ✅ External Secrets Operator | Automatic sync of AWS secrets to K8s |
| ✅ Helm Charts | Clean, reusable templating |
| ✅ Kustomize Overlays | Per-environment configurations (dev, staging, prod) |
| ✅ TLS via cert-manager + Let's Encrypt | Secure HTTPS via Ingress |
| ✅ Ingress (NGINX) | With routing, HTTPS, and rewrite support |
| ✅ Horizontal Pod Autoscaler | Auto-scales app based on CPU |
| ✅ CI/CD Pipeline | GitHub Actions with multi-stage flow |
| ✅ Secure Image Handling | Versioned image tags, no `latest` used |
| ✅ Health Probes & Limits | Readiness/liveness probes and resource limits |

---

## 📂 Folder Structure

```bash
k8s/
├── base/ # Common base manifests for Kustomize
│ ├── deployment.yaml
│ ├── mysql-service.yaml
│ ├── mysql-statefulset.yaml
│ ├── service.yaml
│ └── kustomization.yaml

├── overlays/ # Environment-specific overlays (Kustomize)
│ ├── dev/
│ │ ├── configmap.yaml
│ │ ├── kustomization.yaml
│ │ ├── mysql-external-secret.yaml
│ │ ├── namespace.yaml
│ │ ├── secret-store.yaml
│ │ └── cluster-issuer.yaml # cert-manager ClusterIssuer (staging/prod)
│ └── staging/
│ └── prod/

├── helm/ # Helm chart for full app deployment
│ ├── Chart.yaml
│ ├── values.yaml # Default config
│ └── templates/
│ ├── _helpers.tpl
│ ├── configmap-mysql.yaml
│ ├── secret-external-mysql.yaml
│ ├── secretstore-aws.yaml
│ ├── serviceaccount.yaml
│ ├── mysql/
│ │ ├── service-mysql-headless.yaml
│ │ └── statefulset-mysql.yaml
│ ├── springboot/
│ │ ├── deployment-springboot.yaml
│ │ ├── hpa-springboot.yaml
│ │ ├── ingress-springboot.yaml
│ │ └── service-springboot.yaml
│ └── tests/
│ └── test-connection.yaml

├── values/ # Helm values per environment
│ ├── dev-values.yaml
│ ├── staging-values.yaml
│ └── prod-values.yaml

.github/
└── workflows/
└── crewmeister-ci.yaml # CI/CD pipeline definition
```

---

## 🛠️ Usage Guide

### ✅ Apply Kustomize Overlay (Dev)

```bash
kubectl apply -k k8s/overlays/dev
```

### ❌ Delete Dev Resources

```bash
kubectl delete -k k8s/overlays/dev
```

---

## DevOps Engineer Task
### 🥤 Helm Usage

As a DevOps Engineer at Crewmeister, you will be in charge of several challenging tasks in your daily work. One of your core responsibilities will be to ensure that the system is always running smoothly and that the application is deployed successfully to our customers.
```bash
# Install
helm install my-app ./k8s/helm -f ./k8s/values/dev-values.yaml

In this challenge, you should use DevOps best practices to architect and implement the complete cycle of building, packaging, and deploying a Java application (specified later in this document).
# Upgrade
helm upgrade my-app ./k8s/helm -f ./k8s/values/dev-values.yaml

The following are core technologies/tools that should be present in the solution:
# Uninstall
helm uninstall my-app
```

- Dockerfile
- Helm Chart
- Terraform to interact with the Kubernetes cluster
---

You have the flexibility to utilize any cloud provider of your choice to deploy and run the application effectively. Additionally, it should be designed to operate seamlessly on local machines, allowing for a versatile setup that caters to various operational preferences and environments.
### 🌐 Port Forward for Local Access

## Plus:
```bash
kubectl port-forward svc/my-app-service -n dev 8080:80
```

- Create a CI Pipeline in Github to automate the application lifecycle
Then access: [http://localhost:8080](http://localhost:8080)

- Add monitoring tools to check the health of the application
---

## Important Points:
## 🔐 AWS Secrets Setup

- At Crewmeister, we value creativity and pushing for better. You are encouraged to expand the solution as you find fit. To do so, you must ensure high-quality documentation and that the base solution is correctly executed.
- All the tools used must be publicly accessible or explicitly documented on how to authenticate.
- All the tools must be free to use.
Before deploying, manually create the AWS credentials secret in your cluster:

## Challenge Application
```bash
kubectl create secret generic aws-credentials \
--from-literal=access-key-id=<AWS_ACCESS_KEY_ID> \
--from-literal=secret-access-key=<AWS_SECRET_ACCESS_KEY>
```

A Spring Boot application that provides a simple user management REST API.
> **Note**: Never commit your AWS credentials to Git or store them in `values.yaml`.

### Technologies Used
---

- Java 17
- Spring Boot 3.3.5
- MySQL Database
- Flyway Migration
- Maven
- Spring Data JPA
- Spring Actuator
## ⚙️ GitHub Actions CI/CD (`.github/workflows/crewmeister-ci.yaml`)

### Pre-requisites
| Stage | Description |
|---------------|-------------|
| `build` | Compiles the app with Maven |
| `code-quality`| Runs linting/tests |
| `docker` | Builds versioned image, pushes to Docker Hub |
| `updatek8s` | Deploys Helm chart to EKS using OIDC-authenticated GitHub Action |

- JDK 17
- MySQL
- Maven
---

### API Endpoints
## 🌟 Observability & Reliability

#### GET /user
- ✅ `readinessProbe` and `livenessProbe` configured
- ✅ `resources.requests` and `limits` defined for CPU/memory
- ✅ Horizontal Pod Autoscaler enabled for autoscaling
- ✅ Ingress TLS via cert-manager (staging & prod)
- ✅ Prepped for Prometheus metrics

---

Retrieves a user by ID
## ✅ Best Practices Followed

#### POST /user
- No use of `:latest` tag in Docker builds
- All secrets pulled dynamically via AWS Secret Manager
- Values managed via Helm `values.yaml`
- GitOps-compatible structure via Kustomize overlays
- Externalized environment handling
- Linted and validated YAML
- Modular and extensible folder layout

Creates a new user
Binary file added Terraform/.DS_Store
Binary file not shown.
Loading