Code Monkey home page Code Monkey logo

overstruck / k8s-pod-cpu-stressor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from narmidm/k8s-pod-cpu-stressor

0.0 1.0 0.0 14 KB

The k8s-pod-cpu-stressor is a tool designed to simulate CPU stress on Kubernetes pods. It allows you to specify the desired CPU usage and stress duration, helping you test the behavior of your Kubernetes cluster under different CPU load scenarios.

License: Apache License 2.0

Go 75.71% Makefile 9.81% Dockerfile 14.49%

k8s-pod-cpu-stressor's Introduction

k8s-pod-cpu-stressor

The k8s-pod-cpu-stressor is a tool designed to simulate CPU stress on Kubernetes pods. It allows you to specify the desired CPU usage and stress duration, helping you test the behavior of your Kubernetes cluster under different CPU load scenarios.

Features

  • Simulates CPU stress on Kubernetes pods.
  • Configurable CPU usage (in millicores) and stress duration.
  • Helps evaluate Kubernetes cluster performance and resource allocation.

Getting Started

Prerequisites

To use the k8s-pod-cpu-stressor, you need to have the following installed:

  • Go (version 1.19 or higher)
  • Docker

Building the Binary

  1. Clone this repository to your local machine.

  2. Navigate to the repository directory.

  3. Build the binary using the following command:

    go build -o cpu-stress .

Running with Docker

Build the Docker image using the provided Dockerfile:

docker build -t k8s-pod-cpu-stressor .

Run the Docker container, specifying the desired CPU usage and stress duration as arguments:

docker run --rm k8s-pod-cpu-stressor -cpu=0.2 -duration=10s

Replace 0.2 and 10s with the desired CPU usage (fraction) and duration, respectively.

CPU Usage and Duration

The k8s-pod-cpu-stressor allows you to specify the desired CPU usage and stress duration using the following parameters:

  • CPU Usage: The CPU usage is defined as a fraction of CPU resources. It is specified using the -cpu argument. For example, -cpu=0.2 represents a CPU usage of 20% or 200 milliCPU (mCPU).

  • Stress Duration: The stress duration defines how long the CPU stress operation should run. It is specified using the -duration argument, which accepts a duration value with a unit. Supported units include seconds (s), minutes (m), hours (h), and days (d). For example, -duration=10s represents a stress duration of 10 seconds, -duration=5m represents 5 minutes, -duration=2h represents 2 hours, and -duration=1d represents 1 day.

Adjust these parameters according to your requirements to simulate different CPU load scenarios.

Check the Public Docker Image

The k8s-pod-cpu-stressor Docker image is publicly available on Docker Hub. You can check and pull the image using the following command:

docker pull narmidm/k8s-pod-cpu-stressor:latest

Sample Deployment Manifest

Use the following deployment manifest as a starting point to deploy the k8s-pod-cpu-stressor image in your Kubernetes cluster:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: cpu-stressor-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cpu-stressor
  template:
    metadata:
      labels:
        app: cpu-stressor
    spec:
      containers:
        - name: cpu-stressor
          image: narmidm/k8s-pod-cpu-stressor:1.0.0
          args:
            - "-cpu=0.2"
            - "-duration=10s"
          resources:
            limits:
              cpu: "200m"
            requests:
              cpu: "100m"

Contributing

Contributions are welcome! If you find a bug or have a suggestion, please open an issue or submit a pull request. For major changes, please discuss them first in the issue tracker.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.