Welcome to the Minikube Express ConfigMap & Secret repository! This project demonstrates how to deploy an Express.js application on Minikube using Kubernetes ConfigMap and Secret for configuration management and sensitive data handling.
- Overview
- Features
- Technologies Used
- Installation
- Usage
- Configuration
- Liveness and Readiness Probes
- Environment Variables
- Building the Docker Image
- Deploying on Minikube
- Accessing the Application
- Releases
- Contributing
- License
This repository provides a complete setup for running an Express.js application in a Kubernetes environment using Minikube. It leverages ConfigMaps for configuration settings and Secrets for sensitive data. This approach enhances security and flexibility in managing application settings.
- Deploys an Express.js app on Minikube
- Utilizes Kubernetes ConfigMap and Secret for configuration and sensitive data
- Implements liveness and readiness probes
- Supports environment variable injection
- Allows local builds and prebuilt Docker Hub images
- Node.js: JavaScript runtime for building the Express.js application.
- Express.js: Web framework for Node.js.
- Kubernetes: Container orchestration platform.
- Minikube: Local Kubernetes environment.
- Docker: Container platform for building images.
- YAML: Markup language for configuration files.
To get started, clone the repository to your local machine:
git clone https://github.com/kkksala/minikube-express-configmap-secret.git
cd minikube-express-configmap-secret
Ensure you have Minikube and Docker installed on your system.
Start Minikube with the following command:
minikube start
You can build the Docker image locally or use a prebuilt image from Docker Hub. To build the image locally, run:
docker build -t express-app .
Apply the Kubernetes configuration files:
kubectl apply -f k8s/
This command will create the necessary resources, including deployments, services, ConfigMaps, and Secrets.
The application configuration is managed through a ConfigMap and a Secret.
The ConfigMap contains non-sensitive configuration data. You can find it in the k8s/configmap.yaml
file. Modify this file to update your application settings.
The Secret contains sensitive information such as API keys or database credentials. You can find it in the k8s/secret.yaml
file. Ensure to update this file with your sensitive data.
Kubernetes uses liveness and readiness probes to manage application health.
The liveness probe checks if the application is running. If it fails, Kubernetes will restart the pod.
The readiness probe checks if the application is ready to handle traffic. If it fails, Kubernetes will stop sending requests to the pod.
Both probes are defined in the deployment configuration in the k8s/deployment.yaml
file.
The application supports environment variable injection. You can define environment variables in the k8s/deployment.yaml
file under the env
section. This allows you to customize application behavior without modifying the code.
To build the Docker image, you can use the following command:
docker build -t your-dockerhub-username/express-app .
Replace your-dockerhub-username
with your actual Docker Hub username.
Once the Docker image is built, you can push it to Docker Hub or use it directly in Minikube. If you choose to use the local image, ensure Minikube can access it:
eval $(minikube docker-env)
Then, deploy the application using:
kubectl apply -f k8s/
To access the application, you can use the following command to get the service URL:
minikube service express-app --url
This command will provide a URL that you can open in your browser to see the running application.
For the latest updates and releases, visit the Releases section. Here, you can download the latest release and execute it as needed.
Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Thank you for checking out the Minikube Express ConfigMap & Secret repository! For more information, please refer to the documentation and explore the features offered by this project.