Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 5feed0e

Browse files
committed
K8S changes for replacing docker-compose
1 parent 7e61087 commit 5feed0e

15 files changed

+291
-64
lines changed

deploy.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
minikube start --driver=docker
3+
echo "-------minikube status"
4+
minikube status
5+
echo "-------/"
6+
# Define paths to YAML files
7+
PVC_FILES=(
8+
"k8s/data/mongo-data-persistentvolumeclaim.yaml"
9+
"k8s/data/postgres-data-persistentvolumeclaim.yaml"
10+
"k8s/data/sonarqube-data-persistentvolumeclaim.yaml"
11+
)
12+
13+
DEPLOYMENTS_SERVICES_FILES=(
14+
"k8s/deploy/kafka-deployment.yaml"
15+
"k8s/deploy/mongodb-deployment.yaml"
16+
"k8s/deploy/postgres-deployment.yaml"
17+
"k8s/deploy/sonarqube-deployment.yaml"
18+
"k8s/deploy/zookeeper-deployment.yaml"
19+
"k8s/service/kafka-service.yaml"
20+
"k8s/service/mongodb-service.yaml"
21+
"k8s/service/postgres-service.yaml"
22+
"k8s/service/sonarqube-service.yaml"
23+
"k8s/service/zookeeper-service.yaml"
24+
)
25+
26+
# Apply Persistent Volume Claims
27+
echo "-------Applying Persistent Volume Claims..."
28+
for pvc in "${PVC_FILES[@]}"; do
29+
kubectl apply -f "$pvc"
30+
done
31+
32+
# Apply Deployments and Services
33+
echo "-------Applying Deployments and Services..."
34+
for file in "${DEPLOYMENTS_SERVICES_FILES[@]}"; do
35+
kubectl apply -f "$file"
36+
done
37+
38+
# Wait for Pods to be ready
39+
echo "-------Waiting for Pods to be ready..."
40+
kubectl wait --for=condition=ready pod --all --timeout=5m
41+
42+
# Check Pod status
43+
echo "-------Checking Pod status..."
44+
kubectl get pods
45+
46+
# Display Service URLs
47+
echo "-------Retrieving service details..."
48+
kubectl get services
49+
50+
echo "-------Deployment completed. Access your services as needed."

docker-compose.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: mongo-data-pvc
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 5Gi
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: postgres-data-pvc
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 10Gi
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: sonarqube-data-pvc
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 10Gi

k8s/deploy/kafka-deployment.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: kafka
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: kafka
10+
template:
11+
metadata:
12+
labels:
13+
app: kafka
14+
spec:
15+
containers:
16+
- name: kafka
17+
image: wurstmeister/kafka:latest
18+
ports:
19+
- containerPort: 9092
20+
- containerPort: 9093
21+
env:
22+
- name: KAFKA_ADVERTISED_LISTENERS
23+
value: "INSIDE://kafka:9093,OUTSIDE://localhost:9092"
24+
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
25+
value: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
26+
- name: KAFKA_LISTENERS
27+
value: "INSIDE://0.0.0.0:9093,OUTSIDE://0.0.0.0:9092"
28+
- name: KAFKA_INTER_BROKER_LISTENER_NAME
29+
value: "INSIDE"
30+
- name: KAFKA_ZOOKEEPER_CONNECT
31+
value: "zookeeper:2181"
32+
- name: KAFKA_CREATE_TOPICS
33+
value: "my-topic:1:1"

k8s/deploy/mongodb-deployment.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: mongodb
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: mongodb
10+
template:
11+
metadata:
12+
labels:
13+
app: mongodb
14+
spec:
15+
containers:
16+
- name: mongodb
17+
image: mongo:latest
18+
ports:
19+
- containerPort: 27017
20+
env:
21+
- name: MONGO_INITDB_ROOT_USERNAME
22+
value: "root"
23+
- name: MONGO_INITDB_ROOT_PASSWORD
24+
value: "example"
25+
volumeMounts:
26+
- name: mongo-data
27+
mountPath: /data/db
28+
volumes:
29+
- name: mongo-data
30+
persistentVolumeClaim:
31+
claimName: mongo-data-pvc

k8s/deploy/postgres-deployment.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: postgres
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: postgres
10+
template:
11+
metadata:
12+
labels:
13+
app: postgres
14+
spec:
15+
containers:
16+
- name: postgres
17+
image: postgres
18+
ports:
19+
- containerPort: 5432
20+
env:
21+
- name: POSTGRES_DB
22+
value: "sonar"
23+
- name: POSTGRES_USER
24+
value: "sonar"
25+
- name: POSTGRES_PASSWORD
26+
value: "sonar"
27+
volumeMounts:
28+
- name: postgres-data
29+
mountPath: /var/lib/postgresql/data
30+
volumes:
31+
- name: postgres-data
32+
persistentVolumeClaim:
33+
claimName: postgres-data-pvc

k8s/deploy/sonarqube-deployment.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: sonarqube
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: sonarqube
10+
template:
11+
metadata:
12+
labels:
13+
app: sonarqube
14+
spec:
15+
containers:
16+
- name: sonarqube
17+
image: sonarqube
18+
ports:
19+
- containerPort: 9000
20+
env:
21+
- name: SONAR_JDBC_URL
22+
value: "jdbc:postgresql://postgres:5432/sonar"
23+
- name: SONAR_JDBC_USERNAME
24+
value: "sonar"
25+
- name: SONAR_JDBC_PASSWORD
26+
value: "sonar"
27+
volumeMounts:
28+
- name: sonarqube-data
29+
mountPath: /opt/sonarqube/data
30+
- name: sonarqube-logs
31+
mountPath: /opt/sonarqube/logs
32+
- name: sonarqube-extensions
33+
mountPath: /opt/sonarqube/extensions
34+
volumes:
35+
- name: sonarqube-data
36+
persistentVolumeClaim:
37+
claimName: sonarqube-data-pvc
38+
- name: sonarqube-logs
39+
persistentVolumeClaim:
40+
claimName: sonarqube-logs-pvc
41+
- name: sonarqube-extensions
42+
persistentVolumeClaim:
43+
claimName: sonarqube-extensions-pvc

k8s/deploy/zookeeper-deployment.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: zookeeper
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: zookeeper
10+
template:
11+
metadata:
12+
labels:
13+
app: zookeeper
14+
spec:
15+
containers:
16+
- name: zookeeper
17+
image: wurstmeister/zookeeper:latest
18+
ports:
19+
- containerPort: 2181

k8s/service/kafka-service.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: kafka
5+
spec:
6+
ports:
7+
- port: 9092
8+
targetPort: 9092
9+
- port: 9093
10+
targetPort: 9093
11+
selector:
12+
app: kafka

k8s/service/mongodb-service.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mongodb
5+
spec:
6+
ports:
7+
- port: 27017
8+
targetPort: 27017
9+
selector:
10+
app: mongodb

k8s/service/postgres-service.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: postgres
5+
spec:
6+
ports:
7+
- port: 5432
8+
targetPort: 5432
9+
selector:
10+
app: postgres

k8s/service/sonarqube-service.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: sonarqube
5+
spec:
6+
ports:
7+
- port: 9000
8+
targetPort: 9000
9+
selector:
10+
app: sonarqube

k8s/service/zookeeper-service.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: zookeeper
5+
spec:
6+
ports:
7+
- port: 2181
8+
targetPort: 2181
9+
selector:
10+
app: zookeeper

0 commit comments

Comments
 (0)