Accessing services like MongoDB in Kubernetes Cluster using Loadbalancer and Ingress
If you want to access services like MongoDB and perform database operation. You can create a stateful set and associate storage class with the service and use PVC for the storage.
Whenever you perform a DB operation you will need the DB endpoint that will be provided by the load balancer service and the record will be stored in the storage or the volume mounted as the PVC.
In the below values.yaml file
persistence:
enabled: true
## A manually managed Persistent Volume and Claim
## Requires persistence.enabled: true
## If defined, PVC must be created manually before volume will be bound
##
# existingClaim:
## The path the volume will be mounted at, useful when using different
## MongoDB images.
##
mountPath: /bitnami/mongodb
configmap:
# # where and how to store data.
# storage:
# dbPath: /bitnami/mongodb/data/db
# journal:
# enabled: true
# directoryPerDB: false
# # where to write logging data.
Whatever data will be stored will be in /bitnami/mongodb/data/db
Again in the values.yaml file mentions the load balancer ip to access the DB service.
# loadBalancerIP:
## Specify the loadBalancerSourceRanges value for LoadBalancer service types.