Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 通过Kubernetes群集将PTVSD与VS代码连接起来_Python_Python 3.x_Visual Studio_Kubernetes_Kubernetes Ingress - Fatal编程技术网

Python 通过Kubernetes群集将PTVSD与VS代码连接起来

Python 通过Kubernetes群集将PTVSD与VS代码连接起来,python,python-3.x,visual-studio,kubernetes,kubernetes-ingress,Python,Python 3.x,Visual Studio,Kubernetes,Kubernetes Ingress,我有一个Flask应用程序,在Kubernetes吊舱内使用Gunicorn启动,命令如下: exec gunicorn --log-file - --access-logfile - --access-logformat "${LOGFORMAT}" \ --no-sendfile -w 1 -t 600 --bind 0.0.0.0:${APIPORT-1380} ${EXTRABIND} ${ARGS} \ -n apiwrapper "a

我有一个Flask应用程序,在Kubernetes吊舱内使用Gunicorn启动,命令如下:

exec gunicorn --log-file - --access-logfile - --access-logformat "${LOGFORMAT}" \
     --no-sendfile -w 1 -t 600 --bind 0.0.0.0:${APIPORT-1380} ${EXTRABIND} ${ARGS} \
     -n apiwrapper "apiwrapper:create_app()"
我想将PTVSD调试器附加到我的应用程序,并将其链接到VS代码。以下是我添加到函数
create\u app()
中的行:

我们的架构遵循以下模式:

入口-->服务-->吊舱

在我的Kubernetes服务中,我添加了:

    - port: 9797
      name: ptvsd-debugger
这给了我:

backendapi                  ClusterIP   x.x.35.83     <none>        80/TCP,1380/TCP,9797/TCP   81m
public-site-standard-web    ClusterIP   x.x.214.19    <none>        80/TCP,8080/TCP,9797/TCP   83m
以下是
公共站点
入口:

Name:             public-site-standard-web
Namespace:        default
Address:          192.168.50.101
Default backend:  default-http-backend:80 (<none>)
TLS:
  dev-tls terminates myhostname.com
Rules:
  Host                        Path  Backends
  ----                        ----  --------
  myhostname.com  
                              /debugger   backendapi:9797 (x.x.x.25:9797)
                              /           public-site-standard-web:http (x.x.x.12:80)
Name:             backendapi
Namespace:        default
Address:          192.168.50.101
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host                        Path  Backends
  ----                        ----  --------
  myhostname.com  
                              /debugger         backendapi:9797 (x.x.x.25:9797)
                              /backend/api/v2   backendapi:http (x.x.x.25:80)
现在我在VS代码中创建了我的调试器配置:

{
   "name": "Python: Remote Attach",
   "type": "python",
   "request": "attach",
   "port": 80,
   "host": "myhostname.com/debugger",
   "pathMappings": [
      {
         "localRoot": "${workspaceFolder}/backend/py",
         "remoteRoot": "."
      }
   ]
}
但我得到了:

getaddrinfo ENOTFOUND myhostname.com/debugger
但是当我试图直接访问URL
https://myhostname.com/debugger
我可以在pod日志中看到调试器正在接收调用:

E00139.153: Traceback (most recent call last):
              File "/usr/local/lib/python3.8/site-packages/ptvsd/ipcjson.py", line 269, in process_one_message
                msg = self.__message.pop(0)
            IndexError: pop from empty list
            
            During handling of the above exception, another exception occurred:
            
            Traceback (most recent call last):
              File "/usr/local/lib/python3.8/site-packages/ptvsd/ipcjson.py", line 258, in process_messages
                self.process_one_message()
......................
ptvsd.ipcjson.InvalidHeaderError: Malformed header, expected 'name: value'
VSCode配置有什么问题?还是说我不可能完成我想要实现的目标?
谢谢你

你说过,当你直接访问URL时,你会得到肯定的结果,但你可以通过点击HTTPS来实现。HTTPS使用端口443,在VS代码中的调试器配置中,您将其和其他所有内容配置为使用端口80。您如何才能在端口443上获得答案?因为HTTP请求由于
公共站点
入口而重定向到HTTPS<代码>公共网站标准网站jocteau.aws.citizennet.com x.x.x.101 80443 3h42m。我编辑了问题,那么如果您在VS代码中配置调试器配置以使用HTTPS呢?我通过端口:443更改了端口:80,得到了完全相同的错误更改端口并没有告诉它使用SSL通信。你知道它是否得到支持吗?
{
   "name": "Python: Remote Attach",
   "type": "python",
   "request": "attach",
   "port": 80,
   "host": "myhostname.com/debugger",
   "pathMappings": [
      {
         "localRoot": "${workspaceFolder}/backend/py",
         "remoteRoot": "."
      }
   ]
}
getaddrinfo ENOTFOUND myhostname.com/debugger
E00139.153: Traceback (most recent call last):
              File "/usr/local/lib/python3.8/site-packages/ptvsd/ipcjson.py", line 269, in process_one_message
                msg = self.__message.pop(0)
            IndexError: pop from empty list
            
            During handling of the above exception, another exception occurred:
            
            Traceback (most recent call last):
              File "/usr/local/lib/python3.8/site-packages/ptvsd/ipcjson.py", line 258, in process_messages
                self.process_one_message()
......................
ptvsd.ipcjson.InvalidHeaderError: Malformed header, expected 'name: value'