Skip to content

Commit

Permalink
Merge pull request #54 from igh9410/dev
Browse files Browse the repository at this point in the history
Dealing with Statefulset
  • Loading branch information
igh9410 authored May 29, 2024
2 parents 6496a16 + 15f323d commit ef18c22
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 24 deletions.
4 changes: 2 additions & 2 deletions backend/cmd/blabber-hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func main() {

kafkaProducer, err := kafka.KafkaProducer()
if err != nil {
log.Printf("Failed to initialize Kafka producer")
log.Fatalf("Failed to initialize Kafka producer: %s", err)
}
defer kafkaProducer.Close()

Expand Down Expand Up @@ -102,7 +102,7 @@ func main() {
defer batchProcessor.Stop()

if _, err := kafka.KafkaConsumer(batchProcessor); err != nil {
log.Printf("Failed to initialize Kafka consumer: %s", err)
log.Fatalf("Failed to initialize Kafka consumer: %s", err)
}

routerConfig := &router.RouterConfig{
Expand Down
12 changes: 0 additions & 12 deletions k8s/kafka/broker-claim0-persistentvolumeclaim.yaml

This file was deleted.

10 changes: 6 additions & 4 deletions k8s/kafka/broker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ spec:
value: "1"
- name: KAFKA_ZOOKEEPER_CONNECT
value: zookeeper:2181
- name: KAFKA_LOG4J_ROOT_LOGLEVEL
value: DEBUG
image: confluentinc/cp-kafka:7.4.3
name: blabber-hive-broker
ports:
- containerPort: 9092
hostPort: 9092
protocol: TCP
volumeMounts:
- mountPath: /wait-for-it.sh
name: broker-claim0
- mountPath: /var/lib/kafka
name: kafka-data
restartPolicy: Always
volumes:
- name: broker-claim0
- name: kafka-data
persistentVolumeClaim:
claimName: broker-claim0
claimName: kafka-data-pvc
28 changes: 28 additions & 0 deletions k8s/kafka/broker-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: kafka-broker-pv
spec:
capacity:
storage: 1Gi # Adjust the storage size as needed
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: hostpath
hostPath:
path: /media/mint/linux-1/k8s/kafka # Adjust the path to match your Kafka data directory on the host
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
io.kompose.service: broker
name: kafka-data-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
volumeName: kafka-broker-pv
storageClassName: hostpath
3 changes: 2 additions & 1 deletion k8s/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resources:
- fastapi/fastapi-service.yaml
- grafana/grafana-deployment.yaml
- grafana/grafana-service.yaml
- kafka/broker-claim0-persistentvolumeclaim.yaml
- kafka/broker-pv.yaml
- kafka/broker-deployment.yaml
- kafka/broker-service.yaml
#- kafka/broker-jobs.yaml
Expand All @@ -15,6 +15,7 @@ resources:
- nginx/nginx-deployment.yaml
- nginx/nginx-service.yaml
- postgres/postgres-service.yaml
- postgres/postgres-pv.yaml
- postgres/postgres-env-docker-configmap.yaml
- prometheus/prometheus-cm0-configmap.yaml
- prometheus/prometheus-deployment.yaml
Expand Down
14 changes: 14 additions & 0 deletions k8s/postgres/postgres-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PersistentVolume for Postgres
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgres-pv
spec:
capacity:
storage: 20Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: hostpath
hostPath:
path: /media/mint/linux-1/k8s/postgres
14 changes: 9 additions & 5 deletions k8s/postgres/postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -133,7 +132,12 @@ spec:
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres-data
hostPath:
path: /home/geonhyuk/Documents/CS/Projects/blabber-hive/database
volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 20Gi
storageClassName: hostpath

0 comments on commit ef18c22

Please sign in to comment.