@@ -330,8 +330,8 @@ def create(self, name, image, command, **kwargs):
330330 data = {'metadata' : {'labels' : {'routable' : 'true' }}}
331331 self ._create_namespace (app_name )
332332 self ._create_secret (app_name )
333- self ._create_rc (name , image , command , ** kwargs )
334333 self ._create_service (name , app_name , app_type , data , image = image )
334+ self ._create_rc (name , image , command , ** kwargs )
335335
336336 except Exception as e :
337337 logger .debug (e )
@@ -697,11 +697,13 @@ def _healthcheck(self, controller, path='/', port=8080, delay=30, timeout=1):
697697 if controller ['spec' ]['selector' ]['type' ] not in ['web' , 'cmd' ]:
698698 return controller
699699
700+ app_name = controller ['spec' ]['selector' ]['app' ]
700701 # Inspect if a PORT env is already defined, make sure that's the port used
701- for item in controller ['spec' ]['template' ]['spec' ]['containers' ][0 ]['env' ]:
702- if item ['name' ] == 'PORT' :
703- port = int (item ['value' ])
704-
702+ try :
703+ service = self ._get_service (app_name , app_name ).json ()
704+ port = service ['spec' ]['ports' ][0 ]['targetPort' ]
705+ except :
706+ pass
705707 # Only support HTTP checks for now
706708 # http://kubernetes.io/v1.1/docs/user-guide/pod-states.html#container-probes
707709 healthcheck = {
@@ -770,8 +772,9 @@ def _create_service(self, name, app_name, app_type, data={}, **kwargs):
770772 image = kwargs .get ('image' )
771773 try :
772774 image = self .registry + '/' + image
775+ repo = image .split (":" )
773776 # image already includes the tag, so we split it out here
774- docker_cli .pull (image . rsplit ( ':' ) [0 ], image . rsplit ( ':' ) [1 ])
777+ docker_cli .pull (repo [0 ]+ ":" + repo [1 ], tag = repo [ 2 ], insecure_registry = True )
775778 image_info = docker_cli .inspect_image (image )
776779 port = int (list (image_info ['Config' ]['ExposedPorts' ].keys ())[0 ].split ("/" )[0 ])
777780 except :
0 commit comments