Skip to content

Commit cd20b31

Browse files
committed
feat(istio): routerule all to v1
1 parent 16dcfa5 commit cd20b31

File tree

6 files changed

+26
-33
lines changed

6 files changed

+26
-33
lines changed

istio_examples/RouteRule/api/deployment.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
apiVersion: apps/v1beta1
1+
apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
44
name: api-v1
55
labels:
66
app: api
7-
version: v1
87
spec:
98
replicas: 1
109
template:
1110
metadata:
1211
labels:
1312
app: api
1413
version: v1
15-
name: api-v1
1614
spec:
1715
containers:
1816
- name: api
@@ -23,21 +21,19 @@ spec:
2321
- name: VERSION
2422
value: "v1"
2523
---
26-
apiVersion: apps/v1beta1
24+
apiVersion: extensions/v1beta1
2725
kind: Deployment
2826
metadata:
2927
name: api-v2
3028
labels:
3129
app: api
32-
version: v2
3330
spec:
3431
replicas: 1
3532
template:
3633
metadata:
3734
labels:
3835
app: api
3936
version: v2
40-
name: api-v2
4137
spec:
4238
containers:
4339
- name: api
Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
# every request with Version: v2 header to api service will be sent to "v2" instance
2-
# all remaning will be sent to "v1"
3-
apiVersion: config.istio.io/v1alpha2
4-
kind: RouteRule
5-
metadata:
6-
name: api-v2
7-
labels:
8-
app: api
9-
spec:
10-
destination:
11-
name: api
12-
precedence: 2
13-
match:
14-
request:
15-
headers:
16-
version: v2
17-
route:
18-
- labels:
19-
version: v2
20-
---
211
apiVersion: config.istio.io/v1alpha2
222
kind: RouteRule
233
metadata:
@@ -32,3 +12,21 @@ spec:
3212
- labels:
3313
version: v1
3414
weight: 100
15+
# ---
16+
# apiVersion: config.istio.io/v1alpha2
17+
# kind: RouteRule
18+
# metadata:
19+
# name: api-v2
20+
# labels:
21+
# app: api
22+
# spec:
23+
# destination:
24+
# name: api
25+
# precedence: 2
26+
# match:
27+
# request:
28+
# headers:
29+
# version: v2
30+
# route:
31+
# - labels:
32+
# version: v2

istio_examples/RouteRule/api/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/RouteRule/deploy.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ SERVICE_NAMES=("ui" "api")
77
for SERVICE_NAME in "${SERVICE_NAMES[@]}"; do
88
cd $DIR/$SERVICE_NAME/src && npm i && npm run dockerize
99
kubectl delete service,deployment -l app=$SERVICE_NAME
10-
kubectl create -f ../deployment.yml
11-
kubectl create -f ../service.yml
10+
kubectl apply -f <(istioctl kube-inject -f ../deployment.yml)
11+
kubectl apply -f <(istioctl kube-inject -f ../service.yml)
1212
done
1313

1414
API_URL=$(minikube service api --url)
1515
kubectl patch deployment ui --patch '{"spec": {"template": {"spec": {"containers": [{"name": "ui", "env":[{"name": "REACT_APP_API_URL", "value": "'$API_URL'"}]}]}}}}'
1616

1717
kubectl delete routerule -l app=api
18-
kubectl create -f $DIR/api/routerule.yml
18+
kubectl apply -f <(istioctl kube-inject -f $DIR/api/routerule.yml)

istio_examples/RouteRule/ui/deployment.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
apiVersion: apps/v1beta2 # for versions after 1.9.0 use apps/v1
1+
apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
44
name: ui
55
labels:
66
app: ui
77
spec:
88
replicas: 1
9-
selector:
10-
matchLabels:
11-
app: ui
129
template:
1310
metadata:
1411
labels:

istio_examples/RouteRule/ui/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: 3000
14+
name: http

0 commit comments

Comments
 (0)