通过SSH隧道为私有Cloud Composer环境运行Airflow CLI命令



我想直接从本地机器访问专用的Google Cloud Composer 2环境,并执行Airflow CLI命令。文档提到了连接到专用环境的多种方法,但对于我的特定用例没有提及。我要么必须登录到同一VPC中的GCE实例,要么允许公共端点访问。

我目前正在尝试创建一个SSH隧道或Socks5 Proxy,连接到与我的Composer环境相同的VPC中的VM实例(bastion主机(。然后在我的shell中导出PROXY变量,并使用gcloud运行CLI命令

gcloud compute ssh bastion-host -- -ND 8888
export {HTTP,HTTPS}_PROXY=socks5://localhost:8888
gcloud composer environments run composer --location europe-west1 dags list

但我收到以下错误

ERROR: gcloud crashed (ProxyError): HTTPSConnectionPool(host='composer.googleapis.com', port=443): Max retries exceeded with url: /v1/projects/my-project/locations/europe-west1/environments/composer?alt=json (Caused by ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response')))

如何解决此问题?

看起来gcloud composer environments run不仅通过kubectl访问GKE集群,而且还进行了一些Google API调用。作为一种变通方法,我还必须设置NO_PROXY变量

export NO_PROXY=googleapis.com

最新更新