This project is a scalable and secure authentication & user management microservice, designed for enterprise APIs. It provides centralized authentication, role-based access control (RBAC), and user identity management with high availability and security in mind.
Built using Node.js, MongoDB, Docker, Kubernetes, Helm, and CI/CD tools, this microservice serves as a foundation for enterprise-grade applications, ensuring seamless user authentication, secure API access, and efficient identity management.
- auth-service: A Node.js-based authentication microservice that handles user registration, login, and access control, with MongoDB as the database.
- other-services: Planned future extensions with different frameworks for additional functionalities.
Ensure you have the following installed:
- Node.js
- Docker
- Kubernetes
- Helm
- Jenkins
- SonarQube
- Git
- Kops (Kubernetes Operations)
.
├── README.md
├── auth-service
│ ├── Dockerfile
│ ├── Jenkinsfile
│ ├── README.Docker.md
│ ├── auth-service-helm
│ │ ├── charts
│ │ └── templates
│ │ ├── NOTES.txt
│ │ ├── _helpers.tpl
│ │ ├── auth-app.yaml
│ │ ├── auth-service.yaml
│ │ ├── hpa.yaml
│ │ ├── ingress.yaml
│ │ ├── serviceaccount.yaml
│ │ └── tests
│ │ └── test-connection.yaml
│ ├── compose.yaml
│ ├── config
│ │ └── default.json
│ ├── model
│ │ └── user.js
│ ├── mongodb-helm
│ │ ├── charts
│ │ ├── mongo-config.yaml
│ │ ├── mongo-secret.yaml
│ │ └── templates
│ │ ├── NOTES.txt
│ │ ├── _helpers.tpl
│ │ ├── hpa.yaml
│ │ ├── ingress.yaml
│ │ ├── mongo-app.yaml
│ │ ├── mongo-service.yaml
│ │ ├── serviceaccount.yaml
│ │ └── tests
│ │ └── test-connection.yaml
│ ├── package-lock.json
│ ├── package.json
│ ├── routes
│ │ └── users.js
│ ├── server.js
│ ├── startup
│ │ ├── db.js
│ │ ├── routes.js
│ │ └── validation.js
│ └── test
│ └── users.test.js
└── microserviceArch1.jpg
git clone https://github.com/akhilk2802/blogs-microservices.git
cd blogs-microservices
cd auth-service
npm install
npm test
npm start
docker build -t {docker-username}/auth-service .
docker login
docker push {docker-username}/auth-service
Ensure Helm and Kubernetes are configured before deploying:
helm upgrade --install auth-service ./auth-service-helm \
--set image.repository={docker-username}/auth-service \
--set image.tag=latest
kops create cluster --name=${K8S_CLUSTER_NAME} --state=${K8S_STATE_STORE} \
--zones=us-west-2a --node-count=2 --node-size=t2.micro \
--master-size=t2.micro --dns-zone=${K8S_CLUSTER_NAME}
kops update cluster ${K8S_CLUSTER_NAME} --yes --state=${K8S_STATE_STORE}
kops validate cluster --state=${K8S_STATE_STORE}
This CI/CD pipeline automates building, testing, and deploying the authentication service:
- Fetch Code: Clones the repository from GitHub.
- Install Dependencies: Installs Node.js dependencies.
- Run Tests: Executes unit and integration tests.
- SonarQube Analysis: Runs static code analysis.
- Quality Gate Check: Verifies code quality using SonarQube.
- Build Docker Image: Creates a Docker image for
auth-service
. - Push Docker Image: Uploads the Docker image to Docker Hub.
- Remove Unused Docker Images: Cleans up locally stored images.
- Deploy to Kubernetes with Helm: Deploys
auth-service
to Kubernetes using Helm.
🚀 Scalable, Secure User Management & Authentication Microservice - Designed for Enterprise APIs!