mirror of
https://github.com/alibaba/higress.git
synced 2026-02-26 05:30:50 +08:00
feat: support eureka registry (#464)
Signed-off-by: charlie <qianglin98@qq.com>
This commit is contained in:
@@ -459,4 +459,109 @@ spec:
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 20
|
||||
---
|
||||
# Eureka service registry
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: eureka-cm
|
||||
namespace: higress-conformance-app-backend
|
||||
data:
|
||||
# if you want to deploy n instances of eureka cluster,
|
||||
# you should set eureka_service_address: http://eureka-0.eureka:8761/eureka,...,http://eureka-(n-1).eureka:8761/eureka
|
||||
eureka_service_address: "http://eureka-0.eureka.higress-conformance-app-backend.svc:8761/eureka"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: eureka
|
||||
namespace: higress-conformance-app-backend
|
||||
labels:
|
||||
app: eureka
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- port: 8761
|
||||
name: eureka
|
||||
selector:
|
||||
app: eureka
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: eureka
|
||||
namespace: higress-conformance-app-backend
|
||||
spec:
|
||||
serviceName: eureka
|
||||
# n instances
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: eureka
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: eureka
|
||||
spec:
|
||||
containers:
|
||||
- name: eureka
|
||||
image: bitinit/eureka
|
||||
ports:
|
||||
- containerPort: 8761
|
||||
name: http
|
||||
protocol: TCP
|
||||
resources:
|
||||
requests:
|
||||
memory: "500Mi"
|
||||
cpu: "500m"
|
||||
env:
|
||||
- name: EUREKA_SERVER_ADDRESS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: eureka-cm
|
||||
key: eureka_service_address
|
||||
- name: ENVIRONMENT
|
||||
value: "prod"
|
||||
- name: JVM_OPTS
|
||||
value: "-Xms1g -Xmx1g"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8761
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8761
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: eureka-registry-provider
|
||||
namespace: higress-conformance-app-backend
|
||||
spec:
|
||||
containers:
|
||||
- name: eureka-registry-provider
|
||||
image: charlie1380/eureka-registry-provider:v0.3.0
|
||||
env:
|
||||
- name: EUREKA_SERVER_ADDRESS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: eureka-cm
|
||||
key: eureka_service_address
|
||||
ports:
|
||||
- containerPort: 8888
|
||||
name: http
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
failureThreshold: 5
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8888
|
||||
scheme: HTTP
|
||||
periodSeconds: 1
|
||||
|
||||
|
||||
60
test/e2e/conformance/tests/httproute-eureka-registry.go
Normal file
60
test/e2e/conformance/tests/httproute-eureka-registry.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2022 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 tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/alibaba/higress/test/e2e/conformance/utils/http"
|
||||
"github.com/alibaba/higress/test/e2e/conformance/utils/suite"
|
||||
)
|
||||
|
||||
func init() {
|
||||
HigressConformanceTests = append(HigressConformanceTests, HTTPRouteEurekaRegistry)
|
||||
}
|
||||
|
||||
var HTTPRouteEurekaRegistry = suite.ConformanceTest{
|
||||
ShortName: "HTTPRouteEurekaRegistry",
|
||||
Description: "The Ingress in the higress-conformance-infra namespace uses the eureka service registry.",
|
||||
Manifests: []string{"tests/httproute-eureka-registry.yaml"},
|
||||
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
|
||||
testcases := []http.Assertion{
|
||||
{
|
||||
Request: http.AssertionRequest{
|
||||
ActualRequest: http.Request{
|
||||
Host: "foo.com",
|
||||
Path: "/healthz",
|
||||
Method: "GET",
|
||||
},
|
||||
},
|
||||
Response: http.AssertionResponse{
|
||||
ExpectedResponseNoRequest: true,
|
||||
ExpectedResponse: http.Response{
|
||||
StatusCode: 200,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
timeoutConfig := suite.TimeoutConfig
|
||||
// it may take more time
|
||||
timeoutConfig.MaxTimeToConsistency = 120 * time.Second
|
||||
t.Run("HTTPRoute Eureka Registry", func(t *testing.T) {
|
||||
for _, testcase := range testcases {
|
||||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, timeoutConfig, suite.GatewayAddress, testcase)
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
46
test/e2e/conformance/tests/httproute-eureka-registry.yaml
Normal file
46
test/e2e/conformance/tests/httproute-eureka-registry.yaml
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright (c) 2022 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.
|
||||
|
||||
apiVersion: networking.higress.io/v1
|
||||
kind: McpBridge
|
||||
metadata:
|
||||
name: default
|
||||
namespace: higress-system
|
||||
spec:
|
||||
registries:
|
||||
- domain: eureka.higress-conformance-app-backend.svc.cluster.local
|
||||
name: eureka
|
||||
port: 8761
|
||||
type: eureka
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
higress.io/destination: EUREKA-REGISTRY-PROVIDER.eureka
|
||||
name: httproute-eureka-ingress
|
||||
namespace: higress-system
|
||||
spec:
|
||||
ingressClassName: higress
|
||||
rules:
|
||||
- host: "foo.com"
|
||||
http:
|
||||
paths:
|
||||
- pathType: Prefix
|
||||
path: /
|
||||
backend:
|
||||
resource:
|
||||
apiGroup: networking.higress.io
|
||||
kind: McpBridge
|
||||
name: default
|
||||
@@ -97,6 +97,7 @@ func TestHigressConformanceTests(t *testing.T) {
|
||||
tests.HTTPRouteFullPathRegex,
|
||||
tests.HTTPRouteHttp2Rpc,
|
||||
tests.HTTPRouteConsulHttpBin,
|
||||
tests.HTTPRouteEurekaRegistry,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user