抱歉,这个问题比较菜鸟,我刚刚开始使用 Google Cloud 和 Web 开发。我有一个 Flask 应用程序,在本地运行良好,在部署到 GC 中的 VM 时也运行良好。但是,我现在只能使用外部 IP 地址来触发 API,我想给它一个友好的 URL。
所以目前我有 15.15.15.15/triggerawesomapi 并且我想要拥有:https://awesomeapplication.com/triggerawesomapi
我应该怎么做才能实现这个目标?
答案1
选项 1)更简单、更快捷的方法,但可靠性较差:
1.1. Assign an external/static IP to your VM server
1.2. Change your DNS entry awesomeapplication.com to point to your static external IP
In this case, your application is supposed to have an outage in case your server goes down
选项 2)需要做更多工作,但更可靠
2.1. Create a VM image with your application
2.2. Create a MIG (Managed Instance Group)
2.3. Configure a load balancer with health-check pointing to your MIG
2.4. Change your DNS entry to point to your load balancer
In this case, GCP is supposed to launch a new healthy VM, in case of an application failure
选项3)推荐一个:更容易维护和可靠
3.1. Create a docker image and deploy it to AppEngine
3.2. Change your DNS entry to point to your AppEngine's URL
In this case, you're supposed to have automatic scale and reliability. Besides, AppEngine standard can downscale to zero when idle, in order to save costs. In addition, you can leverage canary deployments and cache from default's AppEngine infrastructure.