Skip to content

Commit 0180f30

Browse files
committed
feat:add fault injection
1 parent f2df7c1 commit 0180f30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3759
-1424
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ bin/
1616
# Dependency directories (remove the comment below to include it)
1717
# vendor/
1818

19+
.vscode
1920
.idea/**
2021
demo/**
2122
testdemo/**
22-
.DS_Store
23+
.DS_Store
24+
.vscode/launch.json

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
4+
CLUSTER_NAME ?= kindcluster
45

56
CRD_OPTIONS ?= "crd:crdVersions=v1"
67

@@ -77,6 +78,19 @@ docker-push: ## Push docker image with the manager.
7778

7879
##@ Deployment
7980

81+
deploy-local-kind:
82+
sed -i'' -e 's@name: .*@name: '"${CLUSTER_NAME}"'@' ./e2e/scripts/kind-conf.yaml
83+
kind create cluster --image kindest/node:v1.21.1 --config ./e2e/scripts/kind-conf.yaml
84+
85+
kind-kube-config:
86+
kind get kubeconfig --name ${CLUSTER_NAME} > /tmp/kind-kubeconfig.yaml
87+
export KUBECONFIG=/tmp/kind-kubeconfig.yaml
88+
89+
kind: deploy-local-kind kind-kube-config # deploy kind
90+
91+
clear-kind:
92+
kind delete cluster --name ${CLUSTER_NAME}
93+
8094
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
8195
$(KUSTOMIZE) build config/crd
8296

config/crd/bases/ctrlmesh.kusionstack.io_faultinjections.yaml

+51-37
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ spec:
4949
upstream service is faulty.
5050
properties:
5151
httpStatus:
52+
description: HttpStatus is used to indicate the HTTP status
53+
code to return to the caller.
5254
format: int32
5355
type: integer
5456
percent:
@@ -63,6 +65,8 @@ spec:
6365
etc.
6466
properties:
6567
fixedDelay:
68+
description: FixedDelay is used to indicate the amount of
69+
delay in seconds.
6670
type: string
6771
percent:
6872
description: Percent of requests on which the delay will
@@ -72,43 +76,53 @@ spec:
7276
match:
7377
description: Match specifies a set of criterion to be met in
7478
order for the rule to be applied to the HTTP request.
75-
properties:
76-
method:
77-
items:
78-
type: string
79-
type: array
80-
relatedResources:
81-
items:
82-
properties:
83-
apiGroups:
84-
items:
85-
type: string
86-
type: array
87-
namespaces:
88-
items:
89-
type: string
90-
type: array
91-
resources:
92-
items:
93-
type: string
94-
type: array
95-
verbs:
96-
items:
97-
type: string
98-
type: array
99-
type: object
100-
type: array
101-
url:
102-
description: 'TODO: http match'
103-
items:
104-
properties:
105-
matchType:
106-
type: string
107-
value:
108-
type: string
109-
type: object
110-
type: array
111-
type: object
79+
items:
80+
properties:
81+
relatedResources:
82+
items:
83+
properties:
84+
apiGroups:
85+
items:
86+
type: string
87+
type: array
88+
namespaces:
89+
items:
90+
type: string
91+
type: array
92+
resources:
93+
items:
94+
type: string
95+
type: array
96+
verbs:
97+
items:
98+
type: string
99+
type: array
100+
type: object
101+
type: array
102+
restRules:
103+
items:
104+
description: RestRule defines the target rest resource
105+
of the limiting policy
106+
properties:
107+
method:
108+
description: 'Method specifies the http method of
109+
the request, like: PUT, POST, GET, DELETE.'
110+
items:
111+
type: string
112+
type: array
113+
url:
114+
description: URL gives the location of the rest
115+
request, in standard URL form (`scheme://host:port/path`)
116+
items:
117+
type: string
118+
type: array
119+
required:
120+
- method
121+
- url
122+
type: object
123+
type: array
124+
type: object
125+
type: array
112126
type: object
113127
type: array
114128
selector:

config/demo/circuitbreaker-demo.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ apiVersion: ctrlmesh.kusionstack.io/v1alpha1
22
kind: CircuitBreaker
33
metadata:
44
name: breaker-demo
5-
namespace: default
5+
namespace: kusionstack-system
66
spec:
77
rateLimitings:
88
- bucket:
9-
burst: 500
10-
interval: 1s
11-
limit: 20
9+
burst: 1
10+
interval: 10s
11+
limit: 1
1212
name: deletePod
1313
recoverPolicy:
1414
sleepingWindowSize: 10m

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/KusionStack/controller-mesh
33
go 1.20
44

55
require (
6-
connectrpc.com/connect v1.11.1
6+
connectrpc.com/connect v1.13.0
77
github.com/go-logr/zapr v1.2.3
88
github.com/onsi/ginkgo v1.16.5
99
github.com/onsi/gomega v1.24.1

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
3333
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
3434
connectrpc.com/connect v1.11.1 h1:dqRwblixqkVh+OFBOOL1yIf1jS/yP0MSJLijRj29bFg=
3535
connectrpc.com/connect v1.11.1/go.mod h1:3AGaO6RRGMx5IKFfqbe3hvK1NqLosFNP2BxDYTPmNPo=
36+
connectrpc.com/connect v1.13.0 h1:lGs5maZZzWOOD+PFFiOt5OncKmMsk9ZdPwpy5jcmaYg=
37+
connectrpc.com/connect v1.13.0/go.mod h1:uHAFHtYgeSZJxXrkN1IunDpKghnTXhYbVh0wW4StPW0=
3638
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
3739
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
3840
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

0 commit comments

Comments
 (0)