Skip to content

asoucase/flask-celery-kubernetes-example

Repository files navigation

Flask + Celery + RabbitMQ in Kubernetes

This repository contains the code of a demo app developed with Flask that calculates the Fibonacci number in the most non-optimised way possible.

The application provides the user with a simple form to type in the n-th term of the sequence. Every time a new calculation is submitted, a job gets created and a celery worker, using rabbitmq as message broker, will pick up the job to perform the calculation.

A list of all jobs created is also presented below the form.

An instance of flower is also included to monitor celery.

Node Ports:

  • flask app: 30081
  • flower: 30082

Screenshots

Usage

Docker Compose

Just as simple as running:

$ docker-compose up --build

Kubernetes

In order to deploy the demo app stack on a kubernetes cluster, you must build and push the images into a container registry. In this repository, we will make use of docker hub.

Please login into docker hub with the command:

$ docker login

Steps:

  1. Set docker hub username in .env file

    DOCKERHUB_USERNAME=arturosoucase
    
  2. Build images

    $ docker-compose build
  3. Push images into Docker Hub

    $ docker-compose push
  4. Apply kubernetes manifest files:

    $ kubectl apply -f manifests/

Releases

No releases published

Packages

No packages published