Skip to content
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

Merged
merged 33 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b934835
add gatewayapi crd models
iendi Aug 23, 2024
13a68f7
add gatewayclass init & workmode init
iendi Aug 23, 2024
c7b0df1
modify domain model to multi-certs
iendi Aug 23, 2024
9f43da6
refine gatewayapi crd model definitions
iendi Aug 24, 2024
f4ba777
support gateway functions; modify the service port accordingly
iendi Aug 24, 2024
f94c4c6
Refactor: Add comments to enum constants and rename variables to comp…
iendi Sep 2, 2024
2e18b4b
Refactor: modify codestyle of modelConverter and clientService
iendi Sep 2, 2024
058874f
Refactor: modify codestyle and add license
iendi Sep 2, 2024
07f7b1e
refactor: when domain is related to a ingress, only update the configmap
iendi Oct 16, 2024
3f4a56d
feat: add httproute functions
iendi Oct 16, 2024
ba61e19
test: add unit test case for gateway and httproute converter
iendi Oct 16, 2024
c8cbc02
feat: translate openapi specification to higress domain&route
iendi Oct 16, 2024
0ca75c8
feat: add frontend code
iendi Nov 8, 2024
087988c
fix: change frontend page name
iendi Nov 8, 2024
fe26b08
Merge branch 'main' of origin into feat4
iendi Nov 8, 2024
07711d9
fix: support route(ingress cr) with a domain(gateway cr)
iendi Nov 8, 2024
e285af8
refactor: apply strategy pattern to RouteService and DomainService
iendi Nov 18, 2024
a6fe9f5
fix: resolve bug in domain of OAS conversion
iendi Nov 19, 2024
22a6128
Merge branch 'higress-group:main' into feat4
iendi Nov 19, 2024
45fc7d5
fix: add default label to gateway & httproute
iendi Nov 20, 2024
5338414
fix: resolve bug in httproute rewrite path
iendi Nov 20, 2024
3310075
Resolve merge conflict
iendi Dec 18, 2024
a89cc7f
Resolve merge conflict
iendi Dec 18, 2024
7b1b43a
Merge branch 'main' into feat4
iendi Dec 23, 2024
55f5ffb
feat: add alpha warning for gatewayapi integration
iendi Dec 23, 2024
a423477
fix: refined interface method names for clear business semantics, upd…
iendi Dec 31, 2024
ad7478a
Merge branch 'main' into feat4
johnlanni Jan 2, 2025
e0b6fbc
fix: refactor unit test about gateway name
iendi Jan 2, 2025
6c70c58
Merge branch 'main' into feat4
iendi Jan 4, 2025
4b76804
Resolve merge conflict
iendi Jan 6, 2025
1a674ef
Merge remote-tracking branch 'upstream/main' into feat4
iendi Jan 6, 2025
c72c538
Resolve duplicate import
iendi Jan 6, 2025
03f89b4
fix: restore overwritten yarn.lock file
iendi Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import javax.annotation.PostConstruct;

import com.alibaba.higress.sdk.service.OpenAPIService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -36,6 +37,7 @@
import com.alibaba.higress.sdk.service.consumer.ConsumerService;
import com.alibaba.higress.sdk.service.kubernetes.KubernetesClientService;
import com.alibaba.higress.sdk.service.kubernetes.KubernetesModelConverter;
import com.alibaba.higress.sdk.service.HigressConfigService;

@Configuration
public class SdkConfig {
Expand Down Expand Up @@ -129,6 +131,15 @@ public WasmPluginInstanceService wasmPluginInstanceService() {
return serviceProvider.wasmPluginInstanceService();
}

@Bean
public OpenAPIService openApiService() {
return serviceProvider.openApiService();
}

@Bean
public HigressConfigService higressConfigService() {
return serviceProvider.higressConfigService();
}
@Bean
public ConsumerService consumerService() {
return serviceProvider.consumerService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import com.alibaba.higress.sdk.service.RouteService;

@RestController("DomainsController")
@RequestMapping("/v1/domains")
@RequestMapping("/v2/domains")
@Validated
public class DomainsController {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.alibaba.higress.console.controller;

import com.alibaba.higress.sdk.service.HigressConfigService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController("HigressController")
@RequestMapping("/v1/workmode")
@Validated
public class HigressConfigController {
@Resource
HigressConfigService higressConfigService;

@GetMapping
public Boolean getWorkMode() {
return higressConfigService.getWorkMode();
}

@PutMapping
public Boolean updateWorkMode(@RequestParam Boolean mode) {
return higressConfigService.putWorkMode(mode);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.alibaba.higress.console.controller;

import com.alibaba.higress.console.controller.dto.Response;
import com.alibaba.higress.console.controller.util.ControllerUtil;
import com.alibaba.higress.sdk.model.OpenAPISpecification;
import com.alibaba.higress.sdk.service.OpenAPIService;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController("OpenAPIController")
@RequestMapping("/v1/openapi")
@Validated
public class OpenAPIController {
@Resource
private OpenAPIService openApiService;

@PostMapping
public ResponseEntity<Response<OpenAPISpecification>> add(@RequestBody OpenAPISpecification oas) {
return ControllerUtil.buildResponseEntity(openApiService.add(oas));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ private void initDefaultRoutes() {
Domain domain = new Domain();
domain.setName(HigressConstants.DEFAULT_DOMAIN);
domain.setEnableHttps(Domain.EnableHttps.ON);
domain.setCertIdentifier(DEFAULT_TLS_CERTIFICATE_NAME);
Map<Integer, String> portAndCert = new HashMap<>();
portAndCert.put(443, DEFAULT_TLS_CERTIFICATE_NAME);
domain.setPortAndCertMap(portAndCert);
domainService.add(domain);
} catch (ResourceConflictException e) {
// Ignore it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public class HigressConstants {
public static final String INTERNAL_RESOURCE_NAME_SUFFIX = ".internal";
public static final String FALLBACK_ROUTE_NAME_SUFFIX = ".fallback";
public static final String FALLBACK_FROM_HEADER = "x-higress-fallback-from";
public static final String DEFAULT_CONFIG = "higress-config";
public static final String PORT_CONFIG = "higress-ports";
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public class KubernetesConstants {
public static final String SECRET_TLS_KEY_FIELD = "tls.key";
public static final String YAML_SEPARATOR = "---\n";

public static class WorkMode {
public static final String KEY = "workMode";
public static final String GATEWAY = "gateway";
public static final String INGRESS = "ingress";
}



public static class Annotation {
public static final String KEY_PREFIX = "higress.io/";
public static final String NGINX_INGRESS_KEY_PREFIX = "nginx.ingress.kubernetes.io/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ public class Separators {
public static final String UNDERSCORE = "_";

public static final String COLON = ":";

public static final String SLASH = "/";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@Builder
@NoArgsConstructor
Expand All @@ -30,12 +32,13 @@ public static class EnableHttps {
public static final String ON = "on";
public static final String FORCE = "force";
}
private Boolean isIngressMode;

private String name;

private String version;

private String enableHttps;

private String certIdentifier;
private Map<Integer, String> portAndCertMap;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package com.alibaba.higress.sdk.model;

import com.alibaba.higress.sdk.model.openapi.OpenAPIComponents;
import com.alibaba.higress.sdk.model.openapi.OpenAPIInfo;
import com.alibaba.higress.sdk.model.openapi.OpenAPIPathDescription;
import com.alibaba.higress.sdk.model.openapi.OpenAPIServer;
import com.alibaba.higress.sdk.model.openapi.OpenAPITag;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("OpenAPI")
public class OpenAPISpecification {
private String openapi;
private OpenAPIInfo info;
private List<OpenAPIServer> servers;
private Map<String, OpenAPIPathDescription> paths;
private List<OpenAPIComponents> components;
private List<OpenAPITag> tags;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class Route implements VersionedDto {

private String name;

private Boolean isIngressMode;

private String version;

private List<String> domains;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.alibaba.higress.sdk.model.openapi;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OpenAPIComponents {
private Map<String, OpenAPISchema> schemas;
private Map<String, OpenAPIResponse> responses;
private Map<String, OpenAPIParameter> parameters;
private Map<String, OpenAPIRequestBody> requestBodies;
private Map<String, Object> extensions;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.alibaba.higress.sdk.model.openapi;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OpenAPIContactDetails {
private String name;
private String url;
private String email;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.alibaba.higress.sdk.model.openapi;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OpenAPIEncoding {
private String contentType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.alibaba.higress.sdk.model.openapi;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OpenAPIExternalDocs {
private String description;
private String url;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2022-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.alibaba.higress.sdk.model.openapi;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OpenAPIInfo {
private String title;
private String description;
private OpenAPIContactDetails contact;
private OpenAPILicense license;
private String version;
}
Loading
Loading