Skip to content

MongoDB deployment on Kubernetes using StatefulSets

License

Notifications You must be signed in to change notification settings

jaydp17/mongodb-on-k8s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongodb-on-k8s

This repo shows how to deploy a very simple app with mongodb on Kubernetes using StatefulSets.

The app being deployed here is a very minimal app with just 2 endpoints

1. Set name for the user

$ curl -v -X PUT https://<DOMAIN>/name/this-is-my-new-name

2. Get the name of the user

$ curl -v https://<DOMAIN>/name

How to deploy?

The project uses helm for templating & release management.

To check Kubernetes manifest files before deploying

# it'll print out all the rendered manifest files
$ helm install --dry-run --debug ./helm-chart/mongodb-on-k8s

To deploy it

# installs/upgrades the chart
$ helm --debug upgrade --install --namespace default my-release-name ./helm-chart/mongodb-on-k8s

The above commmand deploys it to namespace default.

To deploy it to some other namespace

# create the namespace
$ kubectl create ns my-custom-ns

# deploy the chart in that namespace
$ helm --debug upgrade --install --namespace my-custom-ns my-release-name ./helm-chart/mongodb-on-k8s

If you have an SSL that you'd wanna put on your Loadbalancer

$ helm --debug upgrade --install --set aws_ssl_arn="<REPLACE_WITH_YOUR_CERT_ARN>" my-release-name ./helm-chart/mongodb-on-k8s

The default replica count is 3, you can change it if you like.
Also every API response contains the name of the pod that served the response in its header.

Cluster Info Kubernetes v1.9.7

Because StatefulSets became GA in Kubernetes 1.9, this project has been tested on a cluster running v1.9.7 with RBAC enabled.

The Terraform files used to create the cluster are available over here.

Note: These terraform files are generated using kops v1.9

Node Version

Anything above node.js version 8 will work just fine.

The Docker image uses v8.9.0.

License

MIT

About

MongoDB deployment on Kubernetes using StatefulSets

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published