как получить доступ к метаданным кластера Datapro c? - PullRequest
3 голосов
/ 06 января 2020

После создания кластера я пытаюсь получить URL-адрес моих дополнительных компонентов (без использования панели управления GCP). Я использую de Datapro c python API и, более конкретно, функцию get_cluster().

Функция возвращает много данных, но мне не удается найти URL-адрес шлюза Jupyter или другие метаданные.

from google.cloud import dataproc_v1

project_id, cluster_name = '', ''
region = 'europe-west4'

client = dataproc_v1.ClusterControllerClient(
                       client_options={
                            'api_endpoint': '{}-dataproc.googleapis.com:443'.format(region)
                        }
                    )


response = client.get_cluster(project_id, region, cluster_name)
print(response)

Кто-нибудь может решить эту проблему?

1 Ответ

4 голосов
/ 06 января 2020

Если вы выполнили , то выполните c, чтобы настроить доступ Jupyter, включив шлюз компонентов, тогда вы можете получить доступ к веб-интерфейсам, как описано здесь . Хитрость заключается в том, что это включено в ответ API для версии v1beta2.

Изменения, необходимые в коде, минимальны (кроме библиотеки google-cloud-dataproc никаких дополнительных требований). Просто замените dataproc_v1 на dataproc_v1beta2 и получите доступ к конечным точкам с помощью response.config.endpoint_config:

from google.cloud import dataproc_v1beta2

project_id, cluster_name = '', ''
region = 'europe-west4'

client = dataproc_v1beta2.ClusterControllerClient(
                       client_options={
                            'api_endpoint': '{}-dataproc.googleapis.com:443'.format(region)
                        }
                    )


response = client.get_cluster(project_id, region, cluster_name)
print(response.config.endpoint_config)

В моем случае я получаю:

http_ports {
  key: "HDFS NameNode"
  value: "https://REDACTED-dot-europe-west4.dataproc.googleusercontent.com/hdfs/dfshealth.html"
}
http_ports {
  key: "Jupyter"
  value: "https://REDACTED-dot-europe-west4.dataproc.googleusercontent.com/jupyter/"
}
http_ports {
  key: "JupyterLab"
  value: "https://REDACTED-dot-europe-west4.dataproc.googleusercontent.com/jupyter/lab/"
}
http_ports {
  key: "MapReduce Job History"
  value: "https://REDACTED-dot-europe-west4.dataproc.googleusercontent.com/jobhistory/"
}
http_ports {
  key: "Spark History Server"
  value: "https://REDACTED-dot-europe-west4.dataproc.googleusercontent.com/sparkhistory/"
}
http_ports {
  key: "Tez"
  value: "https://REDACTED-dot-europe-west4.dataproc.googleusercontent.com/apphistory/tez-ui/"
}
http_ports {
  key: "YARN Application Timeline"
  value: "https://REDACTED-dot-europe-west4.dataproc.googleusercontent.com/apphistory/"
}
http_ports {
  key: "YARN ResourceManager"
  value: "https://REDACTED-dot-europe-west4.dataproc.googleusercontent.com/yarn/"
}
enable_http_port_access: true
...