Skip to content

Kubernetes job autoscaler solution based on Queue size in Azure Service Bus

License

Notifications You must be signed in to change notification settings

lulzzz/ContainerNanny

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kuber.NET

Monitoring solution for container jobs scale

Architecture

Basic Architecture

The proposed solution uses an Azure Function to get the message count from a Service Bus Queue. Is is triggered every n minutes. If there is any message, Function calls Kubernetes API in order to scale it up, creating a job on Kube.

Every job has the following pattern: It continuously peek, process and delete messages from queue. If there is no messages in a definied interval, the process finishes.

Basic Architecture

Basic Architecture + DevOps Included

The solution above can be extended to embrace a DevOps process. In the following proposed architecture a Jenkins instance is triggered by a git repository. Then it builds the container image and pushes to an Azure Container Registry. Right after, Jenkins calls Kubernetes API and notifies the new container image.

Basic Architecture + DevOps Included

Documentation (/docs):

  1. Initial Deployment
  2. Kubernetes Setup
  3. Certificate Setup
  4. SDK Development
  5. Function Development
  6. Deployment and Jobs

Projects (/src):

Library

This .NET Full library implements:

  • Authentication
  • Deployments scaling
  • Jobs creation

Function

The C# Azure Function with the following code snippets:

  • Kube.csx: handles calls to Kuber.NET private assembly
  • Queue.csx: handles calls to Service Bus Queue using its SDK
  • Settings.csx: stores all settings related to the project
  • run.csx: business logic inside container scaling rules

Example\Queue:

  • Queue.Checker: Check if there is any item in a Queue and use Kuber.NET to increase the number of containers (.NET Full, Project to be deploy inside an Azure Function)
  • Queue.Producer: Inserts items in Service Bus Queue (.NET Full, Simulate other enviroment microservices)
  • Queue.Consumer: Reads items in Service Bus Queue (.NET Core, Simulate container inside Kubernetes)

Scripts

Scripts for automation (used in our Jenkins instance).

  • buildandpush.sh: Builds the .NET core project, create the docker image and deploys it to Azure Container Registry.
  • buildimage_example.sh: Example that uses the script above.
  • deployment_template.yaml: Uses a previously built image from Azure Container Registry and creates a Deployment on Kubernetes.
  • job_template.yaml: Uses a previously built image from Azure Container Registry and creates a Job on Kubernetes.

References

About

Kubernetes job autoscaler solution based on Queue size in Azure Service Bus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 69.2%
  • C# 30.0%
  • Other 0.8%