Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow user-defined ports on Configuration #2642
Allow user-defined ports on Configuration #2642
Changes from all commits
62193cd
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this second ContainerPort is empty? I think it's still an error to have:
Ports: []corev1.ContainerPort{{}, {}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have improved validation and cleaned up the tests including a test to cover empty ports in the array.
I currently have it as an error, but I could also be convinced that a ContainerPorts object with a missing ContainerPort value results in the default 8080.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a ContainerPorts object with a single missing value results in the default, but two empty ContainerPorts elements suggests selecting two ports, which should still be an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test that it's fine to omit
ContainerPort
altogether?We should also raise an error if
HostIP
,HostPort
orProtocol
is set. (Protocol
could be allowed to be TCP.) Feel free to open a separate issue for that fix.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I was already making changes I added errors for those fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to remove any previous env var entries for PORT here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And/or prefer the
PORT
env var if the containerPort was not already set?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This currently mimics existing behavior, and I think I am okay with the behavior. Both a user specified PORT and the auto-populated port will be available from the API server when querying the pod or deployment, but the PORT we set should take effect inside the container due to environment variable ordering.
I can't think of a case where you want the environment variable in the container to not be the port where the queue-proxy is sending traffic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question was what happens if I have the following in my spec:
I'm worried that the Deployment pod will look like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the above example you cannot have a name without a containerPort which should prevent some confusion. However, the bottom part of the example is still possible to have duplicate ports if the user specified an environment variable named PORT.
Whatever we do I would like to have consistent behavior with all environment variables set by Knative ( https://github.com/knative/serving/blob/master/docs/runtime-contract.md#process ).
Lets chat about the behavior we want, and I will open up a new issue to change if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a TODO to extract EXPOSE information from the container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added