-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【GLCC】Higress Console 支持 Gateway API #371
base: main
Are you sure you want to change the base?
Conversation
…ly with PMD rules and lowerCamelCase naming conventions
Refactor: modify codestyle
Refactor: modify codestyle and change code level Refactor: modify codestyle and change code level
@iendi 有一些文件冲突了,麻烦更新一下 |
冲突已解决 |
backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigService.java
Outdated
Show resolved
Hide resolved
throw new BusinessException("Error occurs when adding a new domain.", e); | ||
} | ||
return kubernetesModelConverter.configMap2Domain(newDomainConfigMap); | ||
DomainStrategy strategy = getStrategy(domain); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether it is possible to make a unified context judgment between controller and service instead of coupling to business service for policy pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or abstract a layer of Service Proxy layer is also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this design feasible?
-
create
DomainServiceProxy
:@Service public class DomainServiceProxy { private final IngressDomainService ingressDomainService; private final GatewayDomainService gatewayDomainService; public DomainServiceProxy(IngressDomainService ingressDomainService, GatewayDomainService gatewayDomainService) { this.ingressDomainService = ingressDomainService; this.gatewayDomainService = gatewayDomainService; } public Domain add(Domain domain) { return getDomainService(domain.getIsIngressMode()).add(domain); } private DomainService getDomainService(boolean isIngressMode) { return isIngressMode ? ingressDomainService : gatewayDomainService; } }
-
Split
DomainServiceImpl
intoIngressDomainServiceImpl
andGatewayDomainServiceImpl
based on business logic.@Service public class IngressDomainServiceImpl implements DomainService { // implementation for Ingress } @Service public class GatewayDomainService implements DomainService { // implementation for Gateway }
-
Controller:
public class DomainsController { @Resource private DomainServiceProxy domainServiceProxy; @PostMapping public ResponseEntity<Response<Domain>> add(@RequestBody Domain domain) { return ControllerUtil.buildResponseEntity(domainServiceProxy.add(domain)); } }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This optimization can be submitted in a separate PR later
backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java
Show resolved
Hide resolved
backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java
Show resolved
Hide resolved
...d/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java
Show resolved
Hide resolved
…ated GatewayName naming convention, added @OverRide annotations, and implemented NPE checks for improved reliability.
@iendi Please fix the CI |
Ⅰ. Describe what this PR did
本 PR 是GLCC活动#1042的实现,实现了资源管理、路由配置、前端适配以及单元测试等核心功能。具体包括:完成 CRD 模型创建与初始化、域名到网关的映射配置、支持多端口证书配置、路由策略与插件适配,以及前端的工作模式切换与域名路由功能适配。同时,单元测试覆盖率达到 92%,确保了配置转换逻辑的正确性。
Ⅱ. 整体进度
[√]启动console时,初始化gtw class,读取网关模式
[√]修改域名定义,支持不同端口配置不同证书
[√]增加域名端口时,同时修改higress-gateway的service的ports字段 #896
[√]重写、重定向等策略的适配
[√]域名级插件适配
[√]路由级插件适配
[√]域名部分适配
[√]路由部分适配
[√]支持openapi导入时指定域名级或路由级插件
Ⅲ. 结果
工作模式配置
允许用户自行设置使用ingress或者是gatewayapi的工作模式,入口在右上角-个人信息-工作模式配置
当工作模式切换后,新建域名或者路由时,默认采用的都是当前的工作模式
域名
规则如下
不允许重复的端口
ingress模式下,只允许选择80端口(HTTP)和443端口(HTTPS)
当同时有80端口(HTTP)和443端口(HTTPS)启动时,显示是否强制HTTPS选项
路由
当路由为httproute时,允许选择后端服务的权重:
路由显示时,会根据权重显示流量分配的百分比:
特殊情况处理
考虑到下面两个特殊情况:
处理方法如下:
创建一个对应的 Gateway CR。
将 ConfigMap 中该域名的工作模式由 ingress 类型改为 gateway 类型。
判断域名是否开启了 80 端口(HTTP):
更新gatewayapi 类型的域名时 :
Ⅳ. 备注
目前
Route
中有些注解httproute
cr中并未有对应的参数进行转换,因此我先在httproute中直接添加相应注解,如下表所示higress.io/ignore-path-case
higress.io/cors-expose-headers
higress.io/enable-proxy-next-upstream
higress.io/ssl-redirect
https