Skip to content

Commit

Permalink
uf
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamv108 committed Aug 29, 2023
1 parent 52490de commit 642cd53
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ setup: teardown build
start-services:
$(call start-services)

local-app: build-local
local-app: build
$(call local-app)

teardown:
Expand Down
10 changes: 7 additions & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ services:

environment:
- SLEEP_LENGTH=5
- spring.datasource.url=jdbc:mysql://mysql:3306/sse?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false&autoReconnect=true&allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true
- spring.datasource.username=test
- spring.datasource.password=root1234
- spring.kafka.bootstrap-servers=kafka:9092

mysql:
image: 'mysql:latest'
environment:
- 'MYSQL_DATABASE=sse'
# - 'MYSQL_PASSWORD=root1234'
- 'MYSQL_PASSWORD=root1234'
- 'MYSQL_ROOT_PASSWORD=root1234'
# - 'MYSQL_USER=root'
- 'MYSQL_USER=test'
ports:
- '3306:3306'

Expand All @@ -55,7 +59,7 @@ services:
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
2 changes: 1 addition & 1 deletion k8s/base-setup.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kubectl apply -f ./namespace-kafka.yaml
kubectl apply -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka
#kubectl apply -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka
171 changes: 133 additions & 38 deletions k8s/kafka.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,140 @@
apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
#apiVersion: kafka.strimzi.io/v1beta2
#kind: Kafka
#metadata:
# name: kafka-cluster
# namespace: kafka
#spec:
# kafka:
# version: 3.3.1
# replicas: 3
# listeners:
# - name: plain
# port: 9092
# type: internal
# tls: false
# - name: tls
# port: 9093
# type: internal
# tls: true
# config:
# offsets.topic.replication.factor: 1
# transaction.state.log.replication.factor: 1
# transaction.state.log.min.isr: 1
# default.replication.factor: 1
# min.insync.replicas: 1
# inter.broker.protocol.version: "3.3"
# storage:
# type: ephemeral
# zookeeper:
# replicas: 1
# storage:
# type: ephemeral
# entityOperator:
# topicOperator: {}
# userOperator: {}
#---
##apiVersion: kafka.strimzi.io/v1beta1
##kind: KafkaTopic
##metadata:
## name: userevents
## labels:
## strimzi.io/cluster: "kafka-cluster"
##spec:
## partitions: 1
## replicas: 1
#---
apiVersion: v1
kind: Namespace
metadata:
name: kafka-cluster
name: kafka
labels:
name: kafka
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: zookeeper
name: zookeeper
namespace: kafka
spec:
kafka:
version: 3.3.1
replicas: 3
listeners:
- name: plain
port: 9092
type: internal
tls: false
- name: tls
port: 9093
type: internal
tls: true
config:
offsets.topic.replication.factor: 3
transaction.state.log.replication.factor: 3
transaction.state.log.min.isr: 2
default.replication.factor: 3
min.insync.replicas: 2
inter.broker.protocol.version: "3.3"
storage:
type: ephemeral
zookeeper:
replicas: 3
storage:
type: ephemeral
entityOperator:
topicOperator: {}
userOperator: {}
replicas: 1
selector:
matchLabels:
app: zookeeper
template:
metadata:
labels:
app: zookeeper
spec:
containers:
- image: wurstmeister/zookeeper
imagePullPolicy: IfNotPresent
name: zookeeper
ports:
- containerPort: 2181
---
apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaTopic
apiVersion: v1
kind: Service
metadata:
name: userevents
labels:
strimzi.io/cluster: "kafka-cluster"
app: zookeeper
name: zookeeper
namespace: kafka
spec:
type: NodePort
ports:
- name: zookeeper
port: 2181
nodePort: 30181
targetPort: 2181
selector:
app: zookeeper
---

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: kafka
name: kafka
namespace: kafka
spec:
replicas: 1
selector:
matchLabels:
app: kafka
template:
metadata:
labels:
app: kafka
spec:
hostname: kafka
containers:
- env:
- name: KAFKA_BROKER_ID
value: "1"
- name: KAFKA_ZOOKEEPER_CONNECT
value: zookeeper:2181
- name: KAFKA_LISTENERS
value: PLAINTEXT://:9092
- name: KAFKA_ADVERTISED_LISTENERS
value: PLAINTEXT://kafka-cluster:9092
image: wurstmeister/kafka
imagePullPolicy: IfNotPresent
name: kafka
ports:
- containerPort: 9092
---
apiVersion: v1
kind: Service
metadata:
labels:
app: kafka
name: kafka-cluster
namespace: kafka
spec:
partitions: 1
replicas: 3
---
ports:
- port: 9092
selector:
app: kafka
8 changes: 4 additions & 4 deletions k8s/mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ spec:
# secretKeyRef:
# name: mysql-pass-root
# key: password
- name: MYSQL_USER
value: root
- name: MYSQL_PASSWORD
value: root1234
# - name: MYSQL_USER
# value: root
# - name: MYSQL_PASSWORD
# value: root1234
# valueFrom:
# secretKeyRef:
# name: mysql-pass-user
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ spring.datasource.username=root
spring.datasource.password=root1234
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=update
spring.datasource.hikari.connectionTimeout=30000
spring.datasource.hikari.idleTimeout=600000
spring.datasource.hikari.maxLifetime=1800000


kafka.bootstrap.servers=kafka-cluster.kafka.svc:9092
spring.kafka.bootstrap-servers=kafka-cluster.kafka.svc:9092
kafka.group.id=server-sent-events
kafka.topic.name=userevents
spring.kafka.consumer.auto-offset-reset=earliest

0 comments on commit 642cd53

Please sign in to comment.