def get_replica(self, environment): main_container = k8s_schemas.V1Container(name="main") sidecar_containers = [k8s_schemas.V1Container(name="sidecar")] init_containers = [k8s_schemas.V1Container(name="init")] replica = ReplicaSpec( volumes=[], init_containers=init_containers, sidecar_containers=sidecar_containers, main_container=main_container, labels=environment.labels, environment=environment, num_replicas=12, ) metadata, pod_spec = get_pod_spec( namespace="default", main_container=main_container, sidecar_containers=sidecar_containers, init_containers=init_containers, resource_name="foo", volumes=[], environment=environment, labels=environment.labels, ) replica_template = { "replicas": replica.num_replicas, "restartPolicy": pod_spec.restart_policy, "template": get_pod_template_spec(metadata=metadata, pod_spec=pod_spec), } return replica, replica_template
def get_replica_resource( self, environment: V1Environment, plugins: V1Plugins, contexts: PluginsContextsSpec, volumes: List[k8s_schemas.V1Volume], init: List[V1Init], sidecars: List[k8s_schemas.V1Container], container: k8s_schemas.V1Container, artifacts_store: V1ConnectionType, connections: List[str], connection_by_names: Dict[str, V1ConnectionType], secrets: Optional[Iterable[V1K8sResourceType]], config_maps: Optional[Iterable[V1K8sResourceType]], default_sa: str = None, ports: List[int] = None, num_replicas: int = None, ) -> ReplicaSpec: volumes = volumes or [] init = init or [] sidecars = sidecars or [] connections = connections or [] environment = environment or V1Environment() environment.service_account_name = (environment.service_account_name or default_sa or settings.AGENT_CONFIG.runs_sa) init_connections = self.filter_connections_from_init(init=init) volumes = get_pod_volumes( contexts=contexts, artifacts_store=artifacts_store, init_connections=init_connections, connections=connections, connection_by_names=connection_by_names, secrets=secrets, config_maps=config_maps, volumes=volumes, ) init_containers = self.get_init_containers( polyaxon_init=self.polyaxon_init, contexts=contexts, artifacts_store=artifacts_store, init_connections=init_connections, init_containers=self.filter_containers_from_init(init=init), connection_by_names=connection_by_names, ) sidecar_containers = self.get_sidecar_containers( polyaxon_sidecar=self.polyaxon_sidecar, contexts=contexts, artifacts_store=artifacts_store, sidecar_containers=sidecars, ) main_container = self.get_main_container( main_container=container, contexts=contexts, artifacts_store=artifacts_store, connections=connections, init_connections=init_connections, connection_by_names=connection_by_names, log_level=plugins.log_level, secrets=secrets, config_maps=config_maps, ports=ports, ) labels = self.get_labels(version=pkg.VERSION, labels=environment.labels) return ReplicaSpec( volumes=volumes, init_containers=init_containers, sidecar_containers=sidecar_containers, main_container=main_container, labels=labels, environment=environment, num_replicas=num_replicas, )