Skip to content

Commit

Permalink
feat(crd): update chaosexperiment schema (litmuschaos#13)
Browse files Browse the repository at this point in the history
Updates the chaosexperiment custom resource schema to contain low-level chaos params eliminating need for chaosgraph

Signed-off-by: ksatchit <karthik.s@openebs.io>
  • Loading branch information
Karthik Satchitanand authored and Amit Kumar Das committed May 10, 2019
1 parent 3ecb5fe commit 0a02781
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 311 deletions.
57 changes: 39 additions & 18 deletions deploy/crds/chaosexperiment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,54 @@ metadata:

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

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:

## A low-level definition of chaos parameters which is fed to the executor
## for running the experiment.

## 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.
## failures. This Component info is generally kept to a minimum and passed as ENV to
## the actual chaos-runner/executor pod/container.

definition:

labels:
name: pod-delete

image:

env:
- name: ANSIBLE_STDOUT_CALLBACK
value: ""

## Injected by chaosengine
- name: APP_NAMESPACE
value: ""

## Injected by chaosengine
- name: APP_LABEL
value: ""

- name: FORCE_DELETE
value: ""

## The chaos operator can use different execution frameworks to achieve
## to achieve a certain chaos operation. It could use Litmus or Chaostoolkit
## etc..,

components:
container: ""
nwinterface: ""
node: ""
pvc: ""
disk: ""
- name: LIB
value: ""

command: ["/bin/bash"]
args: ["-c", "ansible-playbook ./experiments/chaos/pod_delete/test.yml -i /etc/ansible/hosts -vv; exit 0"]
41 changes: 0 additions & 41 deletions deploy/crds/chaosgraph.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions deploy/crds/chaosgraph_crd.yaml

This file was deleted.

38 changes: 22 additions & 16 deletions pkg/apis/litmuschaos/v1alpha1/chaosexperiment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
// 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.
type ChaosExperimentSpec struct {
// ChaosGraph refers to the resource carrying low-level chaos options
Chaosgraph string `json:"chaosgraph"`
Components ComponentUnderTest `json:"components"`
// Definition carries low-level chaos options
Definition ExperimentDef `json:"definition"`
}

// ChaosExperimentStatus defines the observed state of ChaosExperiment
Expand All @@ -22,18 +21,25 @@ type ChaosExperimentStatus struct {
// Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html
}

// ComponentUnderTest defines information about component subjected to chaos in an experiment
type ComponentUnderTest struct {
//Name of container under test in a pod
Container string `json:"container"`
//Name of interface under test in a container
NWinterface string `json:"nwinterface"`
//Name of node under test in a K8s cluster
Node string `json:"node"`
//Name of persistent volume claim used by app
PVC string `json:"pvc"`
//Name of backend disk under test on a node
Disk string `json:"disk"`
// ExperimentDef defines information about nature of chaos & components subjected to it
type ExperimentDef struct {
// Default labels of the executor pod
// +optional
Labels map[string]string `json:"labels"`
// Image of the chaos executor
Image string `json:"image"`
// List of ENV vars passed to executor pod
ENVList []ENVPair `json:"env"`
// Defines command to invoke experiment
Command []string `json:"command"`
// Defines arguments to executor's entrypoint command
Args []string `json:"args"`
}

// ENVPair defines env var list to hold chaos params
type ENVPair struct {
Name string `json:"name"`
Value string `json:"value"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -43,7 +49,7 @@ type ComponentUnderTest struct {
type ChaosExperiment struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ChaosExperimentSpec `json:"spec,omitempty"`
Status ChaosExperimentStatus `json:"status,omitempty"`
}
Expand Down
68 changes: 0 additions & 68 deletions pkg/apis/litmuschaos/v1alpha1/chaosgraph_types.go

This file was deleted.

Loading

0 comments on commit 0a02781

Please sign in to comment.