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
$ curl -v -X PUT https://<DOMAIN>/name/this-is-my-new-name
$ curl -v https://<DOMAIN>/name
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.
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
Anything above node.js version 8 will work just fine.
The Docker image uses v8.9.0
.
MIT