Skip to content

Instantly share code, notes, and snippets.

@harivemula
Last active June 26, 2021 15:17
Show Gist options
  • Save harivemula/8a619c30782237c941207d5057a56e9e to your computer and use it in GitHub Desktop.
Save harivemula/8a619c30782237c941207d5057a56e9e to your computer and use it in GitHub Desktop.
Connecting to MongoDB cluster with Spring Boot Application
spring:
data:
mongodb:
uri: mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@mongo-mongodb-0.mongo-mongodb-headless.mongodb.svc:27017,mongo-mongodb-1.mongo-mongodb-headless.mongodb.svc:27017,mongo-mongodb-2.mongo-mongodb-headless.mongodb.svc:27017/test
logging:
level:
org:
springframework:
data.mongodb: INFO
boot.autoconfigure.mongo: INFO
com.mongodb.client: INFO
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: person
name: person
spec:
replicas: 1
selector:
matchLabels:
app: person
template:
metadata:
labels:
app: person
spec:
containers:
- image: harivemula/person:0.0.1-SNAPSHOT
imagePullPolicy: Always
name: person
volumeMounts:
- name: config-volume
mountPath: /workspace/config
env:
- name: MONGODB_USERNAME
valueFrom:
secretKeyRef:
name: mongo-creds
key: mongodb-username
- name: MONGODB_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-creds
key: mongodb-password
volumes:
- name: config-volume
configMap:
name: person-config
---
apiVersion: v1
kind: Service
metadata:
labels:
app: person
name: person-service
namespace: mongodb
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8080
selector:
app: person
type: ClusterIP
architecture: "replicaset"
auth:
rootPassword: "rootSecret"
username: "testuser"
password: "secret"
database: "test"
replicaSetKey: "testrskey001"
replicaSetName: "testrs"
replicaCount: 3
persistence:
storageClass: "standard"
size: 3Gi
rbac:
create: true
podSecurityPolicy:
create: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment