示例#1
0
 def _create(self, app_spec, selector, labels):
     LOG.info("Creating/updating service for %s with labels: %s",
              app_spec.name, labels)
     ports = [
         self._make_service_port(port_spec) for port_spec in app_spec.ports
     ]
     try:
         svc = Service.get(app_spec.name, app_spec.namespace)
         ports = self._merge_ports(svc.spec.ports, ports)
     except NotFound:
         pass
     service_name = app_spec.name
     custom_labels = merge_dicts(app_spec.labels.service, labels)
     custom_annotations = merge_dicts(
         app_spec.annotations.service,
         self._make_tcp_port_annotation(app_spec))
     metadata = ObjectMeta(name=service_name,
                           namespace=app_spec.namespace,
                           labels=custom_labels,
                           annotations=custom_annotations)
     spec = ServiceSpec(selector=selector,
                        ports=ports,
                        type=self._service_type)
     svc = Service.get_or_create(metadata=metadata, spec=spec)
     self._owner_references.apply(svc, app_spec)
     svc.save()
示例#2
0
    def action():
        for kind in kinds:
            assert kind.get(name)
        dep = Deployment.get(name)
        assert dep.spec.template.spec.containers[0].image == image
        svc = Service.get(name)
        assert svc.spec.type == service_type

        for kind, expected_dict in expected.items():
            actual = kind.get(name)
            assert_k8s_resource_matches(actual, expected_dict, image, service_type, deployment_id, strongbox_groups)