Skip to content

SPITZKOP/K8S-Challenge

Repository files navigation

ToDoList Application

Introduction

The above represents a simplified form of our a production application and it can give you an idea of what the app looks like in production.

The goal is to create a flask application that implements a very simple todo list. It would have an HTML form that accepts a new todo and displays a list of todos. You can also delete todo. The todos are persisted in the postgres-main database and replicated to postgres-replica.

Implementation

  • I developpeted the application with python: "app.py"

  • The folder templates contains "index.html".

  • flask_deployment.yaml contains :

    • the deployment of flask application
    • the service of "flask_application" with type "nodePort", the "port=30000". I use service nodePort fort the test.
    • the deployment of pod running "postgre-main" database.
    • the deployment of "postgres-replicas" pod related to the main database.
    • the postgres-service
    • "requirement.txt": contains the ependances of the applications: flask and psycopg2-binary
  • The Dokerfile of application contains : the copy and run of application copy of requirements, the run of dependances The application is exposed on port 5000. and the export of environments

Infrastructure

  • cluster EKS

Deployment

  • To deploy the application, I used the command: "apply -f flask_deployment.yaml"

  • To check the pods, services and deployments :

    • kubectl get pods
    • kubectl get service
    • kubectl get deployment
  • To build the application and push it in Docker-Hub:

    • docker build -t flask .
    • docker tag flask:latest ilhemb/flask:v14
    • docker push ilhemb/flask:v14

Test

  • To test tha application in my machine:

  • To connect to the database locally:

    • docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

Continuous Delivery with Argo CD

  • Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. It provides a powerful and intuitive user interface (UI) and a command-line interface (CLI) for managing the lifecycle of applications running in Kubernetes clusters.

  • With Argo CD, you can define the desired state of your applications in a Git repository using Kubernetes manifests (YAML files). Argo CD continuously monitors the Git repository for changes and ensures that the deployed applications match the desired state defined in the repository.

  • I used Argo-Cd to control the cluster k8S and deployments, Continuous Delivery, scalability, state of pods...

  • Installation Argo-CD

  • Installation Argo-CD CLI

  • Configuration Argo-CD

    • kubectl patch svc argocd-server -n argocd -p '{"spec": {"type":"LoadBalancer"}}' Wait 2min

    • URL: "kubectl get svc argocd-server -n argocd -o json | jq --raw-output '.status.loadBalancer.ingress[0].hostname'"

    • PWD=kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

    • Using admin as login and the autogenerated password

    • argocd login $ARGOCD_SERVER --username admin --password $ARGO_PWD --insecure

Push the Docker Image to the Docker Hub using Jenkins Pipeline – CI CD

  • I used a pipeline CI CD of Jenkins to clone repo-git of application, build image and push the image to Docker-Hub
  • Installation Jenkins in Linux:
  • Connexion to the Dashboard Jenkins:
    • URL: http://15.237.111.38:8080/ (@public de la vm et port 8080)
    • Password: sudo cat /var/lib/jenkins/secrets/initialAdminPassword

About

Application flask ToDoList

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published