如何从Kubernetes Engine的基于http的服务器中在Google Cloud中创建https端点? [英] How to create https endpoint in Google Cloud from http based server for Kubernetes Engine?

查看:258
本文介绍了如何从Kubernetes Engine的基于http的服务器中在Google Cloud中创建https端点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在Google Cloud K8s环境中创建HTTPS端点.

I have been trying to create HTTPS endpoint in Google Cloud K8s environment.

我已经用Python构建了一个flask应用程序,该应用程序通过端口5000在女服务生的生产环境中使用.

I have built a flask application in Python that serves on the waitress production environment via port 5000.

serve(app, host='0.0.0.0', port=5000, ipv6=False, threads=30)

我创建了一个docker文件,并将其推送到Google云存储库.然后,创建一个Kubernetes集群,其中一个工作负载包含此映像.之后,我通过创建LoadBalancer通过外部IP公开了这一点. (将映像推送到Google存储库后,所有内容都通过Google Cloud Console进行管理.我没有任何配置文件,应该通过Google Cloud Console进行.)

I created a docker file and pushed this to the google cloud repository. Then, created a Kubernetes cluster with one workload containing this image. After, I exposed this via external IP by creating LoadBalancer. (After pushing the image to the Google repository, everything is managed through the Google Cloud Console. I do not have any configuration file, it should be through the Google Cloud Console.)

现在,我确实有一个公开的IP和端口号可以访问我的应用程序.假设此IP地址和端口为:11.111.11.222:1111.现在,我可以通过邮递员访问此IP并获得结果.

Now, I do have an exposed IP and port number to access my application. Let's say this IP address and the port is: 11.111.11.222:1111. Now, I can access this IP via Postman and get a result.

我的目标是,如果可能的话,也可以通过使用任何Google云资源来通过HTTPS公开此IP地址. (重定向,创建入口等)

My goal is to implement, If it is possible, to expose this IP address via HTTPS as well, by using any google cloud resources. (redirection, creating ingress, etc)

因此,最后我想通过http://11.111.11.222:111https://11.111.11.222:111

So, in the end I want to reach the application through http://11.111.11.222:111 and https://11.111.11.222:111

有什么建议吗?

推荐答案

研究后,我在Google Cloud Run中找到了答案.在容器中部署基于HTTP的flask应用程序非常简单.作为serve(app, host='0.0.0.0', port=5000, ipv6=False, threads=30)(这部分不需要自认证或HTTPS,只需确保HTTP应用程序正常运行),然后将其推送到Cloud Run.

After researching, I found the answer in Google Cloud Run. It is very simple to deploy HTTP based flask app in the container. As serve(app, host='0.0.0.0', port=5000, ipv6=False, threads=30)(No need for self-certificate or HTTPS in this part, just make sure the HTTP app works) and then push it Cloud Run.

调整服务参数,具体取决于您需要多少资源来运行它.在机器设置中,设置要映射的Docker容器中正在使用的端口.例如,对于我来说,它是5000.创建服务时,Google会为您提供一个HTTPS域名.您可以使用该URL并访问您的资源.

Adjust the service parameters, depend on how much resources do you need to run it. In the machine settings, set the port that you are using in the docker container to be mapped. for instance, in my case, it is 5000. When you create the service, Google provides you a domain address with HTTPS. You can use that URL and access your resources.

就是这样!

有关Cloud Run的更多信息: https://cloud.google.com/serverless-options

计算平台之间的差异: https://www.signalfx.com/blog/gcp-serverless-comparison/

这篇关于如何从Kubernetes Engine的基于http的服务器中在Google Cloud中创建https端点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆