def get_project_name_for_namespace(self): # Check if cluster_project is defined, return that # Else, return self.name # Get lock in case some other api is setting the config with get_lock('kube_manager_conf'): project = self._read_cluster_project() if project: return project else: return self.inputs.k8s_cluster_name + "-" + self.name
def test_service_with_external_ip(self): ''' Create a service with 2 pods running nginx Add annotation external_ip Create a third busybox pod and validate that webservice is load-balanced Validate that webservice is load-balanced from outside network using external_ip Please make sure BGP multipath and per packer load balancing is enabled on the MX ''' app = 'http_test' labels = {'app': app} namespace = self.setup_namespace() #assert namespace.verify_on_setup() # Make sure that no other test can use the external ip by accident pub_vn_fixture = self.public_vn.public_vn_fixture with get_lock(self.inputs.fip_pool): external_ips = pub_vn_fixture.alloc_ips(1) assert external_ips, 'No free IP available to use in public VN' pub_vn_fixture.free_ips(external_ips) service = self.setup_http_service(namespace=namespace.name, labels=labels, external_ips=external_ips) pod1 = self.setup_nginx_pod(namespace=namespace.name, labels=labels) pod2 = self.setup_nginx_pod(namespace=namespace.name, labels=labels) pod3 = self.setup_busybox_pod(namespace=namespace.name) assert self.verify_nginx_pod(pod1) assert self.verify_nginx_pod(pod2) assert pod3.verify_on_setup() assert service.verify_on_setup() # Now validate load-balancing on the service assert self.validate_nginx_lb([pod1, pod2], service.cluster_ip, test_pod=pod3) # When Isolation enabled we need to change SG to allow traffic # from outside. For that we need to disiable service isolation if self.setup_namespace_isolation: namespace.disable_service_isolation() # Now validate ingress from public network assert self.validate_nginx_lb([pod1, pod2], service.external_ips[0])