{"id":15113859,"url":"https://github.com/uditgaurav/k8s-actions","last_synced_at":"2025-04-12T05:13:00.482Z","repository":{"id":58952607,"uuid":"256516804","full_name":"uditgaurav/k8s-actions","owner":"uditgaurav","description":"This Repository contains the code for creating a github action which can delete a pod by passing the name and namespace of pod","archived":false,"fork":false,"pushed_at":"2021-11-30T10:35:27.000Z","size":45,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T05:12:49.003Z","etag":null,"topics":["actions","ansible","bash-script","dockerfile","github","kubectl","kubernetes","pod"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uditgaurav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-17T13:53:31.000Z","updated_at":"2021-11-30T10:35:30.000Z","dependencies_parsed_at":"2023-01-11T17:23:23.345Z","dependency_job_id":null,"html_url":"https://github.com/uditgaurav/k8s-actions","commit_stats":{"total_commits":23,"total_committers":6,"mean_commits":"3.8333333333333335","dds":0.6086956521739131,"last_synced_commit":"0ddcae34aa200f0ae0b4c4ea69700c8a74e1c3b0"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditgaurav%2Fk8s-actions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditgaurav%2Fk8s-actions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditgaurav%2Fk8s-actions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditgaurav%2Fk8s-actions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uditgaurav","download_url":"https://codeload.github.com/uditgaurav/k8s-actions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519556,"owners_count":21117761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","ansible","bash-script","dockerfile","github","kubectl","kubernetes","pod"],"created_at":"2024-09-26T01:23:35.713Z","updated_at":"2025-04-12T05:13:00.458Z","avatar_url":"https://github.com/uditgaurav.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Action for Chaos Engineering in Kubernetes\n\nThis action provides a way to perform different chaos experiments on the Kubernetes environment. It contains Litmus Chaos experiments to run the chaos and find a weakness in the system. For more details about chaos engineering in Kubernetes using Litmus visit \u003ca href=\"https://docs.litmuschaos.io/docs/next/getstarted.html\"\u003e litmus-docs \u003c/a\u003e.\n\n## Pre-requisites\n\nKubernetes 1.16 or later.\n\n## Overview.\n\nThere is a number of chaos experiments that can be performed using `github-chaos-actions`, you can select the one which you want to perform, and for more details about the experiment please visit the \u003ca href=\"https://docs.litmuschaos.io/docs/getstarted\"\u003e experiment docs \u003c/a\u003esection.\n\n## Run a chaos experiment using this action\n\nWe just need to follow these simple steps to run a chaos experiment using this action:\n\n- **Deploy Application**: We need to have an application running on which the chaos will be performed. The user has to create an application and pass the application details through action's ENV. The details involved application kind (deployment,statefulset,daemonset), application label, and namespace.\n\n- **Install Litmus**: Before running any experiment we need to setup litmus in the cluster. If litmus is not already installed then we can install it from `github-chaos-action` by just passing an ENV `INSTALL-LITMUS` with `true` value. This will bring up litmus with all infra components running in litmus namespace.\n\n- **Select experiment**: Select an experiment from the list of experiments mentioned in the below section which you want to perform on an application. Get the details of the experiment and how to run the actions for a particular experiment.\n\n**The different experiments that can be performed using `github-chaos-actions` are:**\n\n- **Pod Delete**: This chaos action causes random (forced/graceful) pod delete of application deployment replicas. It tests deployment sanity (high availability \u0026 uninterrupted service) and recovery workflows of the application pod. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-delete/README.md\"\u003e pod delete chaos action\u003c/a\u003e and for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/pod-delete\"\u003e pod delete docs\u003c/a\u003e.\n\n- **Container Kill**: This chaos action executes SIGKILL on the container of random replicas of application deployment. It tests the deployment sanity (high availability \u0026 uninterrupted service) and recovery workflows of an application. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/container-kill/README.md\"\u003e container kill chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/container-kill\"\u003e container kill docs\u003c/a\u003e.\n\n- **Node CPU Hog**: This chaos action causes CPU resource exhaustion on the Kubernetes node. The experiment aims to verify the resiliency of applications that operate under resource constraints wherein replicas may sometimes be evicted on account on nodes turning unschedulable (Not Ready) due to lack of CPU resources. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/node-cpu-hog/README.md\"\u003enode cpu hog chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/node-cpu-hog\"\u003e node cpu hog docs\u003c/a\u003e .\n\n- **Node Memory Hog**: This chaos action causes Memory exhaustion on the Kubernetes node. The experiment aims to verify the resiliency of applications that operate under resource constraints wherein replicas may sometimes be evicted on account on nodes turning unschedulable due to lack of Memory resources. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/node-memory-hog/README.md\"\u003e node memory hog chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/node-memory-hog\"\u003e node memory hog docs\u003c/a\u003e.\n\n- **Pod CPU Hog**: This chaos action causes CPU resource consumption on specified application containers by starting one or more md5sum calculation process on the special file /dev/zero. It Can test the application's resilience to potential slowness/unavailability of some replicas due to high CPU load. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-cpu-hog/README.md\"\u003e pod cpu hog chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/pod-cpu-hog\"\u003e pod cpu hog docs\u003c/a\u003e.\n\n- **Pod Memory Hog**: This chaos action causes Memory resource consumption on specified application containers by using dd command which will be used to consume memory of the application container for a certain duration of time. It can test the application's resilience to potential slowness/unavailability of some replicas due to high Memory load. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-memory-hog/README.md\"\u003epod memory hog chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/pod-memory-hog\"\u003e Pod Memory hog docs\u003c/a\u003e.\n\n- **Disk Fill**: This chaos action causes Disk Stress by filling up the Ephemeral Storage of the Pod using one of it containers. It forced the Pod to get Evicted if the Pod exceeds it Ephemeral Storage Limit.It tests the Ephemeral Storage Limits, to ensure those parameters are sufficient.Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/disk-fill/README.md\"\u003e disk fill chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/disk-fill\"\u003e Disk Fill hog docs\u003c/a\u003e.\n\n- **Pod Network Corruption**: This chaos action Injects packet corruption on the specified container by starting a traffic control (tc) process with netem rules to add egress packet corruption. Corruption is injected via pumba library with command Pumba netem corruption bypassing the relevant network interface, packet-corruption-percentage, chaos duration, and regex filter for the container name. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-network-corruption/README.md\"\u003epod network corruption chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/pod-network-corruption\"\u003e pod network corruption docs\u003c/a\u003e.\n\n- **Pod Network Latency**: This chaos action causes flaky access to application replica by injecting network delay using Pumba. It injects latency on the specified container by starting a traffic control (tc) process with netem rules to add egress delays. It Can test the application's resilience to lossy/flaky network. Check a sample usage of\u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-network-latency/README.md\"\u003e pod network latency chaos action\u003c/a\u003e and for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/pod-network-latency\"\u003e pod network latency docs\u003c/a\u003e.\n\n- **Pod Network Loss**: This chaos action injects chaos to disrupt network connectivity to Kubernetes pods. The application pod should be healthy once chaos is stopped. It causes loss of access to application replica by injecting packet loss. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-network-loss/README.md\"\u003epod network loss chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/pod-network-loss\"\u003e pod network loss docs\u003c/a\u003e\n\n- **Pod Network Duplication**: This chaos action injects pod-network-duplication injects chaos to disrupt network connectivity to kubernetes podsThe application pod should be healthy once chaos is stopped. Service-requests should be served despite chaos. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-network-duplication/README.md\"\u003epod network duplication chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/pod-network-duplication\"\u003e pod network duplication docs\u003c/a\u003e\n\n- **Pod Autoscaler**: This chaos action can be used for other scenarios as well, such as for checking the Node auto-scaling feature. For example, check if the pods are successfully rescheduled within a specified period in cases where the existing nodes are already running at the specified limits. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-autoscaler/README.md\"\u003epod autoscaler chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/pod-autoscaler\"\u003e pod autoscaler docs\u003c/a\u003e\n\n- **Node IO Stress**: This chaos action injects IO stress on the Kubernetes node. The experiment aims to verify the resiliency of applications that share this disk resource for ephemeral or persistent storage purposes. The amount of disk stress can be either specifed as the size in percentage of the total free space on the file system or simply in Gigabytes(GB). When provided both it will execute with the utilization percentage specified and non of them are provided it will execute with default value of 10%. Check a sample usage of \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/node-io-stress/README.md\"\u003enode io stress chaos action \u003c/a\u003eand for more details about the experiment please visit \u003ca href=\"https://docs.litmuschaos.io/docs/node-io-stress\"\u003e node io stress docs\u003c/a\u003e\n\n## Usage\n\nA sample pod delete experiment workflow:\n\n`.github/workflows/main.yml`\n\n```yaml\nname: chaos-pipeline\n#events can be modified as per requirements\non:\n  workflow_dispatch:\n\njobs:\n  chaos-action:\n    runs-on: ubuntu-latest\n    steps:\n      # KUBE_CONFIG_DATA is required env for litmuschaos/github-chaos-actions.\n      - name: Setting up kubeconfig ENV for Github Chaos Action\n        run: echo ::set-env name=KUBE_CONFIG_DATA::$(base64 -w 0 ~/.kube/config)\n        env:\n          ACTIONS_ALLOW_UNSECURE_COMMANDS: true\n\n      - name: Setup Litmus\n        uses: litmuschaos/github-chaos-actions@master\n        env:\n          INSTALL_LITMUS: true\n\n      - name: Running Litmus pod delete chaos experiment\n        uses: litmuschaos/github-chaos-actions@master\n        env:\n          EXPERIMENT_NAME: pod-delete\n          EXPERIMENT_IMAGE: litmuschaos/go-runner\n          EXPERIMENT_IMAGE_TAG: latest\n          JOB_CLEANUP_POLICY: delete\n          APP_NS: default\n          APP_LABEL: run=nginx\n          APP_KIND: deployment\n          IMAGE_PULL_POLICY: Always\n          TOTAL_CHAOS_DURATION: 30\n          CHAOS_INTERVAL: 10\n          FORCE: false\n\n      - name: Uninstall Litmus\n        if: always()\n        uses: litmuschaos/github-chaos-actions@master\n        env:\n          LITMUS_CLEANUP: true\n```\n\n#### For EKS Clusters\n\nA sample pod delete experiment workflow for EKS Clusters:\n\n`.github/workflows/main.yml`\n\n```yaml\nname: chaos-pipeline\n#events can be modified as per requirements\non:\n  workflow_dispatch:\n\njobs:\n  chaos-action:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Configure AWS Credentials\n        uses: aws-actions/configure-aws-credentials@v1\n        with:\n          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}\n          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}\n          aws-region: ${{ secrets.AWS_REGION }}\n\n      # Optionally kubeconfig can be passed from github secrets in base64 encoded form as mentioned above.\n      - name: Writing kubeconfig for eks cluster\n        run: |\n          aws eks --region ${{ secrets.AWS_REGION }} update-kubeconfig --name \u003ceks_cluster_name\u003e\n\n      - name: Setting up kubeconfig ENV for Github Chaos Action\n        run: echo ::set-env name=KUBE_CONFIG_DATA::$(base64 -w 0 ~/.kube/config)\n        env:\n          ACTIONS_ALLOW_UNSECURE_COMMANDS: true\n\n      - name: Setup Litmus\n        uses: litmuschaos/github-chaos-actions@master\n        env:\n          INSTALL_LITMUS: true\n\n      - name: Running Litmus pod delete chaos experiment\n        uses: litmuschaos/github-chaos-actions@master\n        env:\n          EXPERIMENT_NAME: pod-delete\n          EXPERIMENT_IMAGE: litmuschaos/go-runner\n          EXPERIMENT_IMAGE_TAG: latest\n          JOB_CLEANUP_POLICY: delete\n          APP_NS: default\n          APP_LABEL: run=nginx\n          APP_KIND: deployment\n          IMAGE_PULL_POLICY: Always\n          TOTAL_CHAOS_DURATION: 30\n          CHAOS_INTERVAL: 10\n          FORCE: false\n\n      - name: Uninstall Litmus\n        if: always()\n        uses: litmuschaos/github-chaos-actions@master\n        env:\n          LITMUS_CLEANUP: true\n```\n\nGet the details of the chaos action tunables for pod delete (above example) \u003ca href=\"https://github.com/litmuschaos/github-chaos-actions/blob/master/experiments/pod-delete/README.md\"\u003ehere\u003c/a\u003e\n\n## Secrets\n\n`KUBE_CONFIG_DATA` – **required**: A base64-encoded kubeconfig file with credentials for Kubernetes to access the cluster. You can get it by running the following command:\n\n```bash\ncat $HOME/.kube/config | base64\n```\n\n## Environment Variables\n\nSome comman environment variables used for running the `github-chaos-actions` are:\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003e Variables \u003c/th\u003e\n    \u003cth\u003e Description \u003c/th\u003e\n    \u003cth\u003e Specify In Chaos Action \u003c/th\u003e\n    \u003cth\u003e Default Value \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e \n    \u003ctd\u003e EXPERIMENT_NAME \u003c/td\u003e\n    \u003ctd\u003e Give the experiment name you want to run(check the list of experiments available under experiment folder)\u003c/td\u003e\n    \u003ctd\u003e Mandatory \u003c/td\u003e\n    \u003ctd\u003e No default value \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e \n    \u003ctd\u003e APP_NS \u003c/td\u003e\n    \u003ctd\u003e Provide namespace of application under chaos \u003c/td\u003e\n    \u003ctd\u003e Optional \u003c/td\u003e\n    \u003ctd\u003e Default value is default\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e APP_LABEL  \u003c/td\u003e\n    \u003ctd\u003e Provide application label of application under chaos. \u003c/td\u003e\n    \u003ctd\u003e Optional \u003c/td\u003e\n    \u003ctd\u003e Default value is run=nginx \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e APP_KIND \u003c/td\u003e\n    \u003ctd\u003e Provide the kind of application   \u003c/td\u003e\n    \u003ctd\u003e Optional  \u003c/td\u003e\n    \u003ctd\u003e Default value is deployment \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e INSTALL_LITMUS \u003c/td\u003e\n    \u003ctd\u003e Keep it true to install litmus if litmus is not already installed.\u003c/td\u003e\n    \u003ctd\u003e Optional \u003c/td\u003e\n    \u003ctd\u003e Default value is not set to true \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e LITMUS_CLEANUP \u003c/td\u003e\n    \u003ctd\u003e Keep it true to uninstall litmus after chaos \u003c/td\u003e\n    \u003ctd\u003e Optional \u003c/td\u003e\n    \u003ctd\u003e Default value is not set to true \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e EXPERIMENT_IMAGE \u003c/td\u003e\n    \u003ctd\u003e We can provide custom image for running chaos experiment \u003c/td\u003e\n    \u003ctd\u003e Optional \u003c/td\u003e\n    \u003ctd\u003e Default value is litmuschaos/go-runner \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e EXPERIMENT_IMAGE_TAG \u003c/td\u003e\n    \u003ctd\u003e We can set the image tag while using custom image for the chaos experiment \u003c/td\u003e\n    \u003ctd\u003e Optional \u003c/td\u003e\n    \u003ctd\u003e Default value is latest \u003c/td\u003e\n  \u003c/tr\u003e  \n  \u003ctr\u003e\n    \u003ctd\u003eIMAGE_PULL_POLICY \u003c/td\u003e\n    \u003ctd\u003e We can set the image pull policy while using custom image for running chaos experiment \u003c/td\u003e\n    \u003ctd\u003e Optional \u003c/td\u003e\n    \u003ctd\u003e Default value is Always \u003c/td\u003e\n  \u003c/tr\u003e  \n\u003c/table\u003e\n\n#### For EKS Cluster\n\nSetup AWS Credentials using [GitHub secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets). The secrets should now be populated to action using ENVs.\n\n```yaml\njobs:\n  chaos-action:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Configure AWS Credentials\n        uses: aws-actions/configure-aws-credentials@v1\n        with:\n          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}\n          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}\n          aws-region: ${{ secrets.AWS_REGION }}\n```\n\n\u003e Note: Either these secrets can be setup at Job level or have to be provided in all chaos-action steps.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuditgaurav%2Fk8s-actions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuditgaurav%2Fk8s-actions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuditgaurav%2Fk8s-actions/lists"}