简体   繁体   English

尝试建立与Azure Datalake的连接时,Kubernetes Pod中出现“ OAuth2Client:获取令牌请求失败”错误

[英]“OAuth2Client:Get Token request failed” error in Kubernetes Pod when attempting to make connection to azure datalake

I have a docker image which creates a connection to Azure Datalake using adlCreds = lib.auth(tenant_id=tenantId, client_secret=application_key, client_id=application_id) in python and access a file. 我有一个Docker映像,该映像使用adlCreds = lib.auth(tenant_id=tenantId, client_secret=application_key, client_id=application_id)创建到Azure Datalake的连接并访问文件。 I am executing the docker image in a Kubernetes Pod using Airflow Kubernetes_Pod_Operator. 我正在使用Airflow Kubernetes_Pod_Operator在Kubernetes Pod中执行docker镜像。 When I instantiate the pod operator, the container in Kubernetes is terminating with the error OAuth2Client:Get Token request failed 当我实例化Pod运算符时,Kubernetes中的容器以错误OAuth2Client:Get Token request failed终止

I have verified the Azure creds and the connection is working fine when I execute it locally. 我已经验证了Azure信誉,并且在本地执行该连接时工作正常。 I am getting this error only when I run it in the cluster using Kubernetes Pod. 我只有在使用Kubernetes Pod在集群中运行它时才收到此错误。

        # Creating ADL connection

        def make_azure_enduser():
        logging.info('Creating the Azure Datalake Client...')
        config = dict(azure_tenantid=<tenant_id>'),
                      application_key=<azure_application_key>),
                      application_id=<azure_applicationid>),
                      subscriptionId=<azure_subid>),
                      adlAccountName=<azure_datalake_accountname>)
                      )
        # Format the tenant ID and Account Name as strings to be passed into the object
        application_id = "{}".format(config['application_id'])
        application_key = "{}".format(config['application_key'])
        tenantId = "{}".format(config['azure_tenantid'])
        store_name = "{}".format(config['adlAccountName'])

        # Create the token and the Azure Datalake File System Client
        adlCreds = lib.auth(tenant_id=tenantId, client_secret=application_key, client_id=application_id)

        adlsFileSystemClient = core.AzureDLFileSystem(adlCreds, store_name=store_name)
        return adlsFileSystemClient
        # instantiating Kubernetes_pod_operator in Airflow DAG

        get_adl_file = KubernetesPodOperator(namespace='default',
                                 image="get_adl_file:latest",
                                 image_pull_policy='IfNotPresent',
                                 image_pull_secrets='acr-registry',
                                 # cmds=["/bin/sh", "-c", "sleep 500"],
                                 # arguments=["sleep 500"],
                                 labels={"foo": "bar"},
                                 name="get_file",
                                 task_id="get_adl_file",
                                 get_logs=True,
                                 dag=dag
                                 )

I expect the pod to create a connection to datalake, but it is failing with the below error. 我希望pod可以建立与datalake的连接,但是失败并显示以下错误。

Kubernetes Pod logs Kubernetes Pod日志

> Creating the Azure Datalake Client...
> ed2a3672-9d3b-456e-924f-cdf6e5f60ce8 - TokenRequest:Getting token with
> client credentials.
> /opt/conda/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15:
> DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and
> will be removed in 0.23. Please import this functionality directly
> from joblib, which can be installed with: pip install joblib. If this
> warning is raised when loading pickled models, you may need to
> re-serialize those models with scikit-learn 0.21+.  
> warnings.warn(msg, category=DeprecationWarning)
> ed2a3672-9d3b-456e-924f-cdf6e5f60ce8 - OAuth2Client:Get Token request
> failed Traceback (most recent call last):   File
> "/opt/conda/lib/python3.7/site-packages/urllib3/connection.py", line
> 159, in _new_conn
>     (self._dns_host, self.port), self.timeout, extra_kw)   File "/opt/conda/lib/python3.7/site-packages/urllib3/util/connection.py",
> line 57, in create_connection
>     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):   File "/opt/conda/lib/python3.7/socket.py", line
> 748, in getaddrinfo
>     for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -3] Temporary failure in name
> resolution During handling of the above exception, another exception
> occurred: Traceback (most recent call last):   File
> "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py",
> line 600, in urlopen
>     chunked=chunked)   File "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py",
> line 343, in _make_request
>     self._validate_conn(conn)   File "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py",
> line 839, in _validate_conn
>     conn.connect()   File "/opt/conda/lib/python3.7/site-packages/urllib3/connection.py", line
> 301, in connect
>     conn = self._new_conn()   File "/opt/conda/lib/python3.7/site-packages/urllib3/connection.py", line
> 168, in _new_conn
>     self, "Failed to establish a new connection: %s" % e) urllib3.exceptions.NewConnectionError:
> <urllib3.connection.VerifiedHTTPSConnection object at 0x7f0941ce8160>:
> Failed to establish a new connection: [Errno -3] Temporary failure in
> name resolution

Please help me to fix this connection error. 请帮助我修复此连接错误。 Thanks 谢谢

This seems like a very specific issue. 这似乎是一个非常具体的问题。

Try the “Slack” of Kubernetes, there are skilled users who are gladly to help out! 尝试使用Kubernetes的“ Slack”,有熟练的用户很乐意为您提供帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python kubernetes 客户端获取 pod Ready 状态时间 - Python kubernetes client Get pod Ready state time 访问令牌过期时Gmail API错误(Python,Django):HttpAccessTokenRefreshError invalid_client:未找到OAuth客户端 - Gmail API error when access token expires (Python, Django): HttpAccessTokenRefreshError invalid_client: The OAuth client was not found Kubernetes Python客户端:使用Autobahn Websocket连接到Pod /服务/使用承载令牌扭曲 - Kubernetes Python Client: connecting to a pod/service using Autobahn websocket/Twisted using bearer token (&#39;意外的凭证类型&#39;,无,&#39;预期&#39;,&#39;service_account&#39;)和oauth2client(Python) - ('Unexpected credentials type', None, 'Expected', 'service_account') with oauth2client (Python) 使用 Python 使用 kubernetes-client 连接到 Kubernetes pod 中的 MongoDB - Connecting to MongoDB in Kubernetes pod with kubernetes-client using Python 如何从Django请求中获取oauth2客户端应用 - How to get oauth2 client app from Django request Kubernetes Python 客户端连接问题 - Kubernetes Python client connection Issue 尝试运行PyInstaller时,出现“致命错误”消息 - When Attempting to Run PyInstaller, I get the “Fatal error” Message 如何向 kong 插件请求 OAuth2 令牌 - How to request OAuth2 token to kong plugin 使用http.client.https.connnection向Microsoft Azure服务发出连接请求以分析图像 - Making connection request to microsoft azure services using http.client.https.connnection for analyzing Image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM