Skip to content

Commit a752022

Browse files
committed
Merge branch 'az-loss' into release-07-07-23
2 parents d671d10 + cea85b7 commit a752022

38 files changed

+2326
-19
lines changed

README.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,59 @@ See the following demo video for a quick view of Chaos Mesh:
3636

3737
[![Watch the video](./static/demo.gif)](https://www.youtube.com/watch?v=ifZEwdJO868)
3838

39+
## Form3-specific instructions
40+
41+
### Build CRDs
42+
43+
After changing/adding a go struct that corresponds to a [CRD structure](https://github.com/form3tech/chaos-mesh/blob/nv-gk-az-loss/api/v1alpha1/awsazchaos_types.go)
44+
45+
Run
46+
```sh
47+
make generate && make yaml
48+
```
49+
This will create new CRDS for the new custom Chaos, and update existing schedules and workflows accordingly to accomodate the new custom chaos.
50+
51+
### Build docker images and helm charts
52+
53+
In order to build new docker images and helm charts containing your custom CRD (and its controller code)
54+
55+
Run
56+
57+
```sh
58+
make all
59+
# AWS_ACCOUNT_ID and region which hosts the ECR where you want to push the docker image to
60+
AWS_ACCOUNT_ID="AWS_ACCOUNT_ID_HERE"
61+
AWS_REGION="AWS_REGION_HERE"
62+
TAG="YOUR_BUILD_TAG_HERE"
63+
64+
# `make all` creates docker images with the latest tag and point to ghcr repo. We need to tag them properly to prepare the push to AMAZON ECR
65+
docker tag ghcr.io/chaos-mesh/chaos-daemon:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/chaos-mesh/chaos-daemon:$TAG
66+
docker tag ghcr.io/chaos-mesh/chaos-dashboard:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/chaos-mesh/chaos-dashboard:$TAG
67+
docker tag ghcr.io/chaos-mesh/chaos-mesh:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/chaos-mesh/chaos-mesh:$TAG
68+
69+
## Authenticate to the ECR docker repo using https://github.com/form3tech/docker-build-scripts/blob/master/scripts/docker-ecr-login.sh
70+
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/chaos-mesh/chaos-daemon:$TAG
71+
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/chaos-mesh/chaos-dashboard:$TAG
72+
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/chaos-mesh/chaos-mesh:$TAG
73+
74+
75+
# package the helm charts
76+
cd helm
77+
helm package chaos-mesh --version $TAG --app-version $TAG
78+
79+
## Authenticate to the ECR helm repo
80+
ECR_URL= $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com
81+
export HELM_EXPERIMENTAL_OCI=1;aws ecr get-login-password --region $(AWS_REGION) | \
82+
helm registry login --username AWS --password-stdin $(ECR_URL)
83+
84+
# Push the chart
85+
helm push chaos-mesh-$TAG.tgz oci://$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/charts.tech.form3/
86+
```
87+
88+
89+
90+
91+
3992
## Chaos Operator
4093

4194
Chaos Operator injects chaos into the applications and Kubernetes infrastructure in a manageable way, which provides easy, custom definitions for chaos experiments and automatic orchestration. There are three components at play:
@@ -160,4 +213,4 @@ Chaos Mesh is licensed under the Apache License, Version 2.0. See [LICENSE](./LI
160213

161214
## Trademark
162215

163-
Chaos Mesh is a trademark of The Linux Foundation. All rights reserved.
216+
Chaos Mesh is a trademark of The Linux Foundation. All rights reserved.

api/v1alpha1/awsazchaos_types.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package v1alpha1
2+
3+
import (
4+
"encoding/json"
5+
6+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7+
)
8+
9+
// +kubebuilder:object:root=true
10+
// +kubebuilder:printcolumn:name="duration",type=string,JSONPath=`.spec.duration`
11+
// +chaos-mesh:experiment
12+
13+
// AWSAzChaos is the Schema for the helloworldchaos API
14+
type AWSAzChaos struct {
15+
metav1.TypeMeta `json:",inline"`
16+
metav1.ObjectMeta `json:"metadata,omitempty"`
17+
18+
Spec AWSAzChaosSpec `json:"spec"`
19+
Status AWSAzChaosStatus `json:"status,omitempty"`
20+
}
21+
22+
var (
23+
_ InnerObjectWithCustomStatus = (*AWSAzChaos)(nil)
24+
_ InnerObjectWithSelector = (*AWSAzChaos)(nil)
25+
_ InnerObject = (*AWSAzChaos)(nil)
26+
)
27+
28+
// AWSAzChaosSpec is the content of the specification for a AWSAzChaos
29+
type AWSAzChaosSpec struct {
30+
// ContainerSelector specifies target
31+
AWSAZSelector `json:",inline"`
32+
33+
// Duration represents the duration of the chaos action
34+
// +optional
35+
Duration *string `json:"duration,omitempty"`
36+
37+
// RemoteCluster represents the remote cluster where the chaos will be deployed
38+
// +optional
39+
RemoteCluster string `json:"remoteCluster,omitempty"`
40+
}
41+
42+
// AWSAzChaosStatus represents the status of a HelloWorldChaos
43+
type AWSAzChaosStatus struct {
44+
ChaosStatus `json:",inline"`
45+
// SubnetToACL represents the connection between a subnet and its Network ACL
46+
SubnetToACL map[string]string `json:"subnetToACL,omitempty"`
47+
}
48+
49+
type AWSAZSelector struct {
50+
// TODO: it would be better to split them into multiple different selector and implementation
51+
// but to keep the minimal modification on current implementation, it hasn't been splited.
52+
53+
// AWSRegion defines the region of aws.
54+
Stack string `json:"stack"`
55+
56+
// AvailabilityZone indicates the Availability zone to be taken down
57+
AvailabilityZone string `json:"az"`
58+
}
59+
60+
// GetSelectorSpecs is a getter for selectors
61+
func (obj *AWSAzChaos) GetSelectorSpecs() map[string]interface{} {
62+
return map[string]interface{}{
63+
".": &obj.Spec.AWSAZSelector,
64+
}
65+
}
66+
67+
func (obj *AWSAZSelector) Id() string {
68+
// TODO: handle the error here
69+
// or ignore it is enough ?
70+
json, _ := json.Marshal(obj)
71+
72+
return string(json)
73+
}
74+
75+
func (obj *AWSAzChaos) GetCustomStatus() interface{} {
76+
return &obj.Status.SubnetToACL
77+
}

api/v1alpha1/awschaos_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ type AWSChaos struct {
3636
Status AWSChaosStatus `json:"status,omitempty"`
3737
}
3838

39-
var _ InnerObjectWithSelector = (*AWSChaos)(nil)
40-
var _ InnerObject = (*AWSChaos)(nil)
39+
var (
40+
_ InnerObjectWithSelector = (*AWSChaos)(nil)
41+
_ InnerObject = (*AWSChaos)(nil)
42+
)
4143

4244
// AWSChaosAction represents the chaos action about aws.
4345
type AWSChaosAction string

api/v1alpha1/zz_generated.chaosmesh.go

Lines changed: 149 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.chaosmesh_test.go

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)