Skip to content

Commit

Permalink
Add kubenetes config file for deployment (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsh3305 authored May 22, 2023
1 parent 271c5a7 commit f6e307d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
APPLICATION_PORT: '8080'
USERNAME: ${{secrets.OSSRH_USERNAME}}
TOKEN: ${{secrets.OSSRH_TOKEN}}
KAFKA_URL: localhost:9092
jobs:
build:
name: Build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
APPLICATION_PORT: ${{ secrets.PORT }}
USERNAME: ${{secrets.OSSRH_USERNAME}}
TOKEN: ${{secrets.OSSRH_TOKEN}}
KAFKA_URL: ${{secrets.KAFKA_URL}}
jobs:
push_to_registries:
name: Push Docker image to multiple registries
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM openjdk:19
ARG JAR_FILE=build/libs/User-0.0.1-SNAPSHOT.jar
ARG MONGODB_URI=mongodb://localhost:27017

ARG KAFKA_URL=localhost:9092
ENV MONGODB_URI=$MONGODB_URI
ENV APPLICATION_PORT=8080
ENV KAFKA_URL=$KAFKA_URL
EXPOSE 8080
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
47 changes: 47 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-user-deployment
labels:
app: user
spec:
replicas: 1
selector:
matchLabels:
app: user
template:
metadata:
labels:
app: user
spec:
containers:
- name: backend-user
image: harsh3305/hrv-mart-backend-user
ports:
- containerPort: 8080
imagePullPolicy: Always
env:
- name: MONGODB_URI
valueFrom:
secretKeyRef:
key: mongodb_uri
name: secret
- name: KAFKA_URL
valueFrom:
configMapKeyRef:
name: config-map
key: kafka-url
---
apiVersion: v1
kind: Service
metadata:
name: backend-user-service
spec:
selector:
app: user
type: LoadBalancer
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 30000
10 changes: 5 additions & 5 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ spring.data.mongodb.uri=${MONGODB_URI}
spring.data.mongodb.database=HRV-Mart-Backend-User
spring.data.mongodb.auto-index-creation=true
server.port=${APPLICATION_PORT}
spring.kafka.consumer.bootstrap-servers: localhost:9092
spring.kafka.consumer.group-id: user
spring.kafka.consumer.auto-offset-reset: earliest
spring.kafka.consumer.key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
spring.kafka.consumer.bootstrap-servers= ${KAFKA_URL}
spring.kafka.consumer.group-id= user
spring.kafka.consumer.auto-offset-reset= earliest
spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer= org.springframework.kafka.support.serializer.JsonDeserializer
spring.kafka.consumer.properties.spring.json.trusted.packages=*

0 comments on commit f6e307d

Please sign in to comment.