surahman edited a comment on pull request #3710: URL: https://github.com/apache/incubator-heron/pull/3710#issuecomment-921992801
Okay, so I am going to endeavour to break this down - please bear with me as I am still relatively new to the codebase and K8s API... --- Starting with the reference code in [Spark](https://github.com/apache/spark/blob/bbb33af2e4c90d679542298f56073a71de001fb7/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesUtils.scala#L96-L113), and keeping in mind that the Spark architecture is different from Heron's: This simply gets the Hadoop config from the driver/coordinator: ```scala val hadoopConf = SparkHadoopUtil.get.newConfiguration(conf) ``` These two lines are going to download the remote file from the driver/coordinator and make them local to a machine. The first line [downloads](https://github.com/joan38/kubernetes-client/blob/6fbf23b7a997e572456256c4714222ea734bd845/kubernetes-client/src/com/goyeau/kubernetes/client/api/PodsApi.scala#L119-L148) the file, assuming I am looking at the correct Scala K8s API, and the second retrieves a file descriptor/handle on the downloaded file: ```scala val localFile = downloadFile(templateFileName, Utils.createTempDir(), conf, hadoopConf) val templateFile = new File(new java.net.URI(localFile).getPath) ``` This third line then does the heavy lifting of reading the Pod Template into a Pod Config from the newly copied local file: ```scala val pod = kubernetesClient.pods().load(templateFile).get() ``` The final line sets up the Spark container with the Pod Template and specified name: ```scala selectSparkContainer(pod, containerName) ``` --- Moving on to what we need to do on the Heron side: 1. Read the `ConfigMap` name from the `--config-property` option. I set the key for this to `heron.kubernetes.pod.template.configmap.name` with the value being the file name. 2. Read the YAML `ConfigMap` and extract the YAML node tree which contains the Pod Template. For this, we will either need a YAML parser or need to find a utility in the K8s Java API to do the job. I think the K8s Java API should include a utility for this, a lack thereof would remain a significant oversight on their part. 3. Create a `V1PodTemplateSpec` object using the results from step 2. 4. Iron out permission issues during testing, should they arise. I am not familiar with the K8s API but will start digging around for a YAML config to V1 object parser, if anyone is aware of where it is please let me know. There are some suggestions [here](https://github.com/kubernetes-client/java/issues/170). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
