mirror of
https://github.com/alibaba/higress.git
synced 2026-03-07 18:10:54 +08:00
support custom group in httproute (#561)
This commit is contained in:
71
istio/1.12/patches/istio/20230925-gateway-httproute.patch
Normal file
71
istio/1.12/patches/istio/20230925-gateway-httproute.patch
Normal file
@@ -0,0 +1,71 @@
|
||||
diff -Naur istio/pilot/pkg/config/kube/gateway/conversion.go istio-new/pilot/pkg/config/kube/gateway/conversion.go
|
||||
--- istio/pilot/pkg/config/kube/gateway/conversion.go 2023-09-25 17:26:32.000000000 +0800
|
||||
+++ istio-new/pilot/pkg/config/kube/gateway/conversion.go 2023-09-25 17:25:27.000000000 +0800
|
||||
@@ -656,6 +656,16 @@
|
||||
Port: &istio.PortSelector{Number: uint32(*to.Port)},
|
||||
}, nil
|
||||
}
|
||||
+ if equal((*string)(to.Group), "networking.higress.io") && nilOrEqual((*string)(to.Kind), "Service") {
|
||||
+ var port *istio.PortSelector
|
||||
+ if to.Port != nil {
|
||||
+ port = &istio.PortSelector{Number: uint32(*to.Port)}
|
||||
+ }
|
||||
+ return &istio.Destination{
|
||||
+ Host: string(to.Name),
|
||||
+ Port: port,
|
||||
+ }, nil
|
||||
+ }
|
||||
return nil, &ConfigError{
|
||||
Reason: InvalidDestination,
|
||||
Message: fmt.Sprintf("referencing unsupported backendRef: group %q kind %q", emptyIfNil((*string)(to.Group)), emptyIfNil((*string)(to.Kind))),
|
||||
@@ -912,7 +922,7 @@
|
||||
ObservedGeneration: obj.Generation,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
Reason: string(k8s.GatewayClassConditionStatusAccepted),
|
||||
- Message: "Handled by Istio controller",
|
||||
+ Message: "Handled by Higress controller",
|
||||
})
|
||||
return gcs
|
||||
})
|
||||
@@ -1371,6 +1381,10 @@
|
||||
return d
|
||||
}
|
||||
|
||||
+func equal(have *string, expected string) bool {
|
||||
+ return have != nil && *have == expected
|
||||
+}
|
||||
+
|
||||
func nilOrEqual(have *string, expected string) bool {
|
||||
return have == nil || *have == expected
|
||||
}
|
||||
diff -Naur istio/pilot/pkg/leaderelection/leaderelection.go istio-new/pilot/pkg/leaderelection/leaderelection.go
|
||||
--- istio/pilot/pkg/leaderelection/leaderelection.go 2023-09-25 17:26:31.000000000 +0800
|
||||
+++ istio-new/pilot/pkg/leaderelection/leaderelection.go 2023-09-25 14:59:39.000000000 +0800
|
||||
@@ -35,20 +35,20 @@
|
||||
|
||||
// Various locks used throughout the code
|
||||
const (
|
||||
- NamespaceController = "istio-namespace-controller-election"
|
||||
- ServiceExportController = "istio-serviceexport-controller-election"
|
||||
+ NamespaceController = "higress-namespace-controller-election"
|
||||
+ ServiceExportController = "higress-serviceexport-controller-election"
|
||||
// This holds the legacy name to not conflict with older control plane deployments which are just
|
||||
// doing the ingress syncing.
|
||||
- IngressController = "istio-leader"
|
||||
+ IngressController = "higress-leader"
|
||||
// GatewayStatusController controls the status of gateway.networking.k8s.io objects. For the v1alpha1
|
||||
// this was formally "istio-gateway-leader"; because they are a different API group we need a different
|
||||
// election to ensure we do not only handle one or the other.
|
||||
- GatewayStatusController = "istio-gateway-status-leader"
|
||||
+ GatewayStatusController = "higress-gateway-status-leader"
|
||||
// GatewayDeploymentController controls the Deployment/Service generation from Gateways. This is
|
||||
// separate from GatewayStatusController to allow running in a separate process (for low priv).
|
||||
- GatewayDeploymentController = "istio-gateway-deployment-leader"
|
||||
- StatusController = "istio-status-leader"
|
||||
- AnalyzeController = "istio-analyze-leader"
|
||||
+ GatewayDeploymentController = "higress-gateway-deployment-leader"
|
||||
+ StatusController = "higress-status-leader"
|
||||
+ AnalyzeController = "higress-analyze-leader"
|
||||
)
|
||||
|
||||
var ClusterScopedNamespaceController = NamespaceController
|
||||
55
samples/gateway-api/demo.yaml
Normal file
55
samples/gateway-api/demo.yaml
Normal file
@@ -0,0 +1,55 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: GatewayClass
|
||||
metadata:
|
||||
name: higress-gateway
|
||||
spec:
|
||||
controllerName: "higress.io/gateway-controller"
|
||||
---
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: higress-gateway
|
||||
namespace: higress-system
|
||||
spec:
|
||||
gatewayClassName: higress-gateway
|
||||
listeners:
|
||||
- name: default
|
||||
hostname: "*.gateway-api.com"
|
||||
port: 80
|
||||
protocol: HTTP
|
||||
allowedRoutes:
|
||||
namespaces:
|
||||
from: All
|
||||
---
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: http
|
||||
namespace: default
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: higress-gateway
|
||||
namespace: higress-system
|
||||
hostnames: ["www.gateway-api.com"]
|
||||
rules:
|
||||
- matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: /
|
||||
filters:
|
||||
- type: RequestHeaderModifier
|
||||
requestHeaderModifier:
|
||||
add:
|
||||
- name: my-added-header
|
||||
value: added-value-higress
|
||||
backendRefs:
|
||||
- name: foo-service
|
||||
port: 5678
|
||||
- matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: /by-nacos
|
||||
backendRefs:
|
||||
- name: service-provider.DEFAULT-GROUP.public.nacos
|
||||
group: networking.higress.io
|
||||
|
||||
Reference in New Issue
Block a user