How to run MongoDB with StatefulSet in Kubernetes?
HTML-код
- Опубликовано: 5 ноя 2024
- In this video, I'll show you how to run MongoDB in Kubernetes using a StatefulSet.
#kubernetes #kubernetescourse
If you like the video, consider subscribing: / peterjausovec
▬▬▬▬▬▬ Connect with me ▬▬▬▬▬▬
➡️ Newsletter: learncloudnati...
➡️ Twitter: / pjausovec
➡️ LinkedIn: / pjausovec
How about data sync between db pods ?
Nice and clear explanation. Thanks Peter!
Thank you Hashan!
Best statefulSet video I've seen so far
Overall great video, 1 reminder is that the ip addr of a pod may has changed once it gets restarted.
The idea behind StatefulSets is that each pod get's a unique index and a stable identity (but yes, IPs will be different in case of a restart and one should never rely on pod IPs in any case).
I manage to make it work! Thank you so much! I'm using AWS to host my kubernetes, all works well but I can't seem to connect to the replica set using mongodb compass.
did you expose the services through the ingress?
do we store the data of database pods in another instance outside of the cluster like aws rds or we just store everything in those storage classes itself in production?
you’d use a persistent volume and a persistent volume claim to “claim” some storage for pods. the storage itself is outside of the cluster - you can define volumes in aws or azure, gcp…
Hi Learncloudnative
Can you suggest for storage section which storage you used I.e local or any cloud, I was searching for the cloud template for AWS
hi! here are the YAML files I used for these videos: github.com/peterj/k8s-shorts-files/tree/main/files
how can i connect with mongo compass?
Hello. I have a issue with the pod . always pending and pv,pvc didn't automatic create. need enable some feature or other yaml file to create? Thanks. K9s official document statefulset nginx same like this its pod also pending and waiting for pv/pvc resource. so I need to create pv/pvc by manual first? Thanks!
What are the errors you're seeing? You will have to create a PersistentVolume resource first, and that would depend on where you're running your cluster. Check out this video where I talk about PVs and PVCs
I can't connect with mongo atlas, I have to expose the service externally, so it becomes the link to connect..I connected from k8s but externally it's impossible from Gke..why?
Hi! You'll have to expose the k8s service externally to connect to it, otherwise it's not going to work.
Unfortunately not very useful since each pod has its own storage so the data is independent in each pod, defeating the purpose of having it on k8s.
But in this case, mongodb is not running as replica sets, there are 3 different mongo instances,
The idea here was to show how StatefulSets allow you to manage stateful applications - i.e. guaranteeing the uniqueness of the pods - hence the different instances with different set of data.
what is the use of these replica set the data is not replicated among the dbs
ReplicaSet is a Kubernetes concept and it doesn't have anything to do with DB or data in this case. Even if you're not using StatefulSets, the ReplicaSet in K8s ensures there's always a specified number of pods running in the cluster.
you miss the point of having the database on the kubernetes, what is the use of having 3 instances of mongo if you don't have the same data on all three? you just created 3 different mongodb instances. @@learncloudnative
Why kubernetes created 3 pods instead of 1?
initially, it created only one, but then we used the "scale" command to create 3 replicas
why mongo 4.0.17 and not 7.0 ?
the video was recorded a long time ago :) shouldn’t be any different if you updated to 7.0
so thanks bro! y my god