|
| 1 | +// Module included in the following assemblies: |
| 2 | +// * serverless/networking/serverless-configuring-routes.adoc |
| 3 | + |
| 4 | +[id="serverless-openshift-routes_{context}"] |
| 5 | += Configuring {product-title} routes for Knative services |
| 6 | + |
| 7 | +If you want to configure a Knative service to use your TLS certificate on {product-title}, you must disable the automatic creation of a route for the service by the {ServerlessOperatorName}, and instead manually create a `Route` resource for the service. |
| 8 | + |
| 9 | +.Prerequisites |
| 10 | + |
| 11 | +* The {ServerlessOperatorName} and Knative Serving component must be installed on your {product-title} cluster. |
| 12 | + |
| 13 | +.Procedure |
| 14 | + |
| 15 | +. Create a Knative service that includes the `serving.knative.openshift.io/disableRoute=true` annotation: |
| 16 | ++ |
| 17 | +.Example YAML |
| 18 | +[source,yaml] |
| 19 | +---- |
| 20 | +apiVersion: serving.knative.dev/v1 |
| 21 | +kind: Service |
| 22 | +metadata: |
| 23 | + name: <service_name> |
| 24 | + annotations: |
| 25 | + serving.knative.openshift.io/disableRoute: true |
| 26 | +spec: |
| 27 | + template: |
| 28 | + spec: |
| 29 | + containers: |
| 30 | + - image: <image> |
| 31 | +---- |
| 32 | ++ |
| 33 | +.Example `kn` command |
| 34 | +[source,terminal] |
| 35 | +---- |
| 36 | +$ kn service create hello-example \ |
| 37 | + --image=gcr.io/knative-samples/helloworld-go \ |
| 38 | + --annotation serving.knative.openshift.io/disableRoute=true |
| 39 | +---- |
| 40 | + |
| 41 | +. Verify that no {product-title} route has been created for the service: |
| 42 | ++ |
| 43 | +.Example command |
| 44 | +[source,terminal] |
| 45 | +---- |
| 46 | +$ oc get routes.route.openshift.io -l serving.knative.openshift.io/ingressName=$KSERVICE_NAME -l serving.knative.openshift.io/ingressNamespace=$KSERVICE_NAMESPACE -n knative-serving-ingress |
| 47 | +---- |
| 48 | ++ |
| 49 | +You should see the following output: |
| 50 | ++ |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +No resources found in knative-serving-ingress namespace. |
| 54 | +---- |
| 55 | + |
| 56 | +. Create a `Route` object in the `knative-serving-ingress` namespace by copying the following sample YAML and modifying the replaceable values: |
| 57 | ++ |
| 58 | +[source,yaml] |
| 59 | +---- |
| 60 | +apiVersion: route.openshift.io/v1 |
| 61 | +kind: Route |
| 62 | +metadata: |
| 63 | + annotations: |
| 64 | + haproxy.router.openshift.io/timeout: 600s <1> |
| 65 | + name: <route_name> <2> |
| 66 | + namespace: knative-serving-ingress <3> |
| 67 | +spec: |
| 68 | + host: <service_host> <4> |
| 69 | + port: |
| 70 | + targetPort: http2 |
| 71 | + to: |
| 72 | + kind: Service |
| 73 | + name: kourier |
| 74 | + weight: 100 |
| 75 | + tls: |
| 76 | + insecureEdgeTerminationPolicy: Allow |
| 77 | + termination: edge <5> |
| 78 | + key: |- |
| 79 | + -----BEGIN PRIVATE KEY----- |
| 80 | + [...] |
| 81 | + -----END PRIVATE KEY----- |
| 82 | + certificate: |- |
| 83 | + -----BEGIN CERTIFICATE----- |
| 84 | + [...] |
| 85 | + -----END CERTIFICATE----- |
| 86 | + caCertificate: |- |
| 87 | + -----BEGIN CERTIFICATE----- |
| 88 | + [...] |
| 89 | + -----END CERTIFICATE---- |
| 90 | + wildcardPolicy: None |
| 91 | +---- |
| 92 | +<1> The timeout value for the {product-title} route. You must set the same value as the `max-revision-timeout-seconds` setting (`600s` by default). |
| 93 | +<2> The name of the {product-title} route. |
| 94 | +<3> The namespace for the {product-title} route. This must be `knative-serving-ingress`. |
| 95 | +<4> The hostname for external access. You can set this to `<service_name>-<service_namespace>.<domain>`. |
| 96 | +<5> The certificates you want to use. Currently, only `edge` termination is supported. |
0 commit comments