Orchestrating distributed locks, reliably and efficiently.
Built with the tools and technologies:
- 📍 Overview
- 👾 Features
- 📁 Project Structure
- 🚀 Getting Started
- 📌 Project Roadmap
- 🔰 Contributing
- 🎗 License
- 🙌 Acknowledgments
redlock-k8s-laboratory showcases a scalable microservices architecture using Kubernetes, Redis, and Node.js. It demonstrates distributed locking and task scheduling, enabling efficient processing of concurrent jobs. The project provides a foundation for building robust, fault-tolerant systems that can handle high-volume workloads. Ideal for developers and DevOps professionals seeking best practices for containerized application design.
Feature | Summary | |
---|---|---|
⚙️ | Architecture |
|
🔩 | Code Quality |
|
📄 | Documentation |
|
🔌 | Integrations |
|
🧩 | Modularity |
|
🧪 | Testing |
|
⚡️ | Performance |
|
🛡️ | Security |
|
└── redlock-k8s-laboratory/
├── LICENSE
├── README.md
├── commands
│ ├── build-into-registry.sh
│ ├── log-redis.sh
│ └── log-web.sh
├── cron-service
│ ├── .gitignore
│ ├── Dockerfile
│ ├── main.js
│ ├── package.json
│ └── yarn.lock
├── deployment-cron-service.k8s.yaml
├── deployment-redis.k8s.yaml
├── deployment-web-server.k8s.yaml
├── docker-compose.yml
├── package.json
└── web-server
├── .gitignore
├── Dockerfile
├── main.js
├── package.json
└── yarn.lock
REDLOCK-K8S-LABORATORY/
__root__
deployment-redis.k8s.yaml - Configures a Redis deployment and service in a Kubernetes cluster
- The deployment spins up a single Redis container, exposing port 6379
- The accompanying service enables network access to the Redis instance, allowing other components to store and retrieve data
- Redis acts as an in-memory data store, providing fast caching and persistence capabilities to the application.deployment-web-server.k8s.yaml - Defines a Kubernetes deployment and service for the web server component
- The deployment manages a single replica of the web server container, specifying the container image and port
- The service exposes the web server externally, routing traffic to the appropriate pod
- Together, they enable reliable deployment and access to the web server within the Kubernetes cluster architecture.docker-compose.yml - Orchestrates the deployment of a multi-service architecture using Docker Compose
- Defines three services: a web server, a cron service, and Redis
- The web server and cron service are built from custom images, while Redis uses the official image
- Environment variables are set for each service, and the cron service depends on the web server and Redis.deployment-cron-service.k8s.yaml - Configures a Kubernetes deployment for the cron service in the Redlock Laboratory project
- Sets up 5 replicas of the cron service container, specifying the container image and environment variables for connecting to the web server and Redis services
- Ensures high availability and scalability of the cron service within the project's microservices architecture.package.json - Configures the project's build, deployment, and logging processes
- Defines scripts for starting the application, building Docker images, and managing containers using Docker Compose
- Includes commands for deploying and removing Kubernetes resources
- Provides convenient scripts for accessing logs of the web server and Redis components, streamlining development and troubleshooting tasks.
web-server
Dockerfile - Dockerfile sets up a Node.js environment for the web server component of the project
- It installs dependencies, copies the necessary files, and specifies the command to run the main server script
- The Dockerfile enables building a containerized version of the web server, facilitating deployment and ensuring a consistent runtime environment across different systems.package.json - Manages dependencies and metadata for the web server component of the project
- Specifies the required third-party libraries, including Express for handling HTTP requests, body-parser for parsing request bodies, and Luxon for date and time manipulation
- Defines the entry point of the web server and sets the license under which the package is distributed.main.js - Serves as the main entry point for the web server, handling HTTP requests and managing application state
- Exposes endpoints for receiving and processing messages, tracking data in memory based on message content
- Facilitates communication between system components and provides a centralized location for monitoring and controlling the application's behavior.
commands
build-into-registry.sh - Builds Docker images within the Minikube environment, enabling seamless local development and testing
- By leveraging Minikube's Docker daemon, the script eliminates the need to push images to a remote registry, streamlining the development workflow
- This integration allows for efficient iteration and debugging of containerized applications before deploying to production environments.log-redis.sh - Enables real-time monitoring of Redis keys in a Kubernetes cluster
- Retrieves the name of the Redis pod using kubectl, then continuously displays the keys stored in the Redis database using the redis-cli command
- Facilitates observing changes to Redis data without manually connecting to the pod, aiding in debugging and understanding the application's runtime state.log-web.sh - Enables viewing real-time logs for the web component in a Kubernetes cluster
- Retrieves the pod name associated with the web service using kubectl and the grep command
- Utilizes the kubectl logs command with the -f flag to stream the logs of the identified web pod, facilitating continuous monitoring and troubleshooting of the web component within the project's architecture.
cron-service
Dockerfile - Dockerfile sets up the environment for running the cron-service, a component of the project's architecture
- It installs dependencies, copies the necessary files, and specifies the command to start the service
- The cron-service likely performs scheduled tasks or background jobs, contributing to the overall functionality and automation within the project.package.json - package.json defines dependencies and metadata for the cron-service, a component of the project's architecture
- It specifies the required libraries, such as ioredis for Redis interaction, cron for scheduling tasks, and luxon for date/time handling
- The file also includes development dependencies and identifies the entry point of the cron-service module.main.js - Serves as the cron service for the project architecture, executing scheduled tasks at regular intervals
- Utilizes Redis for distributed locking and list management
- Communicates with the web server to send task-related messages
- Ensures tasks are processed efficiently and reliably by implementing retry logic and random sleep intervals between task executions.
Before getting started with redlock-k8s-laboratory, ensure your runtime environment meets the following requirements:
- Programming Language: Error detecting primary_language: {'yaml': 3, 'yml': 1, 'json': 3, 'lock': 2, 'js': 2, 'sh': 3}
- Package Manager: Npm, Yarn
- Container Runtime: Docker
Install redlock-k8s-laboratory using one of the following methods:
Build from source:
- Clone the redlock-k8s-laboratory repository:
❯ git clone https://github.com/diekotto/redlock-k8s-laboratory
- Navigate to the project directory:
❯ cd redlock-k8s-laboratory
- Install the project dependencies:
❯ echo 'INSERT-INSTALL-COMMAND-HERE'
❯ echo 'INSERT-INSTALL-COMMAND-HERE'
❯ docker build -t diekotto/redlock-k8s-laboratory .
Run redlock-k8s-laboratory using the following command:
Using npm
❯ echo 'INSERT-RUN-COMMAND-HERE'
❯ echo 'INSERT-RUN-COMMAND-HERE'
❯ docker run -it {image_name}
Run the test suite using the following command:
Using npm
❯ echo 'INSERT-TEST-COMMAND-HERE'
❯ echo 'INSERT-TEST-COMMAND-HERE'
-
Task 1
:Implement feature one. -
Task 2
: Implement feature two. -
Task 3
: Implement feature three.
- 💬 Join the Discussions: Share your insights, provide feedback, or ask questions.
- 🐛 Report Issues: Submit bugs found or log feature requests for the
redlock-k8s-laboratory
project. - 💡 Submit Pull Requests: Review open PRs, and submit your own PRs.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your github account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/diekotto/redlock-k8s-laboratory
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to github: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
This project is protected under the SELECT-A-LICENSE License. For more details, refer to the LICENSE file.
- List any resources, contributors, inspiration, etc. here.