云原生网关部署新范式丨 Higress 发布 1.1 版本,支持脱离 K8s 部署

作者:澄潭

版本特性

Higress 1.1.0 版本已经 Release,K8s 环境下可以使用以下命令将 Higress 升级到最新版本:

kubectl apply -f https://github.com/alibaba/higress/releases/download/v1.1.0/customresourcedefinitions.gen.yaml
helm repo update
helm upgrade higress -n higress-system higress.io/higress

下面介绍该版本的核心特性:

支持非 K8s 部署

在 K8s 部署模式下,Higress 已经支持基于 Nacos 进行服务发现,可以打通 Spring Cloud/Dubbo 等微服务生态。Nacos 作为微服务生态的集大成者,既可以作为注册中心,又可以作为配置中心,在非 K8s 环境下,如果将路由、插件等配置存入 Nacos 中,用户只需一个 Higress 和一个 Nacos 即可搞定一切:

image

在 1.1 版本中,Higress 就实现了这个能力,如上图所示,在这个架构中,Nacos 同时可以作为路由配置来源和服务 IP 来源,因为在 Nacos 中存储路由配置也是用了 Ingress API 这套基础 API 抽象,目前 Higress 在 K8s 上可以实现的能力,基于这套架构一样可以搞定。

使用一行命令即可完成非 K8s 环境下的部署(兼容 macOS 和 Linux,Windows 需要安装 Cygwin):

curl -fsSL https://higress.io/standalone/get-higress.sh | bash -s -- -c nacos://<nacos_addr>:8848

-c 参数用于指定非 K8s 场景下的配置存储来源,以 Nacos 为例,通过 nacos:// 指定即可,这种模式下,Higress 的所有配置都将存储在 Nacos 中,后续还将支持 ETCD/Consul等配置来源。

更多的参数可以通过 -h 参数查看,具体如下:

Usage: bash [DIR] [OPTIONS...]
Install Higress (standalone version) into the DIR (the current directory by default).

 -c, --config-url=URL       URL of the Nacos service
                            format: nacos://192.168.0.1:8848
     --use-builtin-nacos    use the built-in Nacos service instead of
                            an external one
     --nacos-ns=NACOS-NAMESPACE
                            the ID of Nacos namespace to store configurations
                            default to "higress-system" if unspecified
     --nacos-username=NACOS-USERNAME
                            the username used to access Nacos
                            only needed if auth is enabled in Nacos
     --nacos-password=NACOS-PASSWORD
                            the password used to access Nacos
                            only needed if auth is enabled in Nacos
 -k, --data-enc-key=KEY     the key used to encrypt sensitive configurations
                            MUST contain 32 characters
                            A random key will be generated if unspecified
 -p, --console-password=CONSOLE-PASSWORD
                            the password to be used to visit Higress Console
                            default to "admin" if unspecified
 -h, --help                 give this help list

启动成功后,本机端口占用情况如下:

  • 80 端口:Higress Gateway 暴露,用于 HTTP 协议代理
  • 443 端口:Higress Gateway 暴露,用于 HTTPS 协议代理
  • 15020 端口:Higress Gateway 暴露,用于暴露 Prometheus 指标  (http://node_ip:15020/stats/prometheus)
  • 8080 端口:Higress Console 暴露,用于 Higress 控制台管理

让我们在本地启动一个 SpringCloud 服务注册到这个 Nacos 上:

image.png

在 Higress 控制台的服务列表也可以看到这个服务(Higress 默认配置监听启动参数指定的 Nacos 的 public 命名空间,可以在服务来源中新增其他命名空间):

image.png

创建路由指向这个服务:

image.png

测试路由成功:

image

Http to Dubbo 配置简化

在之前的版本里,使用 Http to Dubbo 的能力,需要开启 Istio CRD,然后通过 Envoyfilter 进行配置;新版本 Higress 增加了 Http2Rpc 这个 CRD,实现了 Http to Dubbo 的配置简化。

假设我们现在已经部署了如下一个 Dubbo 服务,其服务名为com.alibaba.nacos.example.dubbo.service.DemoService,并指定了该服务的 version 为“1.0.0”,group 为“dev”:

interface:

package com.alibaba.nacos.example.dubbo.service;

public interface DemoService {
    String sayName(String name);
}

implement:

@DubboService(version = "${demo.service.version}", group = "${demo.service.group}")
public class DefaultService implements DemoService {

    @Value("${demo.service.name}")
    private String serviceName;

    public String sayName(String name) {
        RpcContext rpcContext = RpcContext.getContext();
        return String.format("Service [name :%s , port : %d] %s("%s") : Hello,%s",
                serviceName,
                rpcContext.getLocalPort(),
                rpcContext.getMethodName(),
                name,
                name);
    }
}

创建 Http2Rpc CRD

apiVersion: networking.higress.io/v1
kind: Http2Rpc
metadata:
  name: httproute-http2rpc-demo
  namespace: higress-system
spec:
  dubbo: 
    service: com.alibaba.nacos.example.dubbo.service.DemoService
    version: 1.0.0
    group: dev
    methods: 
    - serviceMethod: sayName
      headersAttach: "*"
      httpMethods: 
      - "GET"
      httpPath: "/dubbo/sayName"
      params:
      - paramKey: name
        paramSource: QUERY
        paramType: "java.lang.String"

创建 Ingress 关联 Http2Rpc

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    higress.io/destination: providers:com.alibaba.nacos.example.dubbo.service.DemoService:1.0.0:dev.DEFAULT-GROUP.public.nacos
    higress.io/rpc-destination-name: httproute-http2rpc-demo
  name: httproute-http2rpc-demo-ingress
  namespace: higress-system
spec:
  ingressClassName: higress
  rules:
  - http:
      paths:
      - backend:
          resource:
            apiGroup: networking.higress.io
            kind: McpBridge
            name: default
        path: /dubbo
        pathType: Prefix

通过以上配置,我们就可以执行以下 curl 命令来调用这个 dubbo 服务了:

$curl "localhost/dubbo/sayName?name=abc" 

{"result":"Service [name :demoService , port : 20880] sayName("abc") : Hello,abc"}

支持 SkyWalking Tracing 配置

对 Higress 的全局配置 ConfigMap 对象 higress-config 做如下配置即可开启 SkyWalking Tracing:

apiVersion: v1
data:
  higress: |-
    tracing:
      enable: true
      sampling: 100
      timeout: 500
      skywalking:
       service: skywalking-oap-server.op-system.svc.cluster.local
       port: 11800
...
...
kind: ConfigMap
metadata:
  name: higress-config
  namespace: higress-system

调用链路:

image.png

调用链路拓扑:

image.png

后续版本 Roadmap

目前确定的后续版本核心功能如下,欢迎在:https://github.com/alibaba/higress/issues/425 下提出你期待的功能,我们将实时更新后续 Roadmap。

image.png

社区近期活动

Wasm 插件编程挑战赛,赢取 12w 奖金池

image.png

image

image

了解详情:https://tianchi.aliyun.com/competition/entrance/532104/information

参与 HigressOps 夏季营

image

2023 年需求最大的 8 种编程语言:PHP 强劲,C/C++ 需求放缓 马斯克宣布 Twitter 将改名为 X,并更换 Logo 历时五年,Cython 3.0 正式发布 GPT-4 越来越笨?准确率从 97.6% 降至 2.4% MySQL 8.1 及 MySQL 8.0.34 正式发布 C# 和 TypeScript 之父宣布最新开源项目:TypeChat Meta 放大招:发布开源大语言模型 Llama 2,可免费商用 力不从心,React 核心开发者 Dan Abramov 宣布从 Meta 离职 ChatGPT for Android 将于下周上线,现在开始预注册 不想搬砖,又想完成需求?也许这个 5k 星的 GitHub 开源项目能帮上忙 - MetaGPT
{{o.name}}
{{m.name}}

猜你喜欢

转载自my.oschina.net/u/3874284/blog/10090312