Skip to content

Commit

Permalink
Graceful shutdown (#80) (#3)
Browse files Browse the repository at this point in the history
* Change readiness probe and define preStop lifecycle hook

* Use the admin endpoint as the readiness probe

* Increase the amount of retries for the make local-setup scripts

* Reduce the amount of readyness checks

Co-authored-by: Joaquim Moreno Prusi <[email protected]>
  • Loading branch information
nak3 and jmprusi authored Jun 18, 2020
1 parent 1bb7d19 commit 3d1fb5a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
12 changes: 8 additions & 4 deletions deploy/kourier-knative.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ spec:
- /tmp/config/envoy-bootstrap.yaml
command:
- /usr/local/bin/envoy
image: docker.io/maistra/proxyv2-ubi8:1.0.8
image: docker.io/maistra/proxyv2-ubi8:1.1.0
imagePullPolicy: Always
name: kourier-gateway
ports:
Expand All @@ -116,16 +116,20 @@ spec:
volumeMounts:
- name: config-volume
mountPath: /tmp/config
lifecycle:
preStop:
exec:
command: ["curl","-X","POST","--unix","/tmp/envoy.admin","http://localhost/healthcheck/fail"]
readinessProbe:
httpGet:
httpHeaders:
- name: Host
value: internalkourier
path: /__internalkouriersnapshot
path: /ready
port: 8081
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 2
initialDelaySeconds: 10
periodSeconds: 5
volumes:
- name: config-volume
configMap:
Expand Down
16 changes: 10 additions & 6 deletions pkg/generator/status_vhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package generator

import (
"time"

"knative.dev/net-kourier/pkg/config"
"knative.dev/net-kourier/pkg/envoy"

Expand All @@ -29,13 +31,15 @@ func statusVHost() route.VirtualHost {
return envoy.NewVirtualHost(
config.InternalKourierDomain,
[]string{config.InternalKourierDomain},
[]*route.Route{statusRoute()},
[]*route.Route{readyRoute()},
)
}

func statusRoute() *route.Route {
return envoy.NewRouteStatusOK(
config.InternalKourierDomain,
config.InternalKourierPath,
)
func readyRoute() *route.Route {
cluster := envoy.NewWeightedCluster("service_stats", 100, map[string]string{})
var wrs []*route.WeightedCluster_ClusterWeight
wrs = append(wrs, cluster)
route := envoy.NewRoute("gateway_ready", "/ready", wrs, 1*time.Second, 0, 5*time.Second, map[string]string{})

return route
}
2 changes: 1 addition & 1 deletion utils/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ retries=0
while [[ $(kubectl get pods -n ${KOURIER_NAMESPACE} -l app=3scale-kourier-gateway -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do
echo "Waiting for kourier gateway pod to be ready "
sleep 10
if [ $retries -ge 7 ]; then
if [ $retries -ge 10 ]; then
echo "timedout waiting for kourier gateway pod"
exit 1
fi
Expand Down

0 comments on commit 3d1fb5a

Please sign in to comment.