Cloud Native Monitoring App
make testOverview
Section titled “Overview”Flask monitoring app with Makefile and healthcheck tests.
What You Will Build
Section titled “What You Will Build”Architecture Diagram
Section titled “Architecture Diagram”Prerequisites
Section titled “Prerequisites”- Install or review: Python, Flask, Docker, ECR, EKS, AWS.
- Use your own cloud account credentials and keep them out of commits.
- This project expects cloud resources, so verify budget alerts and cleanup first.
- Open the safety guide before running commands that create infrastructure.
Credentials And Cost Warning
Section titled “Credentials And Cost Warning”Cost risk is medium. Cloud target: AWS. Cloud credentials needed: Yes. Always use your own account, never commit secrets, and confirm cleanup before creating paid infrastructure.
Step-By-Step Lab
Section titled “Step-By-Step Lab”Use this flow before you run commands:
- Read the cost and credential warning above.
- Review the validation, troubleshooting, cleanup, and portfolio proof sections below.
- Follow the original project guide preserved near the bottom of this page.
- Return to the validation and cleanup checks before you capture portfolio evidence.
Validation Checks
Section titled “Validation Checks”Run the project validation command before and after meaningful changes:
make testTroubleshooting
Section titled “Troubleshooting”- Run
make testfirst so local tooling issues are visible early. - If a command fails, check tool versions, working directory, and required environment variables.
- For cloud failures, confirm account identity, region, quotas, and least-privilege IAM.
Cleanup
Section titled “Cleanup”No dedicated cleanup command was detected in the project README. Treat this as a warning: before provisioning anything, write down the exact delete, destroy, or rollback steps for your environment.
Portfolio Proof
Section titled “Portfolio Proof”- Validation command output:
make test - Screenshot or terminal proof: Running container/app screenshot plus logs
- Notes explaining what changed, what failed, and how you fixed it
- Cleanup evidence, especially for cloud or Kubernetes resources
Original Project Guide
Section titled “Original Project Guide”The original README content is preserved here for lab-specific commands and context. Headings are intentionally demoted so the page outline stays focused on the standard lab flow.
Deploying an App built with Python using Flask and psutil on ECR and Kubernete
Section titled “Deploying an App built with Python using Flask and psutil on ECR and Kubernete”This is a monitoring app built with python, and it would be contanerized with docker and deployed to EkS
🛡️ 2026 DevSecOps Enhancements (What You Will Learn)
Section titled “🛡️ 2026 DevSecOps Enhancements (What You Will Learn)”This project’s programmatic deployment methodology via Boto3 and Python has been formalized into a DevSecOps approach:
- IAM Least Privilege & STS: Python scripts (like
ecr.pyandeks.py) that interact directly with AWS APIs require strict IAM boundary enforcement. They must be executed utilizing short-lived AWS STS credentials or Kubernetes IRSA (IAM Roles for Service Accounts) to prevent long-lived credential leakage. - Container OS Hardening: The
Dockerfilehas been optimized. To comply with modern standards, the internal Flask server should be run utilizing an unprivileged user context, mitigating the blast radius if thepsutilorFlaskdependencies ever suffer from a zero-day exploit.
Prerequisites
Section titled “Prerequisites”- Learn Docker and How to containerize a Python application
- Creating Dockerfile
- Building DockerImage
- Running Docker Container
- Docker Commands
- Create ECR repository using Python Boto3 and pushing Docker Image to ECR
- Learn Kubernetes and Create EKS cluster and Nodegroups
- Create Kubernetes Deployments and Services using Python!
STEP 1 - Installations of Services on your WorkStation
Section titled “STEP 1 - Installations of Services on your WorkStation”- Install AWS CLI, then Go to your aws account and get your secret keys and configure the workspace
aws configure - Install python on your workstation and a python extention in vscode
- The application uses the
psutilandFlask, Plotly, boto3 libraries. Install them using pippip3 install -r requirements.txt - Install dependencies psutil
pip3 install psutiland flaskpip install flask - Install python for ECR SDK
pip install boto3 - Install kubernetes, add the K8S python dependencies client library
pip install kubernetesthe extenstion of kubernetes in vscode - Install the docker extention in vscode
Step 2: Run the application
Section titled “Step 2: Run the application”To run the application, navigate to the root directory of the project and execute the following command:
$ python3 app.pyThis will start the Flask server on localhost:5000. Navigate to http://localhost:5000/ on your browser to access the application.
Step 3: Dockerizing the Flask application
Section titled “Step 3: Dockerizing the Flask application”- Create a
Dockerfilein the root directory of the project with the following contents:
#### Use the official Python image as the base imageFROM python:3.11-slim-bookworm
#### Set the working directory in the containerWORKDIR /app
#### Copy the requirements file to the working directoryCOPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
#### Copy the application code to the working directoryCOPY . .
#### Set the environment variables for the Flask appENV FLASK_RUN_HOST=0.0.0.0
#### Expose the port on which the Flask app will runEXPOSE 5000
#### Start the Flask app when the container is runCMD ["flask", "run"]- Build the Docker image, execute the following command:
$ docker build -t <image_name> .- Run the Docker container, execute the following command:
$ docker run -p 5000:5000 <image_name>This will start the Flask server in a Docker container on localhost:5000. Navigate to http://localhost:5000/ on your browser to access the application.
Step 4 - Pushing the Docker image to ECR
Section titled “Step 4 - Pushing the Docker image to ECR”- Create an ECR repository using Python in a folder
ecr.py: - Configure the ECR repository to your workspace to enable a push, you will find the process in console
view push commands
import boto3
#### Create an ECR clientecr_client = boto3.client('ecr')
#### Create a new ECR repositoryrepository_name = 'my-ecr-repo'response = ecr_client.create_repository(repositoryName=repository_name)
#### Print the repository URIrepository_uri = response['repository']['repositoryUri']print(repository_uri)Then run this python3 ecr.py
- Setup password and credentials for ECR
#### Replace <AWS_ACCOUNT_ID> with your AWS account IDaws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com- Push the Docker image to ECR using the push commands on the console:
$ docker push <ecr_repo_uri>:<tag>Step 5 - Creating an EKS cluster and deploying the app using Python**
Section titled “Step 5 - Creating an EKS cluster and deploying the app using Python**”-
Create an EKS cluster
cloud-native-clusterand add node group in aws console -
Create a node group
nodesin the EKS cluster. -
Create deployment and service in a folder
eks.py
from kubernetes import client, config
#### Load Kubernetes configurationconfig.load_kube_config()
#### Create a Kubernetes API clientapi_client = client.ApiClient()
#### Define the deploymentdeployment = client.V1Deployment( metadata=client.V1ObjectMeta(name="my-flask-app"), spec=client.V1DeploymentSpec( replicas=1, selector=client.V1LabelSelector( match_labels={"app": "my-flask-app"} ), template=client.V1PodTemplateSpec( metadata=client.V1ObjectMeta( labels={"app": "my-flask-app"} ), spec=client.V1PodSpec( containers=[ client.V1Container( name="my-flask-container",#### Replace <AWS_ACCOUNT_ID> with your AWS account ID image="<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<IMAGE_NAME>:latest", ports=[client.V1ContainerPort(container_port=5000)] ) ] ) ) ))
#### This is an automation to run deployment and svc using python#### Create the deploymentapi_instance = client.AppsV1Api(api_client)api_instance.create_namespaced_deployment( namespace="default", body=deployment)
#### Define the serviceservice = client.V1Service( metadata=client.V1ObjectMeta(name="my-flask-service"), spec=client.V1ServiceSpec( selector={"app": "my-flask-app"}, ports=[client.V1ServicePort(port=5000)] ))
#### Create the serviceapi_instance = client.CoreV1Api(api_client)api_instance.create_namespaced_service( namespace="default", body=service)make sure to edit the name of the image on line 25 with your image Url.
To run the K8s commands for deployment and service instead of adding the python script you create
deployment.yml and service.ymluse these commandskubectl apply -f deployment.ymlandkubectl apply -f service.yml
- Configure the aws EKS to your work space
aws eks update-kubeconfig --name cloud-native-cluster- Once you run this file by running “python3 eks.py” deployment and service will be created.
- Check by running following commands:
kubectl get deployment -n default (check deployments)kubectl get service -n default (check service)kubectl get pods <name of pod> -n default (to check the pods)
#edit images created if u made errorskubectl edit deployment my-flask-app -n default
#this will pull down the editted imagekubectl get pod -n default -wOnce your pod is up and running, run the port-forward to expose the service
kubectl port-forward service/<service_name> 5000:5000Hit the Star! ⭐
Section titled “Hit the Star! ⭐”If you are planning to use this repo for learning, please hit the star. Thanks!
Source Files On GitHub
Section titled “Source Files On GitHub”The full learning flow stays on this page. Open GitHub only when a step asks you to inspect code, fork the lab, or download source assets.