From 4e796497d2343a525688375a4068f68f6d6d711d Mon Sep 17 00:00:00 2001 From: Cullen Taylor Date: Tue, 11 Sep 2018 09:11:34 -0400 Subject: [PATCH] Defer to service discoery in get_nginxhost_ip.py This will add a few lines of python to defer to service discovery in kubernetes. If http://geonode:80 is resolvable from the get-go, then that will be deferred to and the script will exit. If not, the rest of the logic which is key to running geonode with compose will continue to run normally. Signed-off-by: Cullen Taylor --- get_nginxhost_ip.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/get_nginxhost_ip.py b/get_nginxhost_ip.py index 753865d..0791877 100644 --- a/get_nginxhost_ip.py +++ b/get_nginxhost_ip.py @@ -2,9 +2,19 @@ import logging import os +import socket +import sys import docker +try: + socket.getaddrinfo('geonode', '80') + logging.info("k8s service discovery enabled") + print "http://geonode:80" + sys.exit() +except socket.gaierror as e: + logging.info("k8s service discovery not enabled, using docker-compose") + client = docker.from_env() # print client.info() # TODO avoid this script can fail and fall in the loop where the geoserver