This repository serves as a demonstration of harnessing the power of TypeScript, Redis, Helm and Kubernetes. The included TypeScript application showcases the seamless integration of Node.js with Redis Sentinel for robust and scalable solutions. Additionally, Helm charts are provided to simplify the deployment process on Kubernetes.
Make sure you have the following tools installed:
- Node.js (for running the TypeScript application)
- Helm (for managing Kubernetes applications)
- Kubernetes cluster (local or cloud-based)
The example will be based on minikube:
-
Clone this repository to your local machine:
git clone https://github.com/kripu77/ts-node-redis-sentinel-k8s-example.git cd ts-node-redis-sentinel-k8s-example
-
Create a docker image for the sampleapp located inside app directory:
cd app docker build -f dockerfile.local -t sample-app:tag . example: docker build -f dockerfile.local -t sample-app:0.1.0 .
-
Asuuming Minikube is running on your local machine Load the docker image into minikube.
minikube image load sample-app:tag .
-
Create a namespace for the application stack:
kubectl create namespace <your-desired-namespace> example: kubectl create namespace ts-node-redis-sentinel-k8s-example
-
Switch to the helm-chart directory in order to Deploy Redis Sentinel and the node.js app using Helm:
cd ../helm-chart helm install ts-node-redis-sentinel-k8s-example ./ -n <your-desired-namespace> example: helm install ts-node-redis-sentinel-k8s-example ./ -n ts-node-redis-sentinel-k8s-example
-
Access the application:
kubectl get svc -n <your-namespace-where-application-is-running> minikube service cd-service --url -n <your-namespace-where-application-is-running> example: kubectl get svc -n ts-node-redis-sentinel-k8s-example minikube service cd-service --url -n ts-node-redis-sentinel-k8s-example
The application is now running! Visit the url displayed on your console.
To remove the deployed resources:
helm uninstall ts-node-redis-sentinel-k8s-example ./ -n <your-desired-namespace>