diff --git a/deploy/crds/chaosexperiment.yaml b/deploy/crds/chaosexperiment.yaml index 9a56991e9d5..c865a4a715b 100644 --- a/deploy/crds/chaosexperiment.yaml +++ b/deploy/crds/chaosexperiment.yaml @@ -16,33 +16,54 @@ metadata: ## Eventually launched chaos litmusbook/job will bear - 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"] diff --git a/deploy/crds/chaosgraph.yaml b/deploy/crds/chaosgraph.yaml deleted file mode 100644 index 38eda833dac..00000000000 --- a/deploy/crds/chaosgraph.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- - -## 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"] diff --git a/deploy/crds/chaosgraph_crd.yaml b/deploy/crds/chaosgraph_crd.yaml deleted file mode 100644 index d40d7faf4aa..00000000000 --- a/deploy/crds/chaosgraph_crd.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: chaosgraph.litmuschaos.io -spec: - group: litmuschaos.io - names: - kind: ChaosGraph - listKind: ChaosGraphList - plural: chaosgraphs - singular: chaosgraphs - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - type: object - status: - type: object - version: v1alpha1 - versions: - - name: v1alpha1 - served: true - storage: true diff --git a/pkg/apis/litmuschaos/v1alpha1/chaosexperiment_types.go b/pkg/apis/litmuschaos/v1alpha1/chaosexperiment_types.go index 5de8f87a81c..6e8c92cceab 100644 --- a/pkg/apis/litmuschaos/v1alpha1/chaosexperiment_types.go +++ b/pkg/apis/litmuschaos/v1alpha1/chaosexperiment_types.go @@ -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 @@ -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 @@ -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"` } diff --git a/pkg/apis/litmuschaos/v1alpha1/chaosgraph_types.go b/pkg/apis/litmuschaos/v1alpha1/chaosgraph_types.go deleted file mode 100644 index f2b046f4c6b..00000000000 --- a/pkg/apis/litmuschaos/v1alpha1/chaosgraph_types.go +++ /dev/null @@ -1,68 +0,0 @@ -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// ChaosGraphSpec defines the desired state of ChaosGraph -// +k8s:openapi-gen=true -// ChaosGraph defines the low-level chaos options and the executor infrastructure -type ChaosGraphSpec struct { - // Defines the chaos executor framework/infrastructure to run the experiment - Executor string `json:"executor"` - // Defines the chaos parameters and execution artifacts - Definition ChaosRunDefinition `json:"definition"` -} - -// ChaosRunDefinition defines the information fed to the executor framework -// to enable successful chaos injection -type ChaosRunDefinition struct { - // Default labels of the executor pod - // +optional - Labels map[string]string `json:"labels"` - // 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"` -} - -// ChaosGraphStatus defines the observed state of ChaosGraph -// +k8s:openapi-gen=true -type ChaosGraphStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file - // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ChaosGraph is the Schema for the chaostemplates API -// +k8s:openapi-gen=true -type ChaosGraph struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ChaosGraphSpec `json:"spec,omitempty"` - Status ChaosGraphStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ChaosGraphList contains a list of ChaosGraph -type ChaosGraphList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ChaosGraph `json:"items"` -} - -func init() { - SchemeBuilder.Register(&ChaosGraph{}, &ChaosGraphList{}) -} diff --git a/pkg/apis/litmuschaos/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/litmuschaos/v1alpha1/zz_generated.deepcopy.go index cb8356e1015..23862ea988a 100644 --- a/pkg/apis/litmuschaos/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/litmuschaos/v1alpha1/zz_generated.deepcopy.go @@ -136,7 +136,7 @@ func (in *ChaosExperiment) DeepCopyInto(out *ChaosExperiment) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) out.Status = in.Status return } @@ -195,7 +195,7 @@ func (in *ChaosExperimentList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChaosExperimentSpec) DeepCopyInto(out *ChaosExperimentSpec) { *out = *in - out.Components = in.Components + in.Definition.DeepCopyInto(&out.Definition) return } @@ -226,101 +226,57 @@ func (in *ChaosExperimentStatus) DeepCopy() *ChaosExperimentStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChaosGraph) DeepCopyInto(out *ChaosGraph) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChaosGraph. -func (in *ChaosGraph) DeepCopy() *ChaosGraph { - if in == nil { - return nil - } - out := new(ChaosGraph) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ChaosGraph) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChaosGraphList) DeepCopyInto(out *ChaosGraphList) { +func (in *ChaosSchedule) DeepCopyInto(out *ChaosSchedule) { *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ChaosGraph, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChaosGraphList. -func (in *ChaosGraphList) DeepCopy() *ChaosGraphList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChaosSchedule. +func (in *ChaosSchedule) DeepCopy() *ChaosSchedule { if in == nil { return nil } - out := new(ChaosGraphList) + out := new(ChaosSchedule) in.DeepCopyInto(out) return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ChaosGraphList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChaosGraphSpec) DeepCopyInto(out *ChaosGraphSpec) { +func (in *ENVPair) DeepCopyInto(out *ENVPair) { *out = *in - in.Definition.DeepCopyInto(&out.Definition) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChaosGraphSpec. -func (in *ChaosGraphSpec) DeepCopy() *ChaosGraphSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ENVPair. +func (in *ENVPair) DeepCopy() *ENVPair { if in == nil { return nil } - out := new(ChaosGraphSpec) + out := new(ENVPair) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChaosGraphStatus) DeepCopyInto(out *ChaosGraphStatus) { +func (in *ExperimentAttributes) DeepCopyInto(out *ExperimentAttributes) { *out = *in + out.Components = in.Components + out.Schedule = in.Schedule return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChaosGraphStatus. -func (in *ChaosGraphStatus) DeepCopy() *ChaosGraphStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExperimentAttributes. +func (in *ExperimentAttributes) DeepCopy() *ExperimentAttributes { if in == nil { return nil } - out := new(ChaosGraphStatus) + out := new(ExperimentAttributes) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChaosRunDefinition) DeepCopyInto(out *ChaosRunDefinition) { +func (in *ExperimentDef) DeepCopyInto(out *ExperimentDef) { *out = *in if in.Labels != nil { in, out := &in.Labels, &out.Labels @@ -347,78 +303,12 @@ func (in *ChaosRunDefinition) DeepCopyInto(out *ChaosRunDefinition) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChaosRunDefinition. -func (in *ChaosRunDefinition) DeepCopy() *ChaosRunDefinition { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExperimentDef. +func (in *ExperimentDef) DeepCopy() *ExperimentDef { if in == nil { return nil } - out := new(ChaosRunDefinition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChaosSchedule) DeepCopyInto(out *ChaosSchedule) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChaosSchedule. -func (in *ChaosSchedule) DeepCopy() *ChaosSchedule { - if in == nil { - return nil - } - out := new(ChaosSchedule) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ComponentUnderTest) DeepCopyInto(out *ComponentUnderTest) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentUnderTest. -func (in *ComponentUnderTest) DeepCopy() *ComponentUnderTest { - if in == nil { - return nil - } - out := new(ComponentUnderTest) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ENVPair) DeepCopyInto(out *ENVPair) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ENVPair. -func (in *ENVPair) DeepCopy() *ENVPair { - if in == nil { - return nil - } - out := new(ENVPair) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExperimentAttributes) DeepCopyInto(out *ExperimentAttributes) { - *out = *in - out.Components = in.Components - out.Schedule = in.Schedule - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExperimentAttributes. -func (in *ExperimentAttributes) DeepCopy() *ExperimentAttributes { - if in == nil { - return nil - } - out := new(ExperimentAttributes) + out := new(ExperimentDef) in.DeepCopyInto(out) return out }