Configuring the ingress gateway

    You’ll need to create the gateway service and deployment instance to handle traffic first. Let’s say you customized the default istio-ingressgateway to custom-ingressgateway as follows.

    Update gateway instance knative-ingress-gateway under knative-serving namespace:

    1. kubectl edit gateway knative-ingress-gateway -n knative-serving

    Replace the label selector with the label of your service:

    1. istio: ingressgateway

    For the example custom-ingressgateway service mentioned earlier, it should be updated to:

    1. istio: custom-gateway

    If there is a change in service ports (compared with that of istio-ingressgateway), update the port info in the gateway accordingly.

    1. This command opens your default text editor and allows you to edit the config-istio ConfigMap.

      1. apiVersion: v1
      2. data:
      3. _example: |
      4. ################################
      5. # #
      6. # EXAMPLE CONFIGURATION #
      7. # #
      8. ################################
      9. # ...
    2. Edit the file to add the gateway.knative-serving.knative-ingress-gateway: <ingress_name>.<ingress_namespace>.svc.cluster.local field with the fully qualified url of your service. For the example custom-ingressgateway service mentioned earlier, it should be updated to:

      1. apiVersion: v1
      2. data:
      3. gateway.knative-serving.knative-ingress-gateway: custom-ingressgateway.custom-ns.svc.cluster.local
      4. kind: ConfigMap
      5. [...]

    Replace the knative-ingress-gateway gateway

    We customized the gateway service so far, but we may also want to use our own gateway. We can replace the default gateway with our own gateway with following steps.

    Let’s say you replace the default knative-ingress-gateway gateway with knative-custom-gateway in custom-ns. First, create the knative-custom-gateway gateway:

    1. Create a YAML file using the following template:

      1. apiVersion: networking.istio.io/v1alpha3
      2. kind: Gateway
      3. metadata:
      4. name: knative-custom-gateway
      5. namespace: custom-ns
      6. spec:
      7. selector:
      8. istio: <service-label>
      9. servers:
      10. - port:
      11. number: 80
      12. name: http
      13. protocol: HTTP
    2. Apply the YAML file by running the command:

      Where <filename> is the name of the file you created in the previous step.

    1. Update gateway configmap config-istio under knative-serving namespace:

      1. kubectl edit configmap config-istio -n knative-serving

      This command opens your default text editor and allows you to edit the config-istio ConfigMap.

      1. apiVersion: v1
      2. data:
      3. _example: |
      4. ################################
      5. # #
      6. # EXAMPLE CONFIGURATION #
      7. # #
      8. ################################
      9. # ...
      10. gateway.knative-serving.knative-ingress-gateway: "istio-ingressgateway.istio-system.svc.cluster.local"
    2. Edit the file to add the gateway.<gateway-namespace>.<gateway-name>: istio-ingressgateway.istio-system.svc.cluster.local field with the customized gateway. For the example knative-custom-gateway mentioned earlier, it should be updated to:

      1. apiVersion: v1
      2. data:
      3. gateway.custom-ns.knative-custom-gateway: "istio-ingressgateway.istio-system.svc.cluster.local"
      4. kind: ConfigMap
      5. [...]