Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: K8S changes for replacing docker-compose - Do not merge #11

Closed
wants to merge 1 commit into from
Closed
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
50 changes: 50 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
minikube start --driver=docker
echo "-------minikube status"
minikube status
echo "-------/"
# Define paths to YAML files
PVC_FILES=(
"k8s/data/mongo-data-persistentvolumeclaim.yaml"
"k8s/data/postgres-data-persistentvolumeclaim.yaml"
"k8s/data/sonarqube-data-persistentvolumeclaim.yaml"
)

DEPLOYMENTS_SERVICES_FILES=(
"k8s/deploy/kafka-deployment.yaml"
"k8s/deploy/mongodb-deployment.yaml"
"k8s/deploy/postgres-deployment.yaml"
"k8s/deploy/sonarqube-deployment.yaml"
"k8s/deploy/zookeeper-deployment.yaml"
"k8s/service/kafka-service.yaml"
"k8s/service/mongodb-service.yaml"
"k8s/service/postgres-service.yaml"
"k8s/service/sonarqube-service.yaml"
"k8s/service/zookeeper-service.yaml"
)

# Apply Persistent Volume Claims
echo "-------Applying Persistent Volume Claims..."
for pvc in "${PVC_FILES[@]}"; do
kubectl apply -f "$pvc"
done

# Apply Deployments and Services
echo "-------Applying Deployments and Services..."
for file in "${DEPLOYMENTS_SERVICES_FILES[@]}"; do
kubectl apply -f "$file"
done

# Wait for Pods to be ready
echo "-------Waiting for Pods to be ready..."
kubectl wait --for=condition=ready pod --all --timeout=5m

# Check Pod status
echo "-------Checking Pod status..."
kubectl get pods

# Display Service URLs
echo "-------Retrieving service details..."
kubectl get services

echo "-------Deployment completed. Access your services as needed."
64 changes: 0 additions & 64 deletions docker-compose.yml

This file was deleted.

10 changes: 10 additions & 0 deletions k8s/data/mongo-data-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongo-data-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
10 changes: 10 additions & 0 deletions k8s/data/postgres-data-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-data-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
10 changes: 10 additions & 0 deletions k8s/data/sonarqube-data-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: sonarqube-data-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
33 changes: 33 additions & 0 deletions k8s/deploy/kafka-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: kafka
spec:
replicas: 1
selector:
matchLabels:
app: kafka
template:
metadata:
labels:
app: kafka
spec:
containers:
- name: kafka
image: wurstmeister/kafka:latest
ports:
- containerPort: 9092
- containerPort: 9093
env:
- name: KAFKA_ADVERTISED_LISTENERS
value: "INSIDE://kafka:9093,OUTSIDE://localhost:9092"
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
value: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
- name: KAFKA_LISTENERS
value: "INSIDE://0.0.0.0:9093,OUTSIDE://0.0.0.0:9092"
- name: KAFKA_INTER_BROKER_LISTENER_NAME
value: "INSIDE"
- name: KAFKA_ZOOKEEPER_CONNECT
value: "zookeeper:2181"
- name: KAFKA_CREATE_TOPICS
value: "my-topic:1:1"
31 changes: 31 additions & 0 deletions k8s/deploy/mongodb-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongodb
spec:
replicas: 1
selector:
matchLabels:
app: mongodb
template:
metadata:
labels:
app: mongodb
spec:
containers:
- name: mongodb
image: mongo:latest
ports:
- containerPort: 27017
env:
- name: MONGO_INITDB_ROOT_USERNAME
value: "root"
- name: MONGO_INITDB_ROOT_PASSWORD
value: "example"
volumeMounts:
- name: mongo-data
mountPath: /data/db
volumes:
- name: mongo-data
persistentVolumeClaim:
claimName: mongo-data-pvc
33 changes: 33 additions & 0 deletions k8s/deploy/postgres-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
value: "sonar"
- name: POSTGRES_USER
value: "sonar"
- name: POSTGRES_PASSWORD
value: "sonar"
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-data-pvc
43 changes: 43 additions & 0 deletions k8s/deploy/sonarqube-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: sonarqube
spec:
replicas: 1
selector:
matchLabels:
app: sonarqube
template:
metadata:
labels:
app: sonarqube
spec:
containers:
- name: sonarqube
image: sonarqube
ports:
- containerPort: 9000
env:
- name: SONAR_JDBC_URL
value: "jdbc:postgresql://postgres:5432/sonar"
- name: SONAR_JDBC_USERNAME
value: "sonar"
- name: SONAR_JDBC_PASSWORD
value: "sonar"
volumeMounts:
- name: sonarqube-data
mountPath: /opt/sonarqube/data
- name: sonarqube-logs
mountPath: /opt/sonarqube/logs
- name: sonarqube-extensions
mountPath: /opt/sonarqube/extensions
volumes:
- name: sonarqube-data
persistentVolumeClaim:
claimName: sonarqube-data-pvc
- name: sonarqube-logs
persistentVolumeClaim:
claimName: sonarqube-logs-pvc
- name: sonarqube-extensions
persistentVolumeClaim:
claimName: sonarqube-extensions-pvc
19 changes: 19 additions & 0 deletions k8s/deploy/zookeeper-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: zookeeper
spec:
replicas: 1
selector:
matchLabels:
app: zookeeper
template:
metadata:
labels:
app: zookeeper
spec:
containers:
- name: zookeeper
image: wurstmeister/zookeeper:latest
ports:
- containerPort: 2181
12 changes: 12 additions & 0 deletions k8s/service/kafka-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: kafka
spec:
ports:
- port: 9092
targetPort: 9092
- port: 9093
targetPort: 9093
selector:
app: kafka
10 changes: 10 additions & 0 deletions k8s/service/mongodb-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: mongodb
spec:
ports:
- port: 27017
targetPort: 27017
selector:
app: mongodb
10 changes: 10 additions & 0 deletions k8s/service/postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: postgres
10 changes: 10 additions & 0 deletions k8s/service/sonarqube-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: sonarqube
spec:
ports:
- port: 9000
targetPort: 9000
selector:
app: sonarqube
10 changes: 10 additions & 0 deletions k8s/service/zookeeper-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: zookeeper
spec:
ports:
- port: 2181
targetPort: 2181
selector:
app: zookeeper
Loading