0

I have setup Istio's "ingress gateway" to listen on 8080, and have issues with running the Knative hello-world. Has anyone setup Knative like this?

I would like internet traffic coming in to port 8080 to show the output of the Knative hello world.

Randy L
  • 14,384
  • 14
  • 44
  • 73
  • 1
    Are you asking about the user container, or about the common HTTP ingress for the Knative cluster? – E. Anderson May 19 '20 at 14:41
  • The ingress gateway's port is unrelated to the port that the user containers run on -- Envoy (used by Istio) will happily use a backend on a different port if directed to do so. – E. Anderson May 20 '20 at 03:17

2 Answers2

1

If you have an existing container which listens on port 80 instead of $PORT, you can set spec.template.spec.containers[0].ports[0].containerPort to indicate which port the container listens on.

For example:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
 name: helloworld-go
 namespace: default
spec:
 template:
  spec:
   containers:
    - image: gcr.io/knative-samples/helloworld-go
      env:
      - name: TARGET
       value: "Go Sample v1"
      ports:
      - containerPort: 80

Knative will automatically set the $PORT environment variable to the requested container port, so setting containerPort should work with any of the Knative samples.

E. Anderson
  • 3,405
  • 1
  • 16
  • 19
  • I did experiment a bit trying to set `PORT` in Yaml, the knative api rejected, I think that's expected behavior. – Randy L May 19 '20 at 17:24
  • You need to set the `containerPort`, and Knative will automatically set the environment variable. – E. Anderson May 20 '20 at 03:15
1

If I understand the question this is similar to an issue I've run into trying to configure Knative with the Istio ingress gateway on non-standard ports. Following the Knative instructions for Istio integration I applied the Knative Istio controller (net-istio). This includes a networking.istio.io Gateway that selects istio: ingressgateway that specifies port 80. Modifying this resource to the correct port (8080 in the question) should fix the issue.