Skip to content

Commit f6789fe

Browse files
committed
feat(istio): fault injection example
1 parent 918ce3b commit f6789fe

File tree

7 files changed

+38
-8
lines changed

7 files changed

+38
-8
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
DIR=$(pwd)
4+
5+
kubectl delete routerule -l app=github
6+
kubectl apply -f <(istioctl kube-inject -f $DIR/faultinjection.yml)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: config.istio.io/v1alpha2
2+
kind: RouteRule
3+
metadata:
4+
name: github-abort
5+
labels:
6+
app: github
7+
spec:
8+
destination:
9+
name: github
10+
route:
11+
- labels:
12+
app: github
13+
httpFault:
14+
abort:
15+
percent: 100
16+
httpStatus: 400
17+
precedence: 1

istio_examples/RouteRule/deploy.sh

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#!/bin/bash
2+
13
DIR=$(pwd)
24

35
kubectl delete routerule -l app=api
4-
kubectl apply -f <(istioctl kube-inject -f $DIR/api/routerule.yml)
5-
kubectl apply -f <(istioctl kube-inject -f $DIR/api/routerule2.yml)
6+
kubectl apply -f <(istioctl kube-inject -f $DIR/routerule.yml)
7+
kubectl apply -f <(istioctl kube-inject -f $DIR/routerule2.yml)

istio_examples/Services/api/service.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ spec:
1111
ports:
1212
- protocol: TCP
1313
port: 5000
14-
name: http
14+
name: http

istio_examples/Services/github/service.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ spec:
1111
ports:
1212
- protocol: TCP
1313
port: 5000
14+
name: http

istio_examples/Services/ui/service.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ spec:
1111
ports:
1212
- protocol: TCP
1313
port: 80
14-
name: http
14+
name: http

istio_examples/Services/ui/src/src/App.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ class App extends Component {
1919
headers
2020
})
2121
.then((response) => {
22-
response.json().then(json => {
23-
console.log(json)
24-
this.setState({error: false, data: json})
25-
})
22+
if (response.ok) {
23+
response.json().then(json => {
24+
console.log(json)
25+
this.setState({error: false, data: json})
26+
})
27+
} else {
28+
throw new Error('Network response was not ok.')
29+
}
2630
})
2731
.catch((err) => this.setState({error: true, data: err.toString()}))
2832
}

0 commit comments

Comments
 (0)