class_docstr: Class that implements the output of configuration files for Kubernetes for a given Deployment.
code: def _get_deployment_args(self, args):
      parsed_args = {
          "head_deployment": None,
          "deployments": [],
      }
      shards = getattr(args, "shards", 1)
      uses_before = getattr(args, "uses_before", None)
      uses_after = getattr(args, "uses_after", None)
  
      if args.name != "gateway":
          # head deployment only exists for sharded deployments
          if shards > 1:
              parsed_args[
                  "head_deployment"
              ] = Deployment._copy_to_head_args(self.args)
              parsed_args["head_deployment"].gpus = None
              parsed_args[
                  "head_deployment"
              ].port = GrpcConnectionPool.K8S_PORT
              parsed_args[
                  "head_deployment"
              ].port_monitoring = GrpcConnectionPool.K8S_PORT_MONITORING
              parsed_args["head_deployment"].uses = None
              parsed_args["head_deployment"].uses_metas = None
              parsed_args["head_deployment"].uses_with = None
  
              import json
  
              connection_list = {}
              for i in range(shards):
                  name = (
                      f"{to_compatible_name(self.name)}-{i}"
                      if shards > 1
                      else f"{to_compatible_name(self.name)}"
                  )
                  connection_list[
                      str(i)
                  ] = f"{name}.{self.k8s_namespace}.svc:{GrpcConnectionPool.K8S_PORT}"
  
              parsed_args[
                  "head_deployment"
              ].connection_list = json.dumps(connection_list)
  
              if uses_before:
                  parsed_args[
                      "head_deployment"
                  ].uses_before_address = f"127.0.0.1:{GrpcConnectionPool.K8S_PORT_USES_BEFORE}"
              if uses_after:
                  parsed_args[
                      "head_deployment"
                  ].uses_after_address = f"127.0.0.1:{GrpcConnectionPool.K8S_PORT_USES_AFTER}"
  
      for i in range(shards):
          cargs = copy.deepcopy(args)
          cargs.host = (
              args.host[0] if isinstance(args.host, list) else args.host
          )
          cargs.shard_id = i
          cargs.uses_before = None
          cargs.uses_after = None
          cargs.port = [
              GrpcConnectionPool.K8S_PORT + i
              for i in range(len(cargs.protocol))
          ]
          cargs.port_monitoring = GrpcConnectionPool.K8S_PORT_MONITORING
  
          cargs.uses_before_address = None
          cargs.uses_after_address = None
          if shards > 1:
              cargs.name = f"{cargs.name}-{i}"
          if args.name == "gateway":
              cargs.pod_role = PodRoleType.GATEWAY
          parsed_args["deployments"].append(cargs)
  
      return parsed_args
  
file_path: jina/jina/orchestrate/deployments/config/k8s.py
imports: import copy
  from argparse import Namespace
  from typing import Dict, List, Optional, Tuple, Union
  from jina.constants import __default_composite_gateway__, __default_executor__, __default_grpc_gateway__, __default_http_gateway__, __default_websocket_gateway__
  from jina.enums import PodRoleType
  from jina.excepts import NoContainerizedError
  from jina.orchestrate.deployments import Deployment
  from jina.orchestrate.deployments.config.helper import construct_runtime_container_args, get_base_executor_version, resolve_image_name, to_compatible_name, validate_uses
  from jina.orchestrate.deployments.config.k8slib import kubernetes_deployment
  from jina.serve.networking import GrpcConnectionPool
label_desc: Use image node_id 2 for calling the K8sDeploymentConfig obj's underlying member method code with example usage: obj._get_deployment_args(args) and returns: parsed_args