-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsteps.sh
executable file
·160 lines (138 loc) · 3.34 KB
/
steps.sh
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
#!/usr/bin/env bash
cdiff() {
diff -U 9999 "$1" "$2" | ./diffc
}
#@SHOW
#@clear
# RETRIES
#
# Let's tell Emissary to add a retry when we call the
# face service.
#@echo
#@noshow
cdiff k8s/{01-base,02-retries}/face-mapping.yaml
#@wait
#@echo
kubectl apply -f k8s/02-retries/face-mapping.yaml
#@wait
#@clear
# RETRIES
#
# Great -- how about using Emissary to add a retry when
# we call the smiley service, to get rid of the cursing
# faces?
#@echo
#@noshow
cdiff k8s/{01-base,02-retries}/smiley-mapping.yaml
#@wait
#@echo
kubectl apply -f k8s/02-retries/smiley-mapping.yaml
#@wait
#@clear
# RETRIES
#
# That didn't work because Emissary doesn't ever see the
# call from the face service to the smiley service.
# Instead, we'll ask Linkerd to do the retries.
#@echo
#@noshow
cdiff k8s/{01-base,02-retries}/smiley-profile.yaml
#@wait
#@echo
kubectl apply -f k8s/02-retries/smiley-profile.yaml
#@wait
#@clear
# RETRIES
#
# We'll ask Linkerd to do retries for the color service,
# too, to get rid of the grey backgrounds.
#@echo
#@noshow
cdiff k8s/{01-base,02-retries}/color-profile.yaml
#@wait
#@echo
kubectl apply -f k8s/02-retries/color-profile.yaml
#@wait
#@clear
# TIMEOUTS
#
# Things are better, but still too slow. Let's add
# timeouts, starting from the bottom of the call graph
# this time.
#
# You'll see pink backgrounds here: timeouts aren't about
# protecting the service, they're about providing agency
# to the client. Here, the face service chooses to show
# timeouts as a pink background.
#@echo
#@noshow
cdiff k8s/{02-retries,03-timeouts}/color-profile.yaml
#@wait
#@echo
kubectl apply -f k8s/03-timeouts/color-profile.yaml
#@wait
#@clear
# TIMEOUTS
#
# Let's continue with the faces service. The faces
# service shows a timeout as a sleeping face.
#@echo
#@noshow
cdiff k8s/{02-retries,03-timeouts}/smiley-profile.yaml
#@wait
#@echo
kubectl apply -f k8s/03-timeouts/smiley-profile.yaml
#@wait
#@clear
# TIMEOUTS
#
# Finally, we'll add a timeout when Emissary calls the
# faces service.
#
# Here, the client is the web app. The web app is OK
# showing the user older data rather than showing them a
# failure, but for the moment it will also put a counter
# in the corner so that we can see when it's doing so for
# demo purposes.
#@echo
#@noshow
cdiff k8s/{02-retries,03-timeouts}/face-mapping.yaml
#@wait
#@echo
kubectl apply -f k8s/03-timeouts/face-mapping.yaml
#@wait
#@clear
# RATELIMITS
#
# Suppose someone adds some code to the faces service
# that makes it collapse under too much load, rather than
# just getting slower?
#
# As it happens, our faces service has exactly that code,
# which we'll enable now.
kubectl set env deploy -n faces face MAX_RATE=8.5
#@wait
#@clear
# RATELIMITS
#
# We can tell Emissary to enforce a rate limit for
# requests to the faces service. This is both protecting
# the service and providing agency to the client: here,
# our web app is going to handle rate limits just like it
# handles timeouts.
#@echo
#@noshow
cdiff k8s/{03-timeouts,04-ratelimits}/face-mapping.yaml
#@wait
#@echo
kubectl apply -f k8s/04-ratelimits/face-mapping.yaml
#@wait
#@clear
# SUMMARY
#
# We've used both Emissary and Linkerd to take a very,
# very broken application and turn it into something the
# user might actually have an OK experience with. Fixing
# the application is, of course, still necessary!! but
# making the user experience better is a good thing.
#@wait