jina.orchestrate.deployments.config.k8slib.kubernetes_deployment module#

jina.orchestrate.deployments.config.k8slib.kubernetes_deployment.get_template_yamls(name, namespace, image_name, container_cmd, container_args, replicas, pull_policy, jina_deployment_name, pod_type, shard_id=None, port=None, env=None, env_from_secret=None, gpus=None, image_name_uses_before=None, image_name_uses_after=None, container_cmd_uses_before=None, container_cmd_uses_after=None, container_args_uses_before=None, container_args_uses_after=None, monitoring=False, port_monitoring=None, protocol=None, volumes=None, timeout_ready=600000)[source]#

Get the yaml description of a service on Kubernetes

  • name (str) – name of the service and deployment

  • namespace (str) – k8s namespace of the service and deployment

  • image_name (str) – image for the k8s deployment

  • container_cmd (str) – command executed on the k8s pods

  • container_args (str) – arguments used for the k8s pod

  • replicas (int) – number of replicas

  • pull_policy (str) – pull policy used for fetching the Docker images from the registry.

  • jina_deployment_name (str) – Name of the Jina Deployment this deployment belongs to

  • pod_type (str) – type os this pod, can be gateway/head/worker

  • shard_id (Optional[int]) – id of this shard, None if shards=1 or this is gateway/head

  • port (Union[int, List[int], None]) – port which will be exposed by the deployed containers

  • env (Optional[Dict]) – environment variables to be passed into configmap.

  • env_from_secret (Optional[Dict]) – environment variables from secret to be passed to this pod

  • gpus (Union[int, str, None]) – number of gpus to use, for k8s requires you pass an int number, refers to the number of requested gpus.

  • image_name_uses_before (Optional[str]) – image for uses_before container in the k8s deployment

  • image_name_uses_after (Optional[str]) – image for uses_after container in the k8s deployment

  • container_cmd_uses_before (Optional[str]) – command executed in the uses_before container on the k8s pods

  • container_cmd_uses_after (Optional[str]) – command executed in the uses_after container on the k8s pods

  • container_args_uses_before (Optional[str]) – arguments used for uses_before container on the k8s pod

  • container_args_uses_after (Optional[str]) – arguments used for uses_after container on the k8s pod

  • monitoring (bool) – enable monitoring on the deployment

  • port_monitoring (Optional[int]) – port which will be exposed, for the prometheus server, by the deployed containers

  • protocol (Union[str, List[str], None]) – In case of being a Gateway, the protocol or protocols list used to expose its server

  • volumes (Optional[List[str]]) – If volumes are passed to Executors, Jina will create a StatefulSet instead of Deployment and include the first volume in the volume mounts

  • timeout_ready (int) – The timeout in milliseconds of a Pod waits for the runtime to be ready. This parameter will be reflected in Kubernetes in the startup configuration where the failureThreshold will be calculated depending on timeout_ready. Value -1 is not supported for kubernetes

Return type:



Return a dictionary with all the yaml configuration needed for a deployment

jina.orchestrate.deployments.config.k8slib.kubernetes_deployment.get_cli_params(arguments, skip_list=(), port=None)[source]#

Get cli parameters based on the arguments.

  • arguments (Namespace) – arguments where the cli parameters are generated from

  • skip_list (Tuple[str]) – list of arguments which should be ignored

  • port (Optional[int]) – overwrite port with the provided value if set

Return type:



string which contains all cli parameters


Convert the dictionary into a string to pass it as argument in k8s. :param dictionary: dictionary which has to be passed as argument in k8s.

Return type:



string representation of the dictionary