V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
liliclinton
V2EX  ›  云计算

serverless framework 国内只能用腾讯云?

  •  
  •   liliclinton · 2021-11-09 16:55:04 +08:00 · 6970 次点击
    这是一个创建于 871 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近打算在 aws 上部署 serverless 应用,看了一圈感觉 serverless framework 这个框架挺热门打算试一试,结果安装完第一次初始化就只有腾讯云的模板可以选择,看了一圈文档都没找到地方修改默认设置,怀疑是判断系统语言强制的?

    然后搜了一下发现这个项目接受了腾讯云不少投资的样子,腾讯想要推广自家云服务就这么强奸用户的?

    53 条回复    2022-09-06 22:28:14 +08:00
    liliclinton
        1
    liliclinton  
    OP
       2021-11-09 17:07:26 +08:00
    看了一下是这里判断国内用户的
    https://github.com/serverless/components/blob/df2d3f34a09758a203838267586befa21bb4e104/src/cli/utils.js#L796

    代码里到处是国内用户的特殊处理逻辑,我呕呕
    ch2
        2
    ch2  
       2021-11-09 17:35:11 +08:00
    serverless 本身是跟平台强绑定的
    liliclinton
        3
    liliclinton  
    OP
       2021-11-09 17:38:19 +08:00
    @ch2 框架支持很多平台,然而他识别你是国内用户就只让你用腾讯云了
    ch2
        4
    ch2  
       2021-11-09 17:42:33 +08:00
    他这不就是个二道贩子吗,你不如直接用 aws 的 lambda
    liliclinton
        5
    liliclinton  
    OP
       2021-11-09 17:44:55 +08:00
    @ch2 这是个云服务编排框架,自己手动配置就要在控制台点点点老半天,每个接口上传一次代码,配置一次 api gateway
    locoz
        6
    locoz  
       2021-11-09 17:51:05 +08:00
    这个我记得之前说是不跟云厂商绑定的,可能是给的实在太多了?
    ch2
        7
    ch2  
       2021-11-09 17:51:56 +08:00   ❤️ 1
    每个平台都有自己的 cli ,跟它的上手难度没啥区别
    liliclinton
        8
    liliclinton  
    OP
       2021-11-09 17:54:15 +08:00
    @ch2 建议你先自己了解一下吧……
    liliclinton
        9
    liliclinton  
    OP
       2021-11-09 17:55:16 +08:00
    @locoz 框架本身是支持很多云服务的,海外可以看到各大云厂的组件,但是识别到是国内用户以后就只能看到腾讯云的组件了
    cev2
        10
    cev2  
       2021-11-09 17:57:56 +08:00
    官网用海外 IP 打开的是 Serverless ,用国内 IP 打开会自动跳转到 cn 开头的 Tencent Serverless ,这是俩东西。
    liliclinton
        11
    liliclinton  
    OP
       2021-11-09 17:58:58 +08:00
    @cev2 我直接 npm 安装的 serverless 运行的,参考的也都是英文文档,不存在装错东西的可能性
    liliclinton
        12
    liliclinton  
    OP
       2021-11-09 17:59:24 +08:00
    @cev2 何况我都找到了他判断用户地区的代码
    Vegetable
        13
    Vegetable  
       2021-11-09 17:59:39 +08:00
    serverless 本身就是很难迁移的,挺好理解的吧
    liliclinton
        14
    liliclinton  
    OP
       2021-11-09 18:00:37 +08:00
    @Vegetable 我想用 aws 不行?国内用户不配用?
    Vegetable
        15
    Vegetable  
       2021-11-09 18:00:59 +08:00
    嗯...我之前一直以为 serverless@npm 就是腾讯云的工具
    winnie2012
        16
    winnie2012  
       2021-11-09 18:01:38 +08:00
    腾讯云拿了国内的代理
    liliclinton
        17
    liliclinton  
    OP
       2021-11-09 18:04:39 +08:00
    国内官网确实只有腾讯云,看来钱是真的到位
    minbaby
        18
    minbaby  
       2021-11-09 18:05:32 +08:00
    为了传张图,专门去注册个账号 https://imgur.com/UO0viTq
    mxT52CRuqR6o5
        19
    mxT52CRuqR6o5  
       2021-11-09 18:05:37 +08:00
    躲都躲不起了
    cev2
        20
    cev2  
       2021-11-09 18:06:08 +08:00
    @liliclinton #10 #11 #12 ,不是说你装错了东西,根据 IP 判断是否国内用户,挂个代理就行了,或者手动改一下,在 .env 文件中增加配置 SERVERLESS_PLATFORM_VENDOR=aws
    liliclinton
        21
    liliclinton  
    OP
       2021-11-09 18:07:41 +08:00
    @cev2 他官网根据 ip 判断的,但是工具链看来只能这么绕过检测了,问题是如果我要用 gcp 或者 openwhisk 怎么办
    liliclinton
        22
    liliclinton  
    OP
       2021-11-09 18:09:11 +08:00
    @cev2 说实话就感觉恶心,不想用这玩意了
    cev2
        23
    cev2  
       2021-11-09 18:20:30 +08:00
    @liliclinton #21 IP (挂代理)和时区(没啥难度)不是国内就行,https://github.com/serverless/serverless/issues/8565 解释过他们这么做的原因。因噎废食没必要
    liliclinton
        24
    liliclinton  
    OP
       2021-11-09 18:23:42 +08:00   ❤️ 2
    @cev2 他不事先问用户,一定要用户自己想办法绕过,这不是强奸是什么
    ch2
        25
    ch2  
       2021-11-09 18:25:09 +08:00
    @liliclinton #8 我反正不用这玩意,serverless 跨平台是个伪需求,你不可能只单纯使用 serverless 本身的
    liliclinton
        26
    liliclinton  
    OP
       2021-11-09 18:25:59 +08:00
    @ch2 都说了不是跨平台,是为了方便编排,你没搞明白这是啥就别指点江山了,,,
    starsky007
        27
    starsky007  
       2021-11-09 20:47:50 +08:00
    我用过这个框架,肯定可以搭配 AWS 。你可以从这里找个模板,https://github.com/serverless/examples ,比命令行显示的全面。
    crystom
        28
    crystom  
       2021-11-09 20:59:57 +08:00
    腾讯云开会还请过 serverless 之父远程演讲呢
    liliclinton
        29
    liliclinton  
    OP
       2021-11-09 22:08:29 +08:00
    @starsky007 就要各种姿势去绕他那个检测嘛……我要用 serverless components 似乎不能用 templates
    hkbarton
        30
    hkbarton  
       2021-11-10 01:18:44 +08:00
    @liliclinton 你试试在你要部署的项目根目录创建一个 .env 的文件,然后里面加上这一行:

    SERVERLESS_PLATFORM_VENDOR='aws'


    serverless framework 在国内是和腾讯云有合作,但是开源的 serverless framework/components 并不是和云厂商强绑定的,可以通过.env 文件描述部署环境,可能只是他们文档写的不是太清楚
    hkbarton
        31
    hkbarton  
       2021-11-10 01:22:19 +08:00
    补充一下,可能需要在.env 中写两行:

    SERVERLESS_PLATFORM_VENDOR=aws
    SLS_GEO_LOCATION=us
    zhoujinjing09
        32
    zhoujinjing09  
       2021-11-10 02:36:07 +08:00
    serverless 为什么不直接用 aws fargate ?你要什么方面的 serverless 服务?
    cassyfar
        33
    cassyfar  
       2021-11-10 02:53:08 +08:00
    @liliclinton

    你可以用 cloudformation 或者 terraform 以代码形式来配置。感觉学习这类小作坊框架意义不大,而且坑多。
    Rocketer
        34
    Rocketer  
       2021-11-10 02:56:42 +08:00 via iPhone
    @zhoujinjing09 fargate 是类似于 k8s 的服务,跟函数计算还不是一回事,虽然都属于 serverless 。

    PS:楼主如果是来寻求解决方案的,楼上已经有人给出了,配置.env 文件即可。如果只是想吐个槽……
    dayeye2006199
        35
    dayeye2006199  
       2021-11-10 03:25:18 +08:00
    这种见人下菜碟的搞法确实不咋地。
    但框架后面的初创企业需要赚钱,这个做法也是可以理解的。

    最好是需要在文档上标注怎么去绕过这个默认行为。LZ 也可以去给提个 issue
    fannas
        36
    fannas  
       2021-11-10 04:13:59 +08:00 via iPhone
    其实不用点点点,aws 有 awscli 可以用。 并且建议使用新版。 一些地区还有网页版的 cli 不过网页版的没用过几次
    arischow
        37
    arischow  
       2021-11-10 08:45:20 +08:00 via iPhone
    国内 AWS 肯定可以用,看配置 YAML
    zxcslove
        38
    zxcslove  
       2021-11-10 09:23:08 +08:00
    和 roblox 一样恶臭
    Rorysky
        39
    Rorysky  
       2021-11-10 10:51:44 +08:00
    帮你提了个 issue
    maichael
        40
    maichael  
       2021-11-10 11:09:58 +08:00
    毕竟金主才是最大的,https://github.com/serverless/serverless/issues/7086 19 年到现在了
    liliclinton
        41
    liliclinton  
    OP
       2021-11-10 12:02:08 +08:00
    @zhoujinjing09 fargate 不是容器服务么
    liliclinton
        42
    liliclinton  
    OP
       2021-11-10 12:05:28 +08:00
    @fannas 问题是当你需要部署大量云函数和其他 aws 服务的时候,你需要一个工具帮你去批量处理和管理这些东西
    Rorysky
        43
    Rorysky  
       2021-11-10 12:15:10 +08:00
    来自开发者的回复:

    There is no discrimination here, The logic you see here is used to auto separate users that use AWS and Tencent Provider, and for users from China Tencent is the default provider.

    We decide to make Tencent as the default provider in China as we cooperate with Tencent closely to provide the best experience for most users from China, and user may easily switch back to AWS if they wish by set SERVERLESS_PLATFORM_VENDOR to aws or SLS_GEO_LOCATION to anywhere else than cn.

    We need to know if a user is from China, then we will show CLI context in Chinese to make it easier for users from China use the CLI and understand help info we want to tell users.

    Technically, we have have different architecture on AWS and Tencent, as the infrastructure is different, so we have different CLI (Framework CLI and Component CLI) to help user using serverless, to make user has the best experience, we nested the components CLI in the Framework CLI , they all will be triggered by commands serverless or sls, with geo location info we can easily find the correct CLI for all Serverless users.

    We worked a lot to improve the experience of users from China, not only the Chinese content, but also the user scenarios that China users preferred (eg: easy deploy WEB framework app to serverless, like Express, Flask, ThinkPHP).

    Hope this give you a clear idea why we check geo location and vendor info in our code, please let me know if you have future questions.
    sy20030260
        44
    sy20030260  
       2021-11-10 12:47:12 +08:00 via Android
    CLI init 也只是创建了个 yaml ,从官网的 example copy 一个下来就行
    seducer0719
        45
    seducer0719  
       2021-11-10 12:56:09 +08:00   ❤️ 1
    lz 需要的应该是这个,aws sam (Serverless Application Model) cli
    https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html
    通过一个 yaml 文件管理所有的 lambda 资源,还有 lambda layer 也可以
    CodeBase
        46
    CodeBase  
       2021-11-10 13:44:11 +08:00
    可以试试阿里云的云开发平台
    https://workbench.aliyun.com/
    liliclinton
        47
    liliclinton  
    OP
       2021-11-10 14:18:24 +08:00
    @seducer0719 看起来不错,我试试
    aliveyang
        48
    aliveyang  
       2021-11-10 16:44:33 +08:00
    什么东西到国内就变味了
    chenxiaohong
        49
    chenxiaohong  
       2021-11-11 11:22:20 +08:00
    国内合作伙伴,腾讯云
    国外合作伙伴,AWS
    Txyhwkj
        50
    Txyhwkj  
       2021-11-13 09:46:11 +08:00
    借个楼蹭个帖,腾讯云钻石代理,所有价格都比官网便宜,续费 5000 以上最高可享 6 折 5 折(不限新老用户),合作现返 25%,祝各位生活愉快 打扰了 更多优惠可以联系 Tengxunyun-Cc
    ole3021
        51
    ole3021  
       2021-11-16 14:50:34 +08:00
    大家好, 我是 Serverless 的高级产品经理 Oliver

    感谢大家对于 serverless 的热情, 我这里统一回复一下相关的问题,并解释一下我们之所以这么做的原因。

    1. 为什么要用 Serverless 而不直接使用 AWS SAM 或 AWS Fargate?

    Serverless 致力于提供跨云厂商的无服务器开发体验,我们最终的目标是让开发者无需关心云厂商的不同,以及无需配置应用集成部署流程,只需关心应用开发和用户增长。
    (目前在现阶段我们在平衡了用户使用体验与跨运厂商的功能需求后,目前重心主要在用户的使用体验,相关跨云平台的功能我们也在逐步完善)

    同时 Serverless 提供了一整套完成的 Serverless 应用开发、集成、监控、管理的产品和相关工具。例如
    * Serverless CLI 提供了用户使用本地编辑器,工具开发、调试、管理 Serverless 应用的功能。
    * Serverless CI/CD 提供了 Serverless 应用的自动集成,预览发布,部署管理等功能。
    * Serverless Secrets 提供了 Serverless 应用的密钥信息集成,管理功能。
    * Serverless Console(控制台) 提供了团队账号协同管理,Serverless 应用日志分析,异常报警等功能。
    * Serverless Cloud 提供了秒级的 Serverless 应用开发云平台,同时更加轻松的查看和分享您的 Serverless 应用。
    (以上部分功能处于开发预览阶段,如需体验请前往 Serverless 全球站点了解体验。)

    2. 为什么我被“绑定”在腾讯云,以及自动重定向到中文官网?

    我们并没有“绑定”所有的中国用户在腾讯云上,而是出于使用方便,默认将腾讯云作为为中国用户的提供 Serverless 服务的云厂商。用户依旧可以通过环境变量`SERVERLESS_PLATFORM_VENDOR=aws `来选择使用 AWS 。

    之所以这么做,是因为因为网络限制等原因,中国用户无法完整体验到 AWS 的功能,并且国内 AWS 用户数量非常少,从统计数据上大家更倾向于国内的云服务厂商,如阿里云和腾讯云。

    因为中国和全球用户提供的 Serverless 方案以及用法上的不同,以及我们需要使用中文来更好的帮助中国开发者理解使用 Serverless 工具,所以我们有专门构建 Serverless 中文官网。同时因为历史原因,中文官网与 全球官网都使用 www.serverless.com 所以我们才有的基于 IP 地址的自动重定向。

    目前已经将中文官方 迁移至 cn.serverless.com , 但是为了对老用户的兼容,所以依旧保持了 www.serverless.com 的 IP 自动重定向。 (可以通过 wb.serverless.com 来访问英文的全球官网, 再中文官网底部的交流社区下也提供了跳转链接)

    3. Serverless Framework (基于 AWS 的 serverless 解决方案)与 Tencent Serverless 是两套东西?

    首先要说明 无服务器开发 是一个一种按需提供后端服务的方法。无服务器提供者允许用户编写和部署代码,而不必担心底层基础设施。从无服务器提供商获得后端服务的公司将根据计算量来付费,由于这种服务是自动扩展的,不必预留和付费购买固定数量的带宽或服务器。

    而 Serverless Inc 是一家专注于提供开源无服务器开发解决方案的公司,我们提供了业界知名的 Serverless Framework 并且同众多云厂商进行了合作,包括 AWS ,CloudFlare , 腾讯云,并一起为广大开发者提供最佳的无服务器开发体验工具和产品。

    在腾讯云上,腾讯云有着众多的无服务器开发 产品,而目前 Serverless 主要同腾讯云一起提供了基于 Serverless Tencent ( CLI 命令行工具)和 Serverless 组件应用 ( Serverless Components )的 Serverless 开发体验。

    4. Serverless 与 腾讯云是什么关系?

    Serverless 与 腾讯云是战略合作伙伴的关系,Serverless 同 腾讯云一起通过深度定制的云厂商基础服务设施,解决了 Serverless 产品功能上面的许多局限性,比如对传统 WEB 框架( Express, django, Spring )应用的支持, 并可以更好的集成进腾讯云现有的云控制中心进行统一管理。 我们希望通过与腾讯云厂商的深度合作,来为用户带来超越 其他云厂商的 Serverless 应用开发体验。

    5. Serverless 相关功能没有询问用户,直接绕过用户,这不是**吗?

    并不是我们不询问用户,而是我们希望可以减少对用户开发的干扰,让用户可以正专注在开发和业务增长上,而不是去配置各种复杂的环境。 我们希望可以通过尽可能的自动的方式来帮助绝大多数用户解决这类困扰。

    不过我们目前也意识到有许多来自中国的用户想要使用 AWS 架构来开发 Serverless 应用,因此我们也在进行一系列的改进来支持这些用户,但因为开发人员和工作安排的关系,相关功能可能要到年底或明年年初发布上线。 以下是我们再做的相关功能:

    * www.serverless.com 网站提供显示的中英文站点切换提示,并允记录用户的选择倾向。
    * Serverless CLI 除了现有的环境变量 还会提供更方便的永久切换方式,方便用户固定使用某一个云厂商作为 Serverless 应用的基础服务供应商。

    同时我们也会在未来的产品开发过程中更加注意对于不同用户的使用体验的完善。

    欢迎大家反馈 Serverless 使用问题,以及提出改进建议, 我们会认真对待每位用户的反馈,并为中国用户带来最好的 无服务器应用开发体验。

    欢迎大家到我们的 Serverless 中文讨论区 ( https://github.com/serverless/serverless-tencent/discussions )与我们进行沟通。
    ahill
        52
    ahill  
       2022-07-08 16:31:27 +08:00
    serverless create --template aws-python3 不指定默认是腾讯
    fannas
        53
    fannas  
       2022-09-06 22:28:14 +08:00 via iPhone
    @liliclinton 所以 aws 有 cloud formation
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2864 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 14:26 · PVG 22:26 · LAX 07:26 · JFK 10:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.