Skip to content

Commit

Permalink
feat: improve aws chaos, adding filters support
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Tonks <[email protected]>
Signed-off-by: Kenneth Buck <[email protected]>
  • Loading branch information
miketonks-form3 committed Nov 15, 2023
1 parent f44a688 commit 8c38ee7
Show file tree
Hide file tree
Showing 21 changed files with 1,644 additions and 26 deletions.
33 changes: 29 additions & 4 deletions api/v1alpha1/awschaos_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ type AWSChaosSpec struct {
// +optional
Duration *string `json:"duration,omitempty" webhook:"Duration"`

// SecretName defines the name of kubernetes secret.
// +optional
SecretName *string `json:"secretName,omitempty" webhook:",nilable"`

AWSSelector `json:",inline"`

// RemoteCluster represents the remote cluster where the chaos will be deployed
Expand All @@ -91,6 +87,10 @@ type AWSSelector struct {
// AWSRegion defines the region of aws.
AWSRegion string `json:"awsRegion"`

// SecretName defines the name of kubernetes secret.
// +optional
SecretName *string `json:"secretName,omitempty" webhook:",nilable"`

// Ec2Instance indicates the ID of the ec2 instance.
Ec2Instance string `json:"ec2Instance"`

Expand All @@ -105,6 +105,31 @@ type AWSSelector struct {
// +ui:form:when=action=='detach-volume'
// +optional
DeviceName *string `json:"deviceName,omitempty" webhook:"AWSDeviceName,nilable"`

// Filters defines the filters to pass to the AWS api to query the list of instances.
// Can be specified instead of Ec2Instance, in order to specify instances by tag or other attributes
// Any parameter supported by AWS DescribeInstances method can be used.
// For details see: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html
Filters []*AWSFilter `json:"filters,omitempty"`

// Mode defines the mode to run chaos action.
// Used only if Filters is specified.
// Supported mode: one / all / fixed / fixed-percent / random-max-percent
// +kubebuilder:validation:Enum=one;all;fixed;fixed-percent;random-max-percent
// +optional
Mode SelectorMode `json:"mode,omitempty"`

// Value is required when the mode is set to `FixedMode` / `FixedPercentMode` / `RandomMaxPercentMode`.
// If `FixedMode`, provide an integer of pods to do chaos action.
// If `FixedPercentMode`, provide a number from 0-100 to specify the percent of pods the server can do chaos action.
// IF `RandomMaxPercentMode`, provide a number from 0-100 to specify the max percent of pods to do chaos action
// +optional
Value string `json:"value,omitempty"`
}

type AWSFilter struct {
Name string `json:"name"`
Values []string `json:"values"`
}

func (obj *AWSChaos) GetSelectorSpecs() map[string]interface{} {
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha1/awschaos_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ var _ = Describe("AWSChaos", func() {
Spec: AWSChaosSpec{
Action: Ec2Stop,
AWSSelector: AWSSelector{
SecretName: &testSecretName,
Ec2Instance: testInstance,
Mode: OneMode,
},
SecretName: &testSecretName,
},
}

Expand Down
41 changes: 36 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions config/crd/bases/chaos-mesh.org_awschaos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,51 @@ spec:
description: Endpoint indicates the endpoint of the aws server. Just
used it in test now.
type: string
filters:
description: 'Filters defines the filters to pass to the AWS api to
query the list of instances. Can be specified instead of Ec2Instance,
in order to specify instances by tag or other attributes Any parameter
supported by AWS DescribeInstances method can be used. For details
see: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html'
items:
properties:
name:
type: string
values:
items:
type: string
type: array
required:
- name
- values
type: object
type: array
mode:
description: 'Mode defines the mode to run chaos action. Used only
if Filters is specified. Supported mode: one / all / fixed / fixed-percent
/ random-max-percent'
enum:
- one
- all
- fixed
- fixed-percent
- random-max-percent
type: string
remoteCluster:
description: RemoteCluster represents the remote cluster where the
chaos will be deployed
type: string
secretName:
description: SecretName defines the name of kubernetes secret.
type: string
value:
description: Value is required when the mode is set to `FixedMode`
/ `FixedPercentMode` / `RandomMaxPercentMode`. If `FixedMode`, provide
an integer of pods to do chaos action. If `FixedPercentMode`, provide
a number from 0-100 to specify the percent of pods the server can
do chaos action. IF `RandomMaxPercentMode`, provide a number from
0-100 to specify the max percent of pods to do chaos action
type: string
volumeID:
description: EbsVolume indicates the ID of the EBS volume. Needed
in detach-volume.
Expand Down
121 changes: 121 additions & 0 deletions config/crd/bases/chaos-mesh.org_schedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,52 @@ spec:
description: Endpoint indicates the endpoint of the aws server.
Just used it in test now.
type: string
filters:
description: 'Filters defines the filters to pass to the AWS api
to query the list of instances. Can be specified instead of
Ec2Instance, in order to specify instances by tag or other attributes
Any parameter supported by AWS DescribeInstances method can
be used. For details see: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html'
items:
properties:
name:
type: string
values:
items:
type: string
type: array
required:
- name
- values
type: object
type: array
mode:
description: 'Mode defines the mode to run chaos action. Used
only if Filters is specified. Supported mode: one / all / fixed
/ fixed-percent / random-max-percent'
enum:
- one
- all
- fixed
- fixed-percent
- random-max-percent
type: string
remoteCluster:
description: RemoteCluster represents the remote cluster where
the chaos will be deployed
type: string
secretName:
description: SecretName defines the name of kubernetes secret.
type: string
value:
description: Value is required when the mode is set to `FixedMode`
/ `FixedPercentMode` / `RandomMaxPercentMode`. If `FixedMode`,
provide an integer of pods to do chaos action. If `FixedPercentMode`,
provide a number from 0-100 to specify the percent of pods the
server can do chaos action. IF `RandomMaxPercentMode`, provide
a number from 0-100 to specify the max percent of pods to do
chaos action
type: string
volumeID:
description: EbsVolume indicates the ID of the EBS volume. Needed
in detach-volume.
Expand Down Expand Up @@ -3306,6 +3345,37 @@ spec:
description: Endpoint indicates the endpoint of the
aws server. Just used it in test now.
type: string
filters:
description: 'Filters defines the filters to pass to
the AWS api to query the list of instances. Can be
specified instead of Ec2Instance, in order to specify
instances by tag or other attributes Any parameter
supported by AWS DescribeInstances method can be used.
For details see: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html'
items:
properties:
name:
type: string
values:
items:
type: string
type: array
required:
- name
- values
type: object
type: array
mode:
description: 'Mode defines the mode to run chaos action.
Used only if Filters is specified. Supported mode:
one / all / fixed / fixed-percent / random-max-percent'
enum:
- one
- all
- fixed
- fixed-percent
- random-max-percent
type: string
remoteCluster:
description: RemoteCluster represents the remote cluster
where the chaos will be deployed
Expand All @@ -3314,6 +3384,16 @@ spec:
description: SecretName defines the name of kubernetes
secret.
type: string
value:
description: Value is required when the mode is set
to `FixedMode` / `FixedPercentMode` / `RandomMaxPercentMode`.
If `FixedMode`, provide an integer of pods to do chaos
action. If `FixedPercentMode`, provide a number from
0-100 to specify the percent of pods the server can
do chaos action. IF `RandomMaxPercentMode`, provide
a number from 0-100 to specify the max percent of
pods to do chaos action
type: string
volumeID:
description: EbsVolume indicates the ID of the EBS volume.
Needed in detach-volume.
Expand Down Expand Up @@ -6398,6 +6478,37 @@ spec:
description: Endpoint indicates the endpoint of
the aws server. Just used it in test now.
type: string
filters:
description: 'Filters defines the filters to pass
to the AWS api to query the list of instances.
Can be specified instead of Ec2Instance, in order
to specify instances by tag or other attributes
Any parameter supported by AWS DescribeInstances
method can be used. For details see: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html'
items:
properties:
name:
type: string
values:
items:
type: string
type: array
required:
- name
- values
type: object
type: array
mode:
description: 'Mode defines the mode to run chaos
action. Used only if Filters is specified. Supported
mode: one / all / fixed / fixed-percent / random-max-percent'
enum:
- one
- all
- fixed
- fixed-percent
- random-max-percent
type: string
remoteCluster:
description: RemoteCluster represents the remote
cluster where the chaos will be deployed
Expand All @@ -6406,6 +6517,16 @@ spec:
description: SecretName defines the name of kubernetes
secret.
type: string
value:
description: Value is required when the mode is
set to `FixedMode` / `FixedPercentMode` / `RandomMaxPercentMode`.
If `FixedMode`, provide an integer of pods to
do chaos action. If `FixedPercentMode`, provide
a number from 0-100 to specify the percent of
pods the server can do chaos action. IF `RandomMaxPercentMode`, provide
a number from 0-100 to specify the max percent
of pods to do chaos action
type: string
volumeID:
description: EbsVolume indicates the ID of the EBS
volume. Needed in detach-volume.
Expand Down
Loading

0 comments on commit 8c38ee7

Please sign in to comment.