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.
-
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
- cluster EKS
-
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
-
To test tha application in my machine:
- docker run -p 5000:5000 flask
- curl http://127.0.0.1:5000
-
To connect to the database locally:
- docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
-
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
- kubectl create namespace argocd
- kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.0.4/manifests/install.yaml
-
Installation Argo-CD CLI
- sudo curl --silent --location -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/v2.0.4/argocd-linux-amd64
- sudo chmod +x /usr/local/bin/argocd
-
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
-
- 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:
- sudo yum update
- sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
- sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
- sudo yum upgrade
- sudo dnf install java-11-amazon-corretto
- sudo yum install jenkins
- sudo systemctl enable jenkins
- sudo systemctl start jenkins
- sudo systemctl status jenkins
- 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