Skip to content

Commit

Permalink
Add Deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshal101 committed Feb 10, 2024
1 parent 7cd0857 commit 850bcba
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
IP="192.168.18.108"
JWT_TOKEN="SECReT"
JWT_TOKEN="SECReT"
MONGO_URI="mongodb://localhost:27017/"
22 changes: 22 additions & 0 deletions deployments/K8s/jwt-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: jwt-app
spec:
replicas: 1
selector:
matchLabels:
app: jwt-app
template:
metadata:
labels:
app: jwt-app
spec:
containers:
- name: jwt
image: hanshal101/jwt
env:
- name: MONGODB_URI
value: "mongodb://mongodb-service:27017/"
ports:
- containerPort: 9876
11 changes: 11 additions & 0 deletions deployments/K8s/jwt-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: jwt-service
spec:
selector:
app: jwt-app
ports:
- protocol: TCP
port: 80
targetPort: 9876
19 changes: 19 additions & 0 deletions deployments/K8s/mongodb-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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
11 changes: 11 additions & 0 deletions deployments/K8s/mongodb-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: mongodb-service
spec:
selector:
app: mongodb
ports:
- protocol: TCP
port: 27017
targetPort: 27017
3 changes: 2 additions & 1 deletion internal/db/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"fmt"
"log"
"os"

"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)

const uri = "mongodb://localhost:27017/"
var uri = string(os.Getenv("MONGO_URI"))

func MongoConnect() {
serverAPI := options.ServerAPI(options.ServerAPIVersion1)
Expand Down

0 comments on commit 850bcba

Please sign in to comment.