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

Service links don't work within kubernetes pods #8

Closed
solsson opened this issue Oct 26, 2016 · 5 comments
Closed

Service links don't work within kubernetes pods #8

solsson opened this issue Oct 26, 2016 · 5 comments

Comments

@solsson
Copy link
Collaborator

solsson commented Oct 26, 2016

By design we call svn -> rweb -> svn to serve ?rweb= stuff. With docker-compose this works if services are named like that, or one of them is and the other has a links: entry.

For example the svn container tends to respond Proxy Error DNS lookup failure for: rweb if the following strings don't match:

In Kubernetes you typically run svn and rweb containers in the same pod, which means that svn will reach rweb on 127.0.0.1:9000, but not rweb:9000.

@solsson solsson changed the title Service links Service links don't work within kubernetes pods Oct 26, 2016
@solsson
Copy link
Collaborator Author

solsson commented Oct 26, 2016

By the way why is there double slashes after rweb:9000 in services.conf?

@solsson
Copy link
Collaborator Author

solsson commented Oct 26, 2016

Can individual containers be resolved by name in Kubernetes pods? The most elegant solution to this issue would be that svn:80 and rweb:9000 works in both docker-compose and kube.

@solsson
Copy link
Collaborator Author

solsson commented Nov 3, 2016

Using this workaround in a downstream dockerfile specifically for kubernetes:

RUN  sed -i 's|fcgi://rweb:9000|fcgi://127.0.0.1:9000|' conf/svn/rweb/services-fpm.conf \
  && sed -i 's|fcgi://rweb:9000|fcgi://127.0.0.1:9000|' conf/svn/rweb/load-fpm.conf

The RWEB_SVC variable i conf/svn/rweb/services-fpm.conf is no solution because ProxyPassMatch doesn't support variables. Maybe if we use rewrite there too. Name resolution would be more elegant though.

@solsson
Copy link
Collaborator Author

solsson commented Nov 15, 2016

Improved the workaround so that it can work with regular docker, given a named link.

diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml
index ea08931..2244d33 100644
--- a/build-contracts/docker-compose.yml
+++ b/build-contracts/docker-compose.yml
@@ -9,6 +9,8 @@ services:
     environment:
       - DEBUG=true
       - REPOS_SVC=fcgi://rweb:9000/opt/rweb
+    links:
+      - rweb:svn
   rweb:
     image: solsson/rweb:latest
     expose:
diff --git a/rweb-svn/Dockerfile b/rweb-svn/Dockerfile
index e77ba2b..6338dad 100644
--- a/rweb-svn/Dockerfile
+++ b/rweb-svn/Dockerfile
@@ -7,5 +7,5 @@ ADD leansetup /usr/local/bin/
 RUN sed -i 's/set -e/set -e\n\nleansetup/' /usr/local/bin/httpd-foreground

 # fix multi-container pod issue "DNS lookup failure for: rweb"
-RUN  sed -i 's|fcgi://rweb:9000|fcgi://127.0.0.1:9000|' conf/svn/rweb/services-fpm.conf \
-  && sed -i 's|fcgi://rweb:9000|fcgi://127.0.0.1:9000|' conf/svn/rweb/load-fpm.conf
+RUN  sed -i 's|fcgi://rweb:9000|fcgi://svn:9000|' conf/svn/rweb/services-fpm.conf \
+  && sed -i 's|fcgi://rweb:9000|fcgi://svn:9000|' conf/svn/rweb/load-fpm.conf

As the commit comment says I also tried the name _rweb._tcp.svn (see http://kubernetes.io/docs/admin/dns/#srv-records) but got DNS lookup failure for: _rweb._tcp.svn. I'm guessing that apache's name lookup doesn't support this dns extension.

@solsson
Copy link
Collaborator Author

solsson commented Mar 18, 2017

I don't know what commit I'm referring to above, but now I realize that this isn't a problem with the docker image. Instead, in kubernetes, add a headless service rweb alongside your svn service, and the internal proxy httpd->fpm will work just like in docker-compose. For example, with the same selector app: svn that the service uses:

apiVersion: v1
kind: Service
metadata:
  name: rweb
spec:
  clusterIP: None
  selector:
    app: svn
  ports:
  - port: 9000
    targetPort: 9000

For more info see: https://kubernetes.io/docs/user-guide/services/#headless-services

@solsson solsson closed this as completed Mar 18, 2017
solsson added a commit to Reposoft/docker-repos-indexing that referenced this issue Mar 18, 2017
solsson added a commit to Reposoft/docker-repos-indexing that referenced this issue Mar 18, 2017
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

No branches or pull requests

1 participant