ansible / ansible-container

DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.
GNU Lesser General Public License v3.0
2.19k stars 393 forks source link

Link aliases are not honored in kubernetes' roles #132

Open concaf opened 8 years ago

concaf commented 8 years ago

Hi,

In my ansible/container.yml, I have set an alias for my link as follows:

  webclient:
    image: centos:7
    command: ['./tmp/client.sh']
    links:
      - webserver:web

I have used the alias in my container.yml:

    - name: Configure client
      shell: echo -e '#!/bin/sh\nwhile true; do sleep 3; nmap -Pn -p 80 $WEB_PORT_80_TCP_ADDR; curl $WEB_PORT_80_TCP_ADDR:80; done' > /tmp/client.sh
`ansible/container.yml` ``` bash version: "1" services: webserver: image: centos:7 expose: - "80" command: ['/usr/sbin/apachectl', '-DFOREGROUND'] dev_overrides: ports: - "80:8080" webclient: image: centos:7 command: ['./tmp/client.sh'] links: - webserver:web ```
`ansible/main.yml` ``` bash - hosts: webserver tasks: - name: Install web server yum: name=httpd state=latest - name: Configure web server shell: echo "Hi, I am web server." > /var/www/html/index.html - hosts: webclient tasks: - name: Install nmap yum: name=nmap state=latest - name: Configure client shell: echo -e '#!/bin/sh\nwhile true; do sleep 3; nmap -Pn -p 80 $WEB_PORT_80_TCP_ADDR; curl $WEB_PORT_80_TCP_ADDR:80; done' > /tmp/client.sh - name: Make script executable file: path=/tmp/client.sh mode=0777 ```

My application works fine when I do ansible-container run, but when I deploy the Kubernetes role from ansible-container shipit kube, the application fails.

I checked inside the webclient pod, and the link alias is not being honored, instead of environment variables like WEB_PORT_80_TCP_ADDR, there are WEBSERVER_PORT_80_TCP_ADDR.

chouseknecht commented 8 years ago

I have not forgotten about this. When we start working with the OpenShift team on the new K8s modules, this will get fixed.

DanyC97 commented 8 years ago

@chouseknecht any time when the collaboration with OS team will start?

chouseknecht commented 8 years ago

It's actually starting now. Met with @detiber yesterday. Will be helping finish the new K8s modules which we will include here. It'll take a couple weeks, but my plan is to refactor shipit once the new modules are stable.

chouseknecht commented 8 years ago

Waiting around for the K8s modules to get done is probably not going to cut it. That's a longer term project.

Anyway... to fix this. It seems we need to create a service in kubernetes that represents the alias.