From 721b6de6bf484c7ecb120192b64b83d9da64ce6c Mon Sep 17 00:00:00 2001 From: Mark Burnett Date: Tue, 25 Jul 2017 16:28:12 -0500 Subject: [PATCH] [feat] Add tiller-host and -port options to apply This allows the use of a standalone tiller service. --- armada/cli/apply.py | 6 ++++++ armada/handlers/armada.py | 4 +++- armada/handlers/tiller.py | 14 +++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/armada/cli/apply.py b/armada/cli/apply.py index 37634bfb..0e41e93f 100644 --- a/armada/cli/apply.py +++ b/armada/cli/apply.py @@ -25,6 +25,8 @@ def applyCharts(args): args.dry_run, args.wait, args.timeout, + args.tiller_host, + args.tiller_port, args.debug_logging) armada.sync() @@ -49,6 +51,10 @@ class ApplyChartsCommand(cmd.Command): parser.add_argument('--timeout', action='store', type=int, default=3600, help='Specifies time to wait' ' for charts to deploy') + parser.add_argument('--tiller-host', action='store', type=str, + help='Specify the tiller host') + parser.add_argument('--tiller-port', action='store', type=int, + default=44134, help='Specify the tiller port') return parser def take_action(self, parsed_args): diff --git a/armada/handlers/armada.py b/armada/handlers/armada.py index d81bb9c9..5ef247b7 100644 --- a/armada/handlers/armada.py +++ b/armada/handlers/armada.py @@ -46,6 +46,8 @@ class Armada(object): dry_run=False, wait=False, timeout=DEFAULT_TIMEOUT, + tiller_host=None, + tiller_port=44134, debug=False): ''' Initialize the Armada Engine and establish @@ -58,7 +60,7 @@ class Armada(object): self.wait = wait self.timeout = timeout self.config = yaml.load(config) - self.tiller = Tiller() + self.tiller = Tiller(tiller_host=tiller_host, tiller_port=tiller_port) self.debug = debug # Set debug value diff --git a/armada/handlers/tiller.py b/armada/handlers/tiller.py index 7111c471..6f41653e 100644 --- a/armada/handlers/tiller.py +++ b/armada/handlers/tiller.py @@ -49,8 +49,10 @@ class Tiller(object): service over gRPC ''' - def __init__(self): + def __init__(self, tiller_host=None, tiller_port=TILLER_PORT): + self.tiller_host = tiller_host + self.tiller_port = tiller_port # init k8s connectivity self.k8s = K8s() @@ -74,9 +76,8 @@ class Tiller(object): Return a tiller channel ''' tiller_ip = self._get_tiller_ip() - tiller_port = self._get_tiller_port() return grpc.insecure_channel( - '%s:%s' % (tiller_ip, tiller_port), + '%s:%s' % (tiller_ip, self.tiller_port), options=[ ('grpc.max_send_message_length', MAX_MESSAGE_LENGTH), ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH) @@ -96,8 +97,11 @@ class Tiller(object): ''' Returns the tiller pod's IP address by searching all namespaces ''' - pod = self._get_tiller_pod() - return pod.status.pod_ip + if self.tiller_host: + return self.tiller_host + else: + pod = self._get_tiller_pod() + return pod.status.pod_ip def _get_tiller_port(self): '''Stub method to support arbitrary ports in the future'''