Skip to content

Commit

Permalink
Change namespace to service disruption (#143)
Browse files Browse the repository at this point in the history
* change to service disruptioln

* replace namespace

* moving namespace to service disruption

* few doc updates
  • Loading branch information
paigerube14 authored Oct 11, 2023
1 parent 60b65bb commit be5a7de
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ services:
context: ./
dockerfile: ./node-io-hog/Dockerfile
image: quay.io/redhat-chaos/krkn-hub:node-io-hog
namespace-scenarios:
service-disruption-scenarios:
build:
context: ./
dockerfile: ./namespace-scenarios/Dockerfile
image: quay.io/redhat-chaos/krkn-hub:namespace-scenarios
dockerfile: ./service-disruption-scenarios/Dockerfile
image: quay.io/redhat-chaos/krkn-hub:service-disruption-scenarios
application-outages:
build:
context: ./
Expand Down
13 changes: 6 additions & 7 deletions docs/namespace-scenarios.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
### Namespace Scenarios
This scenario deletes a namespace in your Kubernetes/OpenShift cluster. More information can be found [here](https://github.com/redhat-chaos/krkn/blob/master/docs/namespace_scenarios.md).
### Namespace/Service Disruption Scenarios
This scenario deletes a namespace in your Kubernetes/OpenShift cluster. More information can be found [here](https://github.com/redhat-chaos/krkn/blob/master/docs/service_disruption_scenarios.md).

#### Run
If enabling [Cerberus](https://github.com/redhat-chaos/krkn#kraken-scenario-passfail-criteria-and-report) to monitor the cluster and pass/fail the scenario post chaos, refer [docs](https://github.com/redhat-chaos/krkn-hub/tree/main/docs/cerberus.md). Make sure to start it before injecting the chaos and set `CERBERUS_ENABLED` environment variable for the chaos injection container to autoconnect.

```
$ podman run --name=<container_name> --net=host --env-host=true -v <path-to-kube-config>:/root/.kube/config:Z -d quay.io/redhat-chaos/krkn-hub:namespace-scenarios
$ podman run --name=<container_name> --net=host --env-host=true -v <path-to-kube-config>:/root/.kube/config:Z -d quay.io/redhat-chaos/krkn-hub:service-disruption-scenarios
# podman logs -f <container_name or container_id> # Streams Kraken logs
$ podman inspect <container-name or container-id> --format "{{.State.ExitCode}}" # Outputs exit code which can considered as pass/fail for the scenario
```

```
$ docker run $(./get_docker_params.sh) --name=<container_name> --net=host -v <path-to-kube-config>:/root/.kube/config:Z -d quay.io/redhat-chaos/krkn-hub:namespace-scenarios
$ docker run $(./get_docker_params.sh) --name=<container_name> --net=host -v <path-to-kube-config>:/root/.kube/config:Z -d quay.io/redhat-chaos/krkn-hub:service-disruption-scenarios
OR
$ docker run -e <VARIABLE>=<value> --net=host -v <path-to-kube-config>:/root/.kube/config:Z -d quay.io/redhat-chaos/krkn-hub:namespace-scenarios
$ docker run -e <VARIABLE>=<value> --net=host -v <path-to-kube-config>:/root/.kube/config:Z -d quay.io/redhat-chaos/krkn-hub:service-disruption-scenarios
$ docker logs -f <container_name or container_id> # Streams Kraken logs
$ docker inspect <container-name or container-id> --format "{{.State.ExitCode}}" # Outputs exit code which can considered as pass/fail for the scenario
Expand All @@ -33,7 +33,6 @@ See list of variables that apply to all scenarios [here](all_scenarios_env.md) t

Parameter | Description | Default
----------------------- | ----------------------------------------------------------------- | ------------------------------------ |
ACTION | Action to take on the namespace | delete |
LABEL_SELECTOR | Label of the namespace to target. Set this parameter only if NAMESPACE is not set | "" |
NAMESPACE | Name of the namespace you want to target. Set this parameter only if LABEL_SELECTOR is not set | "openshift-etcd" |
SLEEP | Number of seconds to wait before polling to see if namespace exists again | 15 |
Expand All @@ -43,4 +42,4 @@ RUNS | Number of runs to execute the action | 1

**NOTE** In case of using custom metrics profile or alerts profile when `CAPTURE_METRICS` or `ENABLE_ALERTS` is enabled, mount the metrics profile from the host on which the container is run using podman/docker under `/root/kraken/config/metrics-aggregated.yaml` and `/root/kraken/config/alerts`. For example:
```
$ podman run --name=<container_name> --net=host --env-host=true -v <path-to-custom-metrics-profile>:/root/kraken/config/metrics-aggregated.yaml -v <path-to-custom-alerts-profile>:/root/kraken/config/alerts -v <path-to-kube-config>:/root/.kube/config:Z -d quay.io/redhat-chaos/krkn-hub:container-scenarios
$ podman run --name=<container_name> --net=host --env-host=true -v <path-to-custom-metrics-profile>:/root/kraken/config/metrics-aggregated.yaml -v <path-to-custom-alerts-profile>:/root/kraken/config/alerts -v <path-to-kube-config>:/root/.kube/config:Z -d quay.io/redhat-chaos/krkn-hub:service-disruption-scenarios
14 changes: 7 additions & 7 deletions prow/namespace-scenarios/prow_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ oc config view
echo "Printing node info"
for node in $(oc get nodes | awk 'NR!=1{print $1}'); do oc get node/$node -o yaml; done

source namespace-scenarios/env.sh
source service-disruption-scenarios/env.sh

krkn_loc=/root/kraken

# Substitute config with environment vars defined
export SCENARIO_FILE="- namespace-scenarios/namespace_scenario.yaml"
envsubst < namespace-scenarios/namespace_scenario.yaml.template > namespace-scenarios/namespace_scenario.yaml
envsubst < config.yaml.template > namespace_config.yaml
export SCENARIO_FILE="- service-disruption-scenarios/service-disruption_scenario.yaml"
envsubst < service-disruption-scenarios/service_disruption_scenario.yaml.template > service-disruption-scenarios/service_disruption_scenario.yaml
envsubst < config.yaml.template > service_disruption_config.yaml

# Run Kraken
cat namespace_config.yaml
cat namespace-scenarios/namespace_scenario.yaml
python3.9 $krkn_loc/run_kraken.py --config=namespace_config.yaml
cat service_disruption_config.yaml
cat service-disruption-scenarios/service_disruption_scenario.yaml
python3.9 $krkn_loc/run_kraken.py --config=service_disruption_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ RUN yum install -y which
# Copy configurations
COPY config.yaml.template /root/kraken/config/config.yaml.template
COPY metrics_config.yaml.template /root/kraken/config/kube_burner.yaml.template
COPY namespace-scenarios/env.sh /root/env.sh
COPY service-disruption-scenarios/env.sh /root/env.sh
COPY env.sh /root/main_env.sh
COPY namespace-scenarios/run.sh /root/run.sh
COPY namespace-scenarios/namespace_scenario.yaml.template /root/kraken/scenarios/namespace_scenario.yaml.template
COPY service-disruption-scenarios/run.sh /root/run.sh
COPY service-disruption-scenarios/namespace_scenario.yaml.template /root/kraken/scenarios/namespace_scenario.yaml.template
COPY common_run.sh /root/common_run.sh

ENTRYPOINT /root/run.sh
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/bin/bash

# Vars and respective defaults
export ACTION=${ACTION:="delete"}
export NAMESPACE=${NAMESPACE:="openshift-etcd"}
export LABEL_SELECTOR=${LABEL_SELECTOR:="''"}
export RUNS=${RUNS:=1}
export DELETE_COUNT=${DELETE_COUNT:=1}
export SLEEP=${SLEEP:=15}
export SCENARIO_TYPE=${SCENARIO_TYPE:=namespace_scenarios}
export SCENARIO_TYPE=${SCENARIO_TYPE:=service_disruption_scenarios}
export SCENARIO_FILE=${SCENARIO_FILE:=- scenarios/namespace_scenario.yaml}
export SCENARIO_POST_ACTION=${SCENARIO_POST_ACTION:=""}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
scenarios:
- action: $ACTION
namespace: $NAMESPACE
- namespace: $NAMESPACE
label_selector: $LABEL_SELECTOR
delete_count: $DELETE_COUNT
runs: $RUNS
Expand Down
File renamed without changes.

0 comments on commit be5a7de

Please sign in to comment.