knativeknative-serving

KNative with Istio Listening on Port 8080


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.


Solution

  • 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.