Skip to content
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

Add exposed ports from images without exposed port #1467

Merged

Conversation

jLopezbarb
Copy link
Contributor

Signed-off-by: Javier López Barba javier@okteto.com

Fixes: When you upload a docker-compose with a service without exposed ports, none of the ports are available in the cluster

Proposed changes

  • Check docker registry to get the default exposed ports that an image must have

Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
@codecov
Copy link

codecov bot commented Apr 30, 2021

Codecov Report

Merging #1467 (ad49d65) into master (ba87504) will decrease coverage by 0.24%.
The diff coverage is 5.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1467      +/-   ##
==========================================
- Coverage   36.52%   36.28%   -0.25%     
==========================================
  Files          80       80              
  Lines        7605     7661      +56     
==========================================
+ Hits         2778     2780       +2     
- Misses       4477     4531      +54     
  Partials      350      350              
Impacted Files Coverage Δ
cmd/up/activate.go 0.00% <0.00%> (ø)
pkg/cmd/stack/deploy.go 0.00% <0.00%> (ø)
pkg/cmd/stack/translate.go 74.66% <0.00%> (ø)
pkg/model/stack.go 44.80% <0.00%> (ø)
pkg/registry/registry.go 10.40% <3.92%> (-4.47%) ⬇️
pkg/registry/image.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba87504...ad49d65. Read the comment docs.


func GetHiddenExposePorts(image string) []int32 {
exposedPorts := make([]int32, 0)
c, err := NewRegistryClient("https://registry.hub.docker.com", "", "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the image is not in docker hub? (e.g. in our own)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now it will only inspect docker hub public images. I think this will cover most of the compose files. When using their own image the user usually set the ports in the expose field. This port injection is costly, so it is good to perform it as few times as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work with images with these formats?

  • docker.io/bitnami/mongodb
  • mongodb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New commits adds support for public images from other repositories. It also adds support for private images on our own registry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work with both formats. It will have issues when the image is a official one and adds the registry. For example, docker.io/mongo.

Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
@jLopezbarb jLopezbarb merged commit eceea36 into master May 5, 2021
@jLopezbarb jLopezbarb deleted the jlopezbarb/get-exposed-ports-from-images-without-port branch May 5, 2021 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants