forked from nicholasjackson/demo-consul-service-mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraffic_routing.yml
194 lines (180 loc) · 3.99 KB
/
traffic_routing.yml
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
---
# Central config stored as config map
apiVersion: v1
kind: ConfigMap
metadata:
name: central-config-routing
data:
1_web_defaults.hcl: |
kind = "service-defaults"
name = "web"
protocol = "http"
2_api_defaults.hcl: |
kind = "service-defaults"
name = "api"
protocol = "http"
3_api_resolver.hcl: |
kind = "service-resolver"
name = "api"
# https://www.consul.io/api/health.html#filtering-2
# # Show Node.Meta demonstration showing performance testing a new instance type
default_subset = "v1"
subsets = {
v1 = {
filter = "Service.Meta.version == 1"
}
v2 = {
filter = "Service.Meta.version == 2"
}
}
---
# Job to load central config
apiVersion: batch/v1
kind: Job
metadata:
name: central-config-routing
labels:
app: central-config-routing
spec:
template:
spec:
restartPolicy: Never
volumes:
- name: central-config
configMap:
name: central-config-routing
containers:
- name: central-config-split
image: "nicholasjackson/consul-envoy:v1.6.1-v0.10.0"
imagePullPolicy: Always
env:
- name: "CONSUL_HTTP_ADDR"
value: "consul-consul-server:8500"
- name: "CONSUL_GRPC_ADDR"
value: "consul-consul-server:8502"
- name: "CENTRAL_CONFIG_DIR"
value: "/config"
volumeMounts:
- name: "central-config"
readOnly: true
mountPath: "/config"
---
# Service to expose web frontend
apiVersion: v1
kind: Service
metadata:
name: web-service
spec:
selector:
app: web
ports:
- name: http
protocol: TCP
port: 9090
targetPort: 9090
---
# Web frontend
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-deployment
labels:
app: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
annotations:
"consul.hashicorp.com/connect-inject": "true"
"consul.hashicorp.com/connect-service-upstreams": "api:9091"
spec:
containers:
- name: web
image: nicholasjackson/fake-service:v0.7.3
ports:
- containerPort: 9090
env:
- name: "LISTEN_ADDR"
value: "0.0.0.0:9090"
- name: "UPSTREAM_URIS"
value: "http://localhost:9091"
- name: "NAME"
value: "web"
- name: "MESSAGE"
value: "Hello World"
- name: "HTTP_CLIENT_KEEP_ALIVES"
value: "false"
---
# API service version 2
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment-v1
labels:
app: api-v1
spec:
replicas: 1
selector:
matchLabels:
app: api-v1
template:
metadata:
labels:
app: api-v1
annotations:
"consul.hashicorp.com/connect-inject": "true"
"consul.hashicorp.com/service-meta-version": "1"
"consul.hashicorp.com/service-tags": "v1"
spec:
containers:
- name: api
image: nicholasjackson/fake-service:v0.7.3
ports:
- containerPort: 9090
env:
- name: "LISTEN_ADDR"
value: "0.0.0.0:9090"
- name: "NAME"
value: "api-v1"
- name: "MESSAGE"
value: "Response from API v1"
---
# API service version 2
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment-v2
labels:
app: api-v2
spec:
replicas: 1
selector:
matchLabels:
app: api-v2
template:
metadata:
labels:
app: api-v2
annotations:
"consul.hashicorp.com/connect-inject": "true"
"consul.hashicorp.com/service-meta-version": "2"
"consul.hashicorp.com/service-tags": "v2"
spec:
containers:
- name: api
image: nicholasjackson/fake-service:v0.7.3
ports:
- containerPort: 9090
env:
- name: "LISTEN_ADDR"
value: "0.0.0.0:9090"
- name: "NAME"
value: "api-v2"
- name: "MESSAGE"
value: "Response from API v2"
---