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

Simplify backend generation to avoid port publishing #204

Open
wants to merge 3 commits into
base: swarm-services
Choose a base branch
from
Open

Simplify backend generation to avoid port publishing #204

wants to merge 3 commits into from

Conversation

vincentlepot
Copy link

@vincentlepot vincentlepot commented Oct 5, 2016

In order to avoid port publishing when using Swarm services, the backend generation is based upon service name and service port (given by the interlock.port label on service).

The example has been updated accordingly.

@ehazlett
Copy link
Owner

ehazlett commented Oct 5, 2016

How do we handle backward compatibility and non-Swarm mode here?

@vincentlepot
Copy link
Author

As far as I understood, I didn't touch the pure container part, hence the backward compatibility should not be impacted. But maybe you have a use case in mind where it does not work?

@vincentlepot
Copy link
Author

Ah! One more thing, I only treated the swarm services case, for container, I haven't looked at a solution to avoid publishing port.

@sedouard
Copy link

sedouard commented Mar 24, 2017

So I'm testing this PR out with a compose stack deployment (docker stack). It seems like it interlock can't find the exposed ports, even though docker container inspect for the container returns:

"Ports": {
                "3000/tcp": null
}

I'm deploying with interlock in a compose file with:

interlock:
    image: sedouard/interlock:swarm-mode # <- just a build of this pull-request source branch
    command: -D run -c /etc/interlock/config.toml
    tty: true
    deploy:
      mode: replicated
      replicas: 2
      placement:
        constraints:
          - node.labels.type == web-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:rw
    networks:
      - redis-network
    depends_on:
      - nginx
    ports:
        - 8080:8080
    environment:
        INTERLOCK_CONFIG: |
            ListenAddr = ":8080"
            DockerURL = "unix:///var/run/docker.sock"
            PollInterval = "2s"
            [[Extensions]]
            Name = "nginx"
            ConfigPath = "/etc/nginx/nginx.conf"
            PidPath = "/var/run/nginx.pid"
            TemplatePath = ""
            MaxConn = 1024
            Port = 80
nginx:
    image: nginx:1.11
    entrypoint: nginx
    command: -g "daemon off;" -c /etc/nginx/nginx.conf
    ports:
        - 80:80
    labels:
        - "interlock.ext.name=nginx"
    deploy:
      mode: global
      placement:
        constraints:
          - node.labels.type == web-server
    networks:
      - redis-network
api:
    image: sedouard/api:latest
    ports:
      - 3000
    networks:
      - redis-network
deploy:
      mode: global
      placement:
        constraints:
          - node.labels.type == web-server

The line of code is:
https://github.com/vincentlepot/interlock/blob/20c3e0e1f6739eb388f5476940a2aef630b12467/ext/lb/nginx/generate.go#L89

where it seems to just be looking to see if there are >0 ports in the Ports bag

@sedouard
Copy link

Silly me -- my labels weren't under the deploy key.

@ehazlett
Copy link
Owner

cool :). I'm not sure we can merge this until the non swarm mode issue is addressed.

@vincentlepot
Copy link
Author

What's the problem with non swarm mode case?

@vincentlepot
Copy link
Author

Sorry I haven't looked here for a while since I used another solution for my use case. But if you need me to finish this PR, just tell me what you think is missing

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.

3 participants