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

Fix docker stack services command Port output #943

Merged

Conversation

silvin-lubecki
Copy link
Contributor

- What I did
A previous fix on the Kubernetes Compose Controller created two services when ports are exposed, one headless (its type is ClusterIP) and another with the exposed port (its type is LoadBalancer). The services command wasn't looking at the right place for the exposed ports, so now it prints the exposed ports defined in the LoadBalancer service.

- How I did it
I identify the corresponding LoadBalancer service, suffixed by "-published" in its name.

- How to verify it
Deploy a stack with an exposed port:

$ cat docker-compose.yml
version: '3.3'
services:
  web:
    image: dockerdemos/lab-web
    ports:
     - "80:80"
$ DOCKER_ORCHESTRATOR=kubernetes docker stack deploy mystack -c docker-compose.yml

Before the fix:

$ DOCKER_ORCHESTRATOR=kubernetes docker stack services mystack
ID                  NAME                MODE                REPLICAS            IMAGE                   PORTS
93b6b4ae-26c        mystack_web         replicated          1/1                 dockerdemos/lab-web

After the fix:

ID                  NAME                MODE                REPLICAS            IMAGE                   PORTS
93b6b4ae-26c        mystack_web         replicated          1/1                 dockerdemos/lab-web     *:80->80/tcp

- Description for the changelog
Fix docker stack services PORTS column on Kubernetes.

- A picture of a cute animal (not mandatory but encouraged)
image

Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐯

@@ -172,3 +172,16 @@ func findService(services *apiv1.ServiceList, name string) (apiv1.Service, bool)
}
return apiv1.Service{}, false
}

func makeServiceEndpoint(service apiv1.Service, publishMode swarm.PortConfigPublishMode) swarm.Endpoint {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: s/makeServiceEndpoint/serviceEndoint ? 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@silvin-lubecki silvin-lubecki force-pushed the fix-kubernetes-published-service branch from 22903e0 to 1615089 Compare March 13, 2018 17:51
@codecov-io
Copy link

codecov-io commented Mar 13, 2018

Codecov Report

Merging #943 into master will increase coverage by 0.29%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #943      +/-   ##
==========================================
+ Coverage   53.92%   54.22%   +0.29%     
==========================================
  Files         262      262              
  Lines       16604    16610       +6     
==========================================
+ Hits         8954     9007      +53     
+ Misses       7049     7001      -48     
- Partials      601      602       +1

…ice is a LoadBalancer or a NodePort

* added tests on Kubernetes service conversion to swarm service

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
@silvin-lubecki silvin-lubecki force-pushed the fix-kubernetes-published-service branch from 1615089 to b816bde Compare March 14, 2018 10:34
@@ -116,25 +116,31 @@ func (t tasksBySlot) Less(i, j int) bool {
return t[j].Meta.CreatedAt.Before(t[i].CreatedAt)
}

const (
publishedServiceSuffix = "-published"
publishedOnRandomPortSuffix = "-random-ports"
Copy link
Member

Choose a reason for hiding this comment

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

nit: There was some discussion around naming of this; as they're not fully "random", but "selected from an ephemeral range"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, good to know, but unfortunately these names are defined in the already shipped compose controller...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, probably not a big issue, it's just that they are not really "random" (could be sequential), so "ephemeral" is possibly a better description.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@thaJeztah thaJeztah merged commit 27f66e3 into docker:master Mar 26, 2018
@GordonTheTurtle GordonTheTurtle added this to the 18.04.0 milestone Mar 26, 2018
@silvin-lubecki silvin-lubecki deleted the fix-kubernetes-published-service branch March 26, 2018 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants