Exemple #1
0
 def get_builder(
         self,
         preprocessor,
         base_image,
         registry,
         needs_deps_installation=True,  # pylint:disable=arguments-differ
         pod_spec_mutators=None):
     if not needs_deps_installation:
         return AppendBuilder(preprocessor=preprocessor,
                              base_image=base_image,
                              registry=registry)
     elif fairing.utils.is_running_in_k8s():
         return ClusterBuilder(preprocessor=preprocessor,
                               base_image=base_image,
                               registry=registry,
                               pod_spec_mutators=pod_spec_mutators,
                               namespace=self._namespace,
                               context_source=self._build_context_source)
     elif ml_tasks_utils.is_docker_daemon_exists():
         return DockerBuilder(preprocessor=preprocessor,
                              base_image=base_image,
                              registry=registry)
     else:
         # TODO (karthikv2k): Add more info on how to reolve this issue
         raise RuntimeError(
             "Not able to guess the right builder for this job!")
Exemple #2
0
 def get_builder(self,
                 preprocessor,
                 base_image,
                 registry,
                 needs_deps_installation=True,
                 pod_spec_mutators=None):
     pod_spec_mutators = pod_spec_mutators or []
     pod_spec_mutators.append(gcp.add_gcp_credentials_if_exists)
     # TODO (karthikv2k): Add cloud build as the deafult
     # once https://github.com/kubeflow/fairing/issues/145 is fixed
     if fairing.utils.is_running_in_k8s():
         return ClusterBuilder(preprocessor=preprocessor,
                               base_image=base_image,
                               registry=registry,
                               pod_spec_mutators=pod_spec_mutators)
     elif ml_tasks_utils.is_docker_daemon_exists():
         return DockerBuilder(preprocessor=preprocessor,
                              base_image=base_image,
                              registry=registry)
     elif not needs_deps_installation:
         return AppendBuilder(preprocessor=preprocessor,
                              base_image=base_image,
                              registry=registry)
     else:
         # TODO (karthikv2k): Add more info on how to reolve this issue
         raise RuntimeError(
             "Not able to guess the right builder for this job!")
Exemple #3
0
    def get_builder(self,
                    preprocessor,
                    base_image,
                    registry,
                    needs_deps_installation=True,
                    pod_spec_mutators=None):

        pod_spec_mutators = pod_spec_mutators or []
        pod_spec_mutators.append(gcp.add_gcp_credentials_if_exists)

        if not needs_deps_installation:
            return AppendBuilder(preprocessor=preprocessor,
                                 base_image=base_image,
                                 registry=registry)
        elif (fairing.utils.is_running_in_k8s() or
              not ml_tasks_utils.is_docker_daemon_exists()) and \
                KubeManager().secret_exists(constants.GCP_CREDS_SECRET_NAME, self._namespace):
            return ClusterBuilder(preprocessor=preprocessor,
                                  base_image=base_image,
                                  registry=registry,
                                  pod_spec_mutators=pod_spec_mutators,
                                  namespace=self._namespace,
                                  context_source=self._build_context_source)
        elif ml_tasks_utils.is_docker_daemon_exists():
            return DockerBuilder(preprocessor=preprocessor,
                                 base_image=base_image,
                                 registry=registry)
        else:
            msg = ["Not able to guess the right builder for this job!"]
            if KubeManager().secret_exists(constants.GCP_CREDS_SECRET_NAME,
                                           self._namespace):
                msg.append(
                    "It seems you don't have permission to list/access secrets in your "
                    "Kubeflow cluster. We need this permission in order to build a docker "
                    "image using Kubeflow cluster. Adding Kubeneters Admin role to the "
                    "service account you are using might solve this issue.")
            if not fairing.utils.is_running_in_k8s():
                msg.append(
                    " Also If you are using 'sudo' to access docker in your system you can"
                    " solve this problem by adding your username to the docker group. "
                    "Reference: https://docs.docker.com/install/linux/linux-postinstall/"
                    "#manage-docker-as-a-non-root-user You need to logout and login to "
                    "get change activated.")
            message = " ".join(msg)
            raise RuntimeError(message)