|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/about-contour-operator.adoc |
| 4 | + |
| 5 | +[id="nw-install-config-gateway-api_{context}"] |
| 6 | += Installing and configuring Contour for Gateway API |
| 7 | + |
| 8 | +[IMPORTANT] |
| 9 | +==== |
| 10 | +The following features are in Developer Preview and not currently supported or intended for production use. They are highlighted here to notify users of the important upcoming addition of Gateway API. Limited documentation is available at this time. |
| 11 | +==== |
| 12 | + |
| 13 | +The following guide provides instructions for using link:https://gateway-api.sigs.k8s.io/[the Gateway API] with the Contour Operator on {product-title}. |
| 14 | + |
| 15 | +.Prerequisites |
| 16 | + |
| 17 | +* You installed an {product-title} cluster and the `oc` command line. |
| 18 | +* You installed the Contour Operator. |
| 19 | +//* Log in as a user with cluster-admin permission. |
| 20 | + |
| 21 | +.Procedure |
| 22 | + |
| 23 | +. Install Contour configured for Gateway API and dependent resources: |
| 24 | ++ |
| 25 | +[source,terminal] |
| 26 | +---- |
| 27 | +$ oc apply -f https://raw.githubusercontent.com/projectcontour/contour-operator/v1.16.0/examples/gateway/gateway.yaml |
| 28 | +---- |
| 29 | ++ |
| 30 | +[NOTE] |
| 31 | +==== |
| 32 | +Envoy pods are exposed using a LoadBalancer service. Replace `gateway.yaml` with `gateway-nodeport.yaml` to use a NodePort service instead. |
| 33 | +==== |
| 34 | ++ |
| 35 | +.Verification |
| 36 | ++ |
| 37 | +. Verify that all pods in the namespace where you installed Contour are running: |
| 38 | ++ |
| 39 | +[source,terminal] |
| 40 | +---- |
| 41 | +$ oc get pods -n projectcontour |
| 42 | +---- |
| 43 | ++ |
| 44 | +.Example output |
| 45 | ++ |
| 46 | +[source,terminal] |
| 47 | +---- |
| 48 | +NAME READY STATUS RESTARTS AGE |
| 49 | +contour-768547cfb8-c2rhn 1/1 Running 0 2m |
| 50 | +contour-768547cfb8-q866f 1/1 Running 0 2m |
| 51 | +contour-certgen-main-rb2h2 0/1 Completed 0 92s |
| 52 | +envoy-d5djm 2/2 Running 0 2m41s |
| 53 | +envoy-gjwz5 2/2 Running 0 2m41s |
| 54 | +envoy-hbg6j 2/2 Running 0 2m41s |
| 55 | +---- |
| 56 | ++ |
| 57 | +The number of Envoy pods depends on how many worker nodes are in your cluster. |
| 58 | ++ |
| 59 | +. Run a test workload: |
| 60 | ++ |
| 61 | +[source,terminal] |
| 62 | +---- |
| 63 | +$ oc apply -f https://raw.githubusercontent.com/projectcontour/contour-operator/v1.16.0/examples/gateway/kuard/kuard.yaml |
| 64 | +---- |
| 65 | ++ |
| 66 | +.Verification |
| 67 | ++ |
| 68 | +. Verify the status of the test workload: |
| 69 | ++ |
| 70 | +[source,terminal] |
| 71 | +---- |
| 72 | +$ oc get pods,svc,httproute -n projectcontour -l app=kuard |
| 73 | +---- |
| 74 | ++ |
| 75 | +.Example output |
| 76 | ++ |
| 77 | +[source,terminal] |
| 78 | +---- |
| 79 | +NAME READY STATUS RESTARTS AGE |
| 80 | +pod/kuard-798585497b-9mvwh 1/1 Running 0 5s |
| 81 | +pod/kuard-798585497b-kcjnn 1/1 Running 0 5s |
| 82 | +pod/kuard-798585497b-lnhsn 1/1 Running 0 5s |
| 83 | +
|
| 84 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 85 | +service/kuard ClusterIP 10.96.157.48 <none> 80/TCP 5s |
| 86 | +
|
| 87 | +NAME HOSTNAMES |
| 88 | +httproute.networking.x-k8s.io/kuard ["local.projectcontour.io"] |
| 89 | +---- |
| 90 | ++ |
| 91 | +The application is exposed using an `HTTPRoute` that routes all HTTP requests for `local.projectcontour.io` to service kuard. |
| 92 | ++ |
| 93 | +. Curl the application hostname: |
| 94 | ++ |
| 95 | +[source,terminal] |
| 96 | +---- |
| 97 | +$ export GATEWAY=$(oc -n projectcontour get svc/envoy -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') |
| 98 | +---- |
| 99 | ++ |
| 100 | +[NOTE] |
| 101 | +==== |
| 102 | +Replace `hostname` in the json path with `ip` if your cloud provider uses IP addresses instead of hostnames for loadBalancer services. |
| 103 | +==== |
| 104 | ++ |
| 105 | +[source,terminal] |
| 106 | +---- |
| 107 | +$ curl -H "Host: local.projectcontour.io" -s -o /dev/null -w "%{http_code}" "http://$GATEWAY/" |
| 108 | +---- |
| 109 | ++ |
| 110 | +If running appropriately, a `200` HTTP status code is returned. |
| 111 | ++ |
| 112 | +.Verification |
| 113 | ++ |
| 114 | +. Verify that the curl request was serviced by Envoy: |
| 115 | ++ |
| 116 | +[source,terminal] |
| 117 | +---- |
| 118 | +$ oc logs ds/envoy -c envoy -n projectcontour | grep curl |
| 119 | +---- |
| 120 | ++ |
| 121 | +.Example output |
| 122 | ++ |
| 123 | +[source,terminal] |
| 124 | +---- |
| 125 | +Found 3 pods, using pod/envoy-g86st |
| 126 | +[2021-02-03T17:17:24.009Z] "GET / HTTP/1.1" 200 - 0 1748 1 1 "10.0.79.141" "curl/7.64.1" "2c53c9ba-46a2-4527-8b41-03ea9041bd2d" "a811b15855e1f428d8a834d0a86c3668-573506534.us-east-2.elb.amazonaws.com" "10.129.2.13:8080" |
| 127 | +---- |
| 128 | ++ |
| 129 | +[NOTE] |
| 130 | +==== |
| 131 | +The example above defaulted to pod `envoy-g86st` since the daemonset has three running pods. Use a different Envoy pod if the curl request does not appear in the logs. |
| 132 | +==== |
0 commit comments