Task scheduling system using Golang, RESTful API, MongoDB, Docker, and Kubernetes.
Table of Contents
This project was seperated into 5 exercises:
- Configure task driven scheduler in Golang
- Building a RESTful API with Gin
- MongoDB: Integrating MongoDB with the Gin API
- Docker: Containerizing the API with Docker
- Kubernetes: Depolying the Containerized API on Kubernetes
The purpose of this project is to build a task scheduling system that builds upon itself to upgrade functionality.
This README will explain each step with visuals and Command-Line arguments to run the applications.
Tools and Frameworks with links to learning resources
-
- Learning: https://go.dev/tour/welcome/1
References to each tool and language is provided above.
The IDE used for this project is Microsoft's Visual Studio Code It is able to run CLI and the extension manager is able to create dockerfiles, go files, YAML and JSON needed for configuration
you will need to download Go, VScode, Docker Desktop, and Postman
- Go: https://go.dev/doc/install
- MS VScode: https://code.visualstudio.com/download
- Docker: https://www.docker.com/products/docker-desktop/
- Postman: https://www.postman.com/downloads/
you will need to set up MongoDB demo account
- MongoDB: https://account.mongodb.com/account/login
- Instructions: https://www.mongodb.com/docs/atlas/tutorial/create-atlas-account/
- after set up create a collection names
tasks
inside thetask-scheduler
collection for default. Otherwise update the config.yaml for databaseName and connectionString
- after set up create a collection names
These are the instructions for cloning the repository and installing any dependencies
-
Clone the repo
git clone https://github.com/SimonGrishin/Backend-Task-Scheduler.git
-
For any issues with required modules
go get <module_name>@latest
Develop a basic Go program that acts as a task scheduler. The program will read tasks and their types from a YAML configuration file, and execute these tasks based on their defined type. This exercise introduces basic Go syntax, enums, file operations, and working with YAML configurations.
Running the task_scheduler.go:
go run task_scheduler.go
Expand upon the knowledge gained from the first exercise by developing a RESTful API using the Gin framework. This API will manage a collection of tasks (similar to the ones in the first exercise) with the ability to Create, Read, Update, and Delete (CRUD) tasks
Running the restful_api.go:
go run restful_api.go
Enhance the task management API developed in the previous exercise by integrating MongoDB for persistent data storage. This involves setting up a MongoDB database, connecting it with the Go application, and modifying the API to perform CRUD operations on the database.
Running chat.go:
go run chat.go
Gain practical experience in Docker by containerizing the Gin-based API with MongoDB integration. This exercise focuses on Docker usage, creating Docker images, and managing containers while ensuring the API is accessible from outside the container.
Build the docker image:
docker build . -t go-container-test:latest
you can change go-container-test to any name but keep it consistent
Run the docker container using the image:
docker run -e PORT=9000 -p 9000:9000 go-container-test:latest
you can test endpoints using: https://0.0.0.0.9000/tasks
Learn the basics of Kubernetes by deploying the previously Dockerized Gin-based API onto a local Kubernetes cluster. This exercise introduces Kubernetes concepts like pods, deployments, services, and basic cluster management.
Apply the kubernetes deployment and service manifests:
kubectl apply -f bb-admin.yaml
Check deployed containers:
kubectl get deployments
Deploying Kubernetes with Docker containers has multiple practical applications from running applications on unknown operating systems and managing resources.
In combination with cloud data storage and kubernetes resource allocation, applications can run completely in the cloud and efficiently use the local hardware. This is an affordable and simple approach to scalable applications for backend developement
Simon Grishin - @LinkedIn - simon.grishin@gmail.com