Skip to content

Commit c5d5962

Browse files
committed
fix docs and e2e install script
Signed-off-by: Sanskar Jaiswal <[email protected]>
1 parent 81b064c commit c5d5962

3 files changed

Lines changed: 44 additions & 15 deletions

File tree

docs/gitbook/tutorials/gatewayapi-progressive-delivery.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ This guide shows you how to use Gateway API and Flagger to automate canary deplo
88

99
Flagger requires a Kubernetes cluster **v1.16** or newer and any mesh/ingress that implements the `v1alpha2` of Gateway API. We'll be using Contour for the sake of this tutorial, but you can use any other implementation.
1010

11-
Install Contour with GatewayAPI and create a GatewayClass and a Gateway object:
11+
Install the GatewayAPI CRDs:
1212

1313
```bash
14-
kubectl apply -f https://raw.githubusercontent.com/projectcontour/contour/release-1.20/examples/render/contour-gateway.yaml
14+
kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.4.1" \
15+
| kubectl apply -f -
16+
```
17+
18+
Install a cluster-wide GatewayClass; a Gateway belonging to the GatewayClass and Contour components in the `projectcontour` namespace:
19+
20+
```bash
21+
kubectl apply -f https://raw.githubusercontent.com/projectcontour/contour/release-1.20/examples/render/contour.yaml
1522
```
1623

1724
Install Flagger in the `flagger-system` namespace:
@@ -42,7 +49,7 @@ Deploy the load testing service to generate traffic during the canary analysis:
4249
kubectl apply -k https://github.com/fluxcd/flagger//kustomize/tester?ref=main
4350
```
4451

45-
Create metric templates targeting the Prometheus server in the `flagger-system` namespace. The PromQL query below is meant for `Envoy`, but you can [change it to your ingress/mesh provider](https://docs.flagger.app/faq#metrics) accordingly.
52+
Create metric templates targeting the Prometheus server in the `flagger-system` namespace. The PromQL queries below are meant for `Envoy`, but you can [change it to your ingress/mesh provider](https://docs.flagger.app/faq#metrics) accordingly.
4653

4754
```yaml
4855
apiVersion: flagger.app/v1beta1
@@ -68,14 +75,14 @@ spec:
6875
apiVersion: flagger.app/v1beta1
6976
kind: MetricTemplate
7077
metadata:
71-
name: request-success-rate
78+
name: error-rate
7279
namespace: flagger-system
7380
spec:
7481
provider:
7582
type: prometheus
7683
address: http://flagger-prometheus:9090
7784
query: |
78-
sum(
85+
100 - sum(
7986
rate(
8087
envoy_cluster_upstream_rq{
8188
envoy_cluster_name=~"{{ namespace }}_{{ target }}-canary_[0-9a-zA-Z-]+",
@@ -100,7 +107,7 @@ Save the above resource as metric-templates.yaml and then apply it:
100107
kubectl apply -f metric-templates.yaml
101108
```
102109

103-
Create a canary custom resource \(replace example.com with your own domain\):
110+
Create a canary custom resource \(replace "loaclproject.contour.io" with your own domain\):
104111

105112
```yaml
106113
apiVersion: flagger.app/v1beta1
@@ -150,10 +157,10 @@ spec:
150157
# minimum req success rate (non 5xx responses)
151158
# percentage (0-100)
152159
templateRef:
153-
name: request-success-rate
160+
name: error-rate
154161
namespace: flagger-system
155162
thresholdRange:
156-
min: 99
163+
max: 1
157164
interval: 1m
158165
- name: latency
159166
templateRef:
@@ -199,6 +206,29 @@ service/podinfo-primary
199206
httproutes.gateway.networking.k8s.io/podinfo
200207
```
201208

209+
## Expose the app outside the cluster
210+
211+
Find the external address of Contour's Envoy load balancer:
212+
213+
```bash
214+
export ADDRESS="$(kubectl -n projectcontour get svc/envoy -ojson \
215+
| jq -r ".status.loadBalancer.ingress[].hostname")"
216+
echo $ADDRESS
217+
```
218+
219+
Configure your DNS server with a CNAME record \(AWS\) or A record \(GKE/AKS/DOKS\) and point a domain e.g. `app.example.com` to the LB address.
220+
221+
Now you can access the podinfo UI using your domain address.
222+
223+
Note that you should be using HTTPS when exposing production workloads on internet. You can obtain free TLS certs from Let's Encrypt, read this [guide](https://github.com/stefanprodan/eks-contour-ingress) on how to configure cert-manager to secure Contour with TLS certificates.
224+
225+
If you're using a local cluster via kind/k3s you can port forward the Envoy LoadBalancer service:
226+
```bash
227+
kubectl port-forward -n projectcontour svc/envoy 8080:80
228+
```
229+
230+
Now you can access the podinfo UI on `localhost:8080`
231+
202232
## Automated canary promotion
203233

204234
Trigger a canary deployment by updating the container image:

test/gatewayapi/install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ fi
1414

1515
mkdir -p ${REPO_ROOT}/bin
1616

17-
echo ">>> Installing Contour ${CONTOUR_VER}, Gateway API components ${GATEWAY_API_VER}"
18-
# retry if it fails, creating a gateway object is flaky sometimes
19-
until cd ${REPO_ROOT}/bin && kubectl apply -f \
20-
https://raw.githubusercontent.com/projectcontour/contour/${CONTOUR_VER}/examples/render/contour-gateway.yaml; do
21-
sleep 1
22-
done
17+
echo ">>> Installing Gateway API CRDs"
18+
kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.4.1" \
19+
| kubectl apply -f -
20+
21+
echo ">>> Installing Contour components, GatewayClass and Gateway"
22+
kubectl apply -f https://raw.githubusercontent.com/projectcontour/contour/${CONTOUR_VER}/examples/render/contour-gateway.yaml
2323

2424
kubectl -n projectcontour rollout status deployment/contour
2525
kubectl -n projectcontour get all

test/gatewayapi/test-canary.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ spec:
7171
progressDeadlineSeconds: 60
7272
service:
7373
port: 9898
74-
targetPort: 9898
7574
portName: http
7675
hosts:
7776
- localproject.contour.io

0 commit comments

Comments
 (0)