Customizing port number
If you have existing apps that doesn't respect the
PORT environment variable
assigned by Knative, you can specify the port number your app listens on:
For example, the
nginx container image from Docker Hub always listens on port
80 and you can't change it easily:
apiVersion: serving.knative.dev/v1alpha1 kind: Service metadata: name: hello spec: template: spec: containers: - image: nginx ports: - containerPort: 80
With this, inside the container,
PORT environment variable will be set to
80 and the traffic will go there.
Note: Specifying more than 1
containerPortis not allowed.
Setting a custom port doesn't change the Knative Service's endpoint port number.
Knative, by default, will
make the created Service available to callers on port
80, regardless of the