Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
89 changes: 86 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ containerization, CI/CD, Kubernetes deployment, and Terraform infrastructure.

```text
http-server-devops/
├── .github/
├── .github/ # GitHub Actions workflows
│ └── workflows/
│ └── docker-publish.yml
├── k8s/ # Kubernetes manifests
├── k8s/ # Kubernetes manifests
│ └── namespace.yaml
│ └── deployment.yaml
│ └── service.yaml
├── terraform/ # Terraform configuration
├── Dockerfile
├── go.mod
Expand All @@ -33,7 +36,7 @@ http-server-devops/
- [x] Task 1: HTTP Server
- [x] Task 2: Dockerize
- [x] Task 3: CI/CD Pipeline
- [ ] Task 4: Kubernetes Deployment
- [x] Task 4: Kubernetes Deployment
- [ ] Task 5: Terraform Configuration

## Installation & Usage
Expand Down Expand Up @@ -137,3 +140,83 @@ permissions:
```

No external Docker registry credentials are required.

## Kubernetes Deployment

The application can be deployed to a local Kubernetes cluster using minikube.

### Start minikube

```bash
minikube start -p http-server-devops
```

### Check cluster status

```bash
minikube status -p http-server-devops
kubectl config current-context
kubectl get nodes
```

### Deploy application

```bash
kubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
```

### Check resources

```bash
kubectl get all -n http-server-devops
```

### Access application

```bash
minikube service http-server -n http-server-devops --url -p http-server-devops
```

Use the returned URL:

```bash
curl <URL>
```

Expected response:

```text
Hello, World!
```

Health check

```bash
curl <URL>/health
```

Expected response:

```text
ok
```

### Remove deployment

```bash
kubectl delete namespace http-server-devops
```

### Delete local cluster

```bash
minikube delete -p http-server-devops
```

The deployment uses the released image:

```text
ghcr.io/aldriondev/http-server-devops:latest
```
45 changes: 45 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-server
namespace: http-server-devops
labels:
app: http-server
spec:
replicas: 2
selector:
matchLabels:
app: http-server
template:
metadata:
labels:
app: http-server
spec:
containers:
- name: http-server
image: ghcr.io/aldriondev/http-server-devops:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
env:
- name: PORT
value: "8080"
resources:
requests:
memory: "64Mi"
cpu: "50m"
limits:
memory: "128Mi"
cpu: "250m"
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 3
periodSeconds: 10
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 20
4 changes: 4 additions & 0 deletions k8s/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: http-server-devops
15 changes: 15 additions & 0 deletions k8s/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: http-server
namespace: http-server-devops
labels:
app: http-server
spec:
type: NodePort
selector:
app: http-server
ports:
- protocol: TCP
port: 80
targetPort: 8080
Loading