- Build and test your code
- Containerize with Docker
- Deploy to a development cluster
- Run integration tests
- Promote to production after manual approval
Deployment Pipeline Overview
We’ve already completed:| Stage | Purpose |
|---|---|
| Unit Testing | Validate code logic with npm test |
| Code Coverage | Measure test coverage using npm run coverage |
| Docker Containerization | Package the app into a Docker image |
- Push the Docker image to a container registry
- Deploy to a Kubernetes development environment
- Execute integration tests against the dev cluster
- Await manual approval
- Promote the same deployment to the production environment
Local Development Commands
Before diving into Kubernetes, run these commands locally to verify your application:| Step | Command | Description |
|---|---|---|
| Install | npm install | Install project dependencies |
| Test | npm test | Execute unit tests |
| Coverage | npm run coverage | Generate code coverage report |
| Build Image | docker build -t my-app:latest . | Create a Docker image |
| Run Image | docker run -p 3000:3000 my-app:latest | Launch the container on port 3000 |
| Push Image | docker push my-app:latest | Upload the image to your registry |
Deploying to Kubernetes
To deploy the Docker image, prepare these Kubernetes manifests:- Deployment: Defines Pods and ReplicaSets in
k8s/deployment.yaml - Service: Exposes Pods internally via
k8s/service.yaml - Ingress: Routes external HTTP traffic using
k8s/ingress.yaml
Integration Testing on Dev
Once the resources are live, validate the deployment:200 OK response confirms that the application is operating correctly in the development cluster.
Ensure your Kubernetes context is set to the development cluster:
Manual Approval Gate
Before proceeding to production, implement a manual approval step in your CI/CD workflow. This prevents unintentional releases.An administrator must review the integration test results and approve the release.
Skipping this step can lead to unverified changes reaching production.
Skipping this step can lead to unverified changes reaching production.
Production Deployment
After approval, deploy to the production cluster using the same manifests:- Switch to the production context:
- Apply the manifests:
- Run production integration tests: