Skip to content

Commit

Permalink
(feat)(cr) define the chaos custom resource specifications (litmuscha…
Browse files Browse the repository at this point in the history
…os#3)

* (feat)(cr) define the chaos custom resource specifications

Signed-off-by: ksatchit <[email protected]>
  • Loading branch information
Karthik Satchitanand authored and Amit Kumar Das committed Apr 24, 2019
1 parent 03d5a66 commit 4a401fe
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 26 deletions.
101 changes: 101 additions & 0 deletions deploy/crds/chaosengine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
## This is the chaos engine resource requested by dev for the nginx
## app, i.e., the user facing custom resource. Mapped to a dedicated
## controller which triggers the actual chaos experiments as per
## defined schedule. The app developer is expected to annotate the
## application with litmuschaos.io/engine: <engine-name>

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
## Eventually launched chaos (cron) jobs will bear <engine>-<exp></reference>-<hash>
name: engine-nginx
namespace: litmus
spec:

## This will be used to identify AUT (Application-Under-Test)
## This app will be value of probed for annotation "litmuschaos.io/chaos"
## to check whether it can be subjected to chaos.

appinfo:
appns: default
applabel: "app=nginx"

## The chaos experiments themselves will be "pulled" via
## downloadable litmus charts and versioned against it
## The chaos operator comes with a default set of experiments

experiments:
- name: pod-delete
spec:

# The experiments can be ranked on execution priority
rank: 1

# An experiment may need additional data points
# "apart" from the "chaos-specific params" defined
# in the template. See spec of flaky-networks for
# case-in-point

# The same will be available in experiment spec as
# well, this definition here will override that.

components:

- name: network-delay
spec:
rank: 2
component:
nwinterface: ""

- name: disk-fill
spec:
rank: 4
component:
disk: ""

# Individual experiments can also have schedule

schedule:
interval: ""
excludedTimes: ""
excludedDays: ""
concurrencyPolicy: ""

- name: container-kill
spec:
ranks: 3
component:
container: ""

schedule:
# quarter-hourly, half-hourly, hourly, bi-hourly, trihoral, daily
interval: "half-hourly"
excludedTimes: ""
excludedDays: ""
concurrencyPolicy: ""

## Hold status of experiments - traceback from chaos experiment
## results. In case of scheduled experiments, the status, verdict
## and lastUpdateTime keep getting updated
status:
experiments:
- name: pod-delete
status: completed
verdict: pass
lastUpdateTime: "2019-04-23T09:10:50Z"

- name: network-delay
status: completed
verdict: pass
lastUpdateTime: "2019-04-23T09:13:50Z"

- name: disk-fill
status: completed
verdict: fail
lastUpdateTime: "2019-04-23T09:16:50Z"

- name: container-kill
status: progressing
verdict: ""
lastUpdateTime: "2019-04-23T09:23:50Z"
48 changes: 48 additions & 0 deletions deploy/crds/chaosexperiment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
## An experiment is the definition of a chaos test and is listed as an item
## in the chaos engine to be run against a given app. Consists of reference
## to chaosGraph (which has chaos param details and executor spec) and also
## component information for the Object-Under-Test. The results upon running
## this experiment is relayed back to the chaos engine which invoked it.

## Experiments can be pulled from litmus charts and are versioned based on
## chart.

## Charts should (not?) be auto-upgraded

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosExperiment
metadata:

## Eventually launched chaos litmusbook/job will bear <name>-<hash>
name: pod-delete
namespace: nginx
labels:
chart/type: kubernetes
chart/version: 0.9

description:
message: |
Deletes a pod belonging to a deployment/statefulset/daemonset
a specified number of times
spec:

## A predefined Chaos template type. Analogy: *Similar* in function to storage
## classes. Will contain params "specific" to that chaos operation w/ default values.
## By default, the experiment is mapped to a chaosgraph of the same name, unless
## explicitly specified

# chaosgraph:

## Some experiments need more info on the "object of chaos". For example, in case
## of container crash tests in a multi-container app, it is necessary to know both
## general app info (namespace, labels) as well as container name which has to undergo
## failures. Component list can be kept to a minimum.

components:
container: ""
nwinterface: ""
node: ""
pvc: ""
disk: ""

41 changes: 41 additions & 0 deletions deploy/crds/chaosgraph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---

## The resource that contains the actual/low-level chaos params.
## Consists of executor definition in its spec, with ENV default
## values and entrypoint scripts (playbooks). The chaosGraph is
## referenced in the chaostype parameter of the chaosExperiment
## resource. Consists of default values for chaos-specific params
## which are expected to be overridden from the chaosExperiment

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosGraph
metadata:
name: pod-delete
namespace: nginx
labels:
chart/type: kubernetes
chart/version: "1.0"
spec:
## The chaos operator can use different execution frameworks
## to achieve a certain chaos operation. It could use Litmus
## or chaostoolkit or pumba etc.., Default: litmus
executor: litmus

## A low-level definition of chaos parameters which is fed
## to the executor for running the experiment
definition:
labels:
name: pod-delete
env:
- name: ANSIBLE_STDOUT_CALLBACK
value: default
- name: APP_NAMESPACE # override from c.engine
value: ""
- name: APP_LABEL # override from c.engine
value: ""
- name: CHAOS_TYPE
value: "pod-delete"
- name: TARGET_CONTAINER
value: "nginx" # override from c.experiment
command: ["/bin/bash"]
args: ["-c", "ansible-playbook ./experiments/chaos/simple_pod_failure/test.yml -i /etc/ansible/hosts -vv; exit 0"]
7 changes: 0 additions & 7 deletions deploy/crds/litmuschaos_v1alpha1_chaosengine_cr.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions deploy/crds/litmuschaos_v1alpha1_chaosexperiment_cr.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: chaostemplates.litmuschaos.io
name: chaosgraph.litmuschaos.io
spec:
group: litmuschaos.io
names:
kind: ChaosTemplate
listKind: ChaosTemplateList
plural: chaostemplates
singular: chaostemplate
kind: ChaosGraph
listKind: ChaosGraphList
plural: chaosgraphs
singular: chaosgraphs
scope: Namespaced
subresources:
status: {}
Expand Down
7 changes: 0 additions & 7 deletions deploy/crds/litmuschaos_v1alpha1_chaostemplate_cr.yaml

This file was deleted.

0 comments on commit 4a401fe

Please sign in to comment.