code: def init_spark_on_k8s(
      self,
      master,
      container_image,
      num_executors,
      executor_cores,
      executor_memory="2g",
      driver_memory="1g",
      driver_cores=4,
      extra_executor_memory_for_ray=None,
      extra_python_lib=None,
      conf=None,
      jars=None,
      python_location=None,
  ):
      print("Initializing SparkContext for k8s-client mode")
      python_env = "/".join(detect_python_location().split("/")[:-2])
      if "PYSPARK_PYTHON" not in os.environ:
          os.environ["PYSPARK_PYTHON"] = (
              python_location
              if python_location
              else detect_python_location()
          )
  
      submit_args = "--master " + master + " --deploy-mode client"
      submit_args = submit_args + gen_submit_args(
          driver_cores,
          driver_memory,
          num_executors,
          executor_cores,
          executor_memory,
          extra_python_lib,
          jars,
      )
  
      conf = enrich_conf_for_spark(
          conf,
          driver_cores,
          driver_memory,
          num_executors,
          executor_cores,
          executor_memory,
          extra_executor_memory_for_ray,
      )
      py_version = ".".join(platform.python_version().split(".")[0:2])
      preload_so = python_env + "/lib/libpython" + py_version + "m.so"
      ld_path = (
          python_env
          + "/lib:"
          + python_env
          + "/lib/python"
          + py_version
          + "/lib-dynload"
      )
      if "spark.executor.extraLibraryPath" in conf:
          ld_path = "{}:{}".format(
              ld_path, conf["spark.executor.extraLibraryPath"]
          )
      conf.update(
          {
              "spark.cores.max": num_executors * executor_cores,
              "spark.executorEnv.PYTHONHOME": python_env,
              "spark.executor.extraLibraryPath": ld_path,
              "spark.executorEnv.LD_PRELOAD": preload_so,
              "spark.kubernetes.container.image": container_image,
          }
      )
      # Not targeted to use pip install. BIGDL_CLASSPATH is supposed to set.
      if "BIGDL_CLASSPATH" in os.environ:
          zoo_bigdl_jar_path = os.environ["BIGDL_CLASSPATH"]
      else:
          zoo_bigdl_jar_path = ":".join(
              list(get_zoo_bigdl_classpath_on_driver())
          )
      if "spark.executor.extraClassPath" in conf:
          conf["spark.executor.extraClassPath"] = "{}:{}".format(
              zoo_bigdl_jar_path, conf["spark.executor.extraClassPath"]
          )
      else:
          conf["spark.executor.extraClassPath"] = zoo_bigdl_jar_path
  
      sc = self.create_sc(submit_args, conf)
      return sc
  
file_path: analytics-zoo/pyzoo/zoo/util/spark.py
imports: import os
  import platform
  from pyspark import SparkContext
  from zoo import init_nncontext, init_spark_conf
  from zoo.util.utils import detect_python_location, pack_penv
  from zoo.util.utils import get_executor_conda_zoo_classpath, get_zoo_bigdl_classpath_on_driver
label_desc: Use image node_id 7 for calling the SparkRunner obj's underlying member method code with example usage: obj.init_spark_on_k8s(master, container_image, num_executors, executor_cores, executor_memory, driver_memory, driver_cores, extra_executor_memory_for_ray, extra_python_lib, conf, jars, python_location) and returns: sc