Пример #1
0
    def get_pod_template_spec(self,
                              resource_name,
                              volume_mounts,
                              volumes,
                              labels,
                              env_vars=None,
                              command=None,
                              args=None,
                              init_command=None,
                              init_args=None,
                              init_env_vars=None,
                              ports=None,
                              persistence_outputs=None,
                              persistence_data=None,
                              outputs_refs_jobs=None,
                              outputs_refs_experiments=None,
                              secret_refs=None,
                              configmap_refs=None,
                              resources=None,
                              ephemeral_token=None,
                              node_selector=None,
                              affinity=None,
                              tolerations=None,
                              restart_policy=None,
                              init_context_mounts=None,
                              sidecar_context_mounts=None):
        annotations = None
        if requests_tpu(resources):
            annotations = get_tpu_annotations()
        metadata = client.V1ObjectMeta(name=resource_name,
                                       labels=labels,
                                       namespace=self.namespace,
                                       annotations=annotations)

        pod_spec = self.get_task_pod_spec(
            resource_name=resource_name,
            volume_mounts=volume_mounts,
            volumes=volumes,
            env_vars=env_vars,
            command=command,
            args=args,
            init_command=init_command,
            init_args=init_args,
            init_env_vars=init_env_vars,
            ports=ports,
            persistence_outputs=persistence_outputs,
            persistence_data=persistence_data,
            outputs_refs_jobs=outputs_refs_jobs,
            outputs_refs_experiments=outputs_refs_experiments,
            secret_refs=secret_refs,
            configmap_refs=configmap_refs,
            resources=resources,
            ephemeral_token=ephemeral_token,
            node_selector=node_selector,
            affinity=affinity,
            tolerations=tolerations,
            init_context_mounts=init_context_mounts,
            sidecar_context_mounts=sidecar_context_mounts,
            restart_policy=restart_policy)
        return client.V1PodTemplateSpec(metadata=metadata, spec=pod_spec)
Пример #2
0
    def get_pod_spec(self,
                     resource_name,
                     volume_mounts,
                     volumes,
                     labels,
                     env_vars=None,
                     command=None,
                     args=None,
                     init_command=None,
                     init_args=None,
                     init_env_vars=None,
                     ports=None,
                     persistence_outputs=None,
                     persistence_data=None,
                     outputs_refs_jobs=None,
                     outputs_refs_experiments=None,
                     secret_refs=None,
                     config_map_refs=None,
                     resources=None,
                     annotations=None,
                     ephemeral_token=None,
                     node_selector=None,
                     affinity=None,
                     tolerations=None,
                     max_restarts=None,
                     restart_policy=None,
                     reconcile_url=None,
                     init_context_mounts=None,
                     sidecar_context_mounts=None):
        resources = self._get_pod_resources(resources=resources)
        resources_annotations = {}
        annotations = self._get_annotations(annotations=annotations)
        if requests_tpu(resources):
            resources_annotations = get_tpu_annotations()
        if annotations:
            resources_annotations.update(annotations)
        annotations = resources_annotations
        metadata = client.V1ObjectMeta(name=resource_name,
                                       labels=labels,
                                       namespace=self.namespace,
                                       annotations=annotations)

        pod_spec = self.get_task_pod_spec(
            resource_name=resource_name,
            volume_mounts=volume_mounts,
            volumes=volumes,
            env_vars=env_vars,
            command=command,
            args=args,
            init_command=init_command,
            init_args=init_args,
            init_env_vars=init_env_vars,
            ports=ports,
            persistence_outputs=persistence_outputs,
            persistence_data=persistence_data,
            outputs_refs_jobs=outputs_refs_jobs,
            outputs_refs_experiments=outputs_refs_experiments,
            secret_refs=secret_refs,
            config_map_refs=config_map_refs,
            resources=resources,
            ephemeral_token=ephemeral_token,
            node_selector=node_selector,
            affinity=affinity,
            tolerations=tolerations,
            init_context_mounts=init_context_mounts,
            sidecar_context_mounts=sidecar_context_mounts,
            reconcile_url=reconcile_url,
            max_restarts=max_restarts,
            restart_policy=restart_policy)
        return metadata, pod_spec