-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathweb-shop-deployment.yaml
152 lines (152 loc) · 3.87 KB
/
web-shop-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
kind: Service
apiVersion: v1
metadata:
name: web-shop
spec:
ports:
- name: http
port: 8090
targetPort: 8090
selector:
app: web-shop
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-shop-v1
spec:
replicas: 2
selector:
matchLabels:
app: web-shop
version: v1
template:
metadata:
labels:
app: web-shop
version: v1
spec:
containers:
- name: web-shop
image: mydemo/shopweb
imagePullPolicy: IfNotPresent
env:
- name: NACOS_HOST
value: "pub-nacos.default.svc.cluster.local"
- name: ZIPKIN_HOST
value: "pub-zipkin.default.svc.cluster.local"
- name: SHOP_VERSION
value: "v1"
ports:
- containerPort: 8090
readinessProbe: # Check whether web-shop is ready
exec:
command: ["sh", "-c", "COUNT=`netstat -antp tcp|grep 8090|grep LISTEN -c`; if [ $COUNT -eq 1 ]; then exit 0; else exit 1; fi"]
initialDelaySeconds: 3 # Wait initialDelaySeconds to check the first time
periodSeconds: 5 # Wait periodSeconds to check next time
timeoutSeconds: 2 # Timeout for check process
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-shop-v2
spec:
replicas: 1
selector:
matchLabels:
app: web-shop
version: v2
template:
metadata:
labels:
app: web-shop
version: v2
spec:
containers:
- name: web-shop
image: mydemo/shopweb
imagePullPolicy: IfNotPresent
env:
- name: NACOS_HOST
value: "pub-nacos.default.svc.cluster.local"
- name: ZIPKIN_HOST
value: "pub-zipkin.default.svc.cluster.local"
- name: SHOP_VERSION
value: "v2"
ports:
- containerPort: 8090
readinessProbe: # Check whether web-shop is ready
exec:
command: ["sh", "-c", "COUNT=`netstat -antp tcp|grep 8090|grep LISTEN -c`; if [ $COUNT -eq 1 ]; then exit 0; else exit 1; fi"]
initialDelaySeconds: 3 # Wait initialDelaySeconds to check the first time
periodSeconds: 5 # Wait periodSeconds to check next time
timeoutSeconds: 2 # Timeout for check process
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: web-shop
spec:
host: web-shop.default.svc.cluster.local
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: web-shop-gateway
namespace: istio-system
spec:
selector:
# Require istio-ingressgateway installed
app: istio-ingressgateway
servers:
- port:
number: 80 # Port exposed by istio-ingressgateway
name: http
protocol: HTTP
hosts:
# Please bind myshop.com to Host IP in local hosts file,
# and visit http://myshop.com/hello/YourName.
- myshop.com
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: web-shop
spec:
hosts:
- web-shop.default.svc.cluster.local # Requests from other PODs in k8s cluster (Internal visits).
- myshop.com # Requests from ingressgateway (External visits).
gateways:
- mesh # Hidden gateway for routing internal visits
- web-shop-gateway.istio-system.svc.cluster.local # ingressgateway
http:
# If query param version=v2 exists, route to web-shop-v2
- match:
- queryParams:
version:
exact: v2
route:
- destination:
host: web-shop.default.svc.cluster.local
subset: v2
port:
number: 8090
# Route to web-shop-v1 by default
- route:
- destination:
host: web-shop.default.svc.cluster.local
subset: v1
port:
number: 8090
exportTo:
- "*"