Skip to main content

High Resource Usage Application Setup Guide

This guide walks through deploying a Python-based application in Kubernetes designed to consume high memory and CPU resources. This setup is useful for testing Kubernetes resource management, scaling, and monitoring under stress.

Table of Contents


Requirements

  • Docker installed locally
  • Kubernetes cluster setup (e.g., minikube, EKS, etc.)
  • kubectl command-line tool configured to communicate with the Kubernetes cluster

Step 1: Docker Setup

Ensure Docker is installed and running on your machine. Verify by running:

Step 2: High Resource Usage Python Script

Create a Python file named high_resource_usage.py. This script will consume high CPU and memory by creating large data structures and performing intensive operations.

Step 3: Dockerfile

Create a Dockerfile to containerize the high resource usage application.

Step 4: Build and Push Docker Image

Build and push the Docker image to a registry such as Docker Hub or GitHub Container Registry.
Replace USERNAME with your Docker Hub or registry username.

Step 5: Kubernetes Deployment

Create a Kubernetes deployment file, high-resource-deployment.yaml, to deploy the application to the Kubernetes cluster.
Apply the deployment file:

Step 6: Kubernetes Service

Create a service file, high-resource-service.yaml, if you want to expose the application (e.g., for monitoring or access purposes).
Apply the service file:

Verification

  1. Check Pod Status: Confirm the pods are running and consuming high resources as expected.
  2. Monitor Resource Usage: Use the following command to see the real-time resource usage of the pods.
  3. Inspect Logs: View any output from the containers if needed.
Replace <pod-name> with the actual pod name retrieved from the kubectl get pods command.
This guide completes the setup for deploying a high-resource usage application in Kubernetes, ideal for testing cluster performance and monitoring setups.