This is an automated email from the ASF dual-hosted git repository.
mfordjody pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 8f532fae Delete meshservice and update resource (#926)
8f532fae is described below
commit 8f532faedcb87237a77a702549c9fe54f8273d5f
Author: mfordjody <[email protected]>
AuthorDate: Sun Jun 28 11:17:29 2026 +0800
Delete meshservice and update resource (#926)
---
dubbod/discovery/cmd/app/xds_client.go | 188 ++++++++--
dubbod/discovery/cmd/app/xds_client_test.go | 114 ++++++
dubbod/discovery/pkg/bootstrap/gui.go | 7 -
.../pkg/bootstrap/proxyless_grpc_controller.go | 2 +-
.../bootstrap/proxyless_grpc_controller_test.go | 55 +--
dubbod/discovery/pkg/bootstrap/server.go | 7 +-
.../discovery/pkg/bootstrap/service_controller.go | 2 +-
.../pkg/config/kube/crdclient/types.gen.go | 53 ---
dubbod/discovery/pkg/features/experimental.go | 2 +-
dubbod/discovery/pkg/model/meshservice.go | 271 -------------
dubbod/discovery/pkg/model/meshservice_test.go | 196 ----------
dubbod/discovery/pkg/model/push_context.go | 106 ------
dubbod/discovery/pkg/model/push_context_test.go | 2 +-
.../discovery/pkg/networking/grpcgen/mtls_test.go | 61 ---
dubbod/discovery/pkg/networking/grpcgen/rds.go | 243 +++---------
.../discovery/pkg/networking/grpcgen/rds_test.go | 177 ++++-----
.../serviceregistry/kube/controller/controller.go | 26 +-
.../kube/controller/multicluster.go | 10 +-
dubbod/discovery/pkg/xds/cds.go | 12 +-
dubbod/discovery/pkg/xds/eds_test.go | 4 +-
.../pkg/xds/endpoints/endpoint_builder_test.go | 53 ---
dubbod/discovery/pkg/xds/pushqueue_test.go | 2 +-
dubbod/gui/resources/data/app.js | 2 +-
manifests/charts/base/files/crd-all.gen.yaml | 417 ---------------------
manifests/charts/dubbod/templates/clusterrole.yaml | 2 +-
.../templates/validatingwebhookconfiguration.yaml | 1 -
.../schema/codegen/templates/clients.go.tmpl | 1 -
.../schema/codegen/templates/crdclient.go.tmpl | 1 -
pkg/config/schema/codegen/templates/types.go.tmpl | 1 -
pkg/config/schema/collections/collections.gen.go | 20 -
pkg/config/schema/gvk/resources.gen.go | 7 -
pkg/config/schema/gvr/resources.gen.go | 3 -
pkg/config/schema/kind/resources.gen.go | 5 -
pkg/config/schema/kubeclient/resources.gen.go | 14 -
pkg/config/schema/kubetypes/resources.gen.go | 6 -
pkg/config/schema/metadata.yaml | 9 -
samples/app/{meshservice.yaml => httproute.yaml} | 33 +-
samples/moviereview/deployment.yaml | 80 +++-
38 files changed, 515 insertions(+), 1680 deletions(-)
diff --git a/dubbod/discovery/cmd/app/xds_client.go
b/dubbod/discovery/cmd/app/xds_client.go
index 1da11637..57443df1 100644
--- a/dubbod/discovery/cmd/app/xds_client.go
+++ b/dubbod/discovery/cmd/app/xds_client.go
@@ -24,6 +24,7 @@ import (
"net"
"net/http"
"os"
+ "regexp"
"sort"
"strconv"
"strings"
@@ -56,6 +57,9 @@ import (
type xdsClientOptions struct {
host string
port int
+ path string
+ headers []string
+ requestHeaders http.Header
target string
xdsAddress string
bootstrapPath string
@@ -100,12 +104,14 @@ type xdsRouteSnapshot struct {
}
type sampleADSClient struct {
- conn *grpc.ClientConn
- stream
discovery.AggregatedDiscoveryService_StreamAggregatedResourcesClient
- node *corev1.Node
- target string
- host string
- port int
+ conn *grpc.ClientConn
+ stream
discovery.AggregatedDiscoveryService_StreamAggregatedResourcesClient
+ node *corev1.Node
+ target string
+ host string
+ port int
+ path string
+ requestHeaders http.Header
mu sync.RWMutex
subs map[string][]string
@@ -126,6 +132,7 @@ func newXClientCommand() *cobra.Command {
opts := &xdsClientOptions{
host: firstNonEmpty(os.Getenv("DUBBO_SERVICE_HOST"),
host),
port: firstIntFromEnv(int(port),
"DUBBO_SERVICE_PORT"),
+ path: firstNonEmpty(os.Getenv("REQUEST_PATH"), "/"),
xdsAddress: firstNonEmpty(os.Getenv("XDS_ADDRESS"),
"dubbod.dubbo-system.svc:26010"),
bootstrapPath: os.Getenv("GRPC_XDS_BOOTSTRAP"),
namespace: namespace,
@@ -164,6 +171,8 @@ func newXClientCommand() *cobra.Command {
}
c.Flags().StringVar(&opts.host, "host", opts.host, "service DNS name to
call")
c.Flags().IntVar(&opts.port, "port", opts.port, "service port to call")
+ c.Flags().StringVar(&opts.path, "path", opts.path, "HTTP request path")
+ c.Flags().StringArrayVar(&opts.headers, "header", nil, "HTTP request
header in key=value form; may be repeated")
c.Flags().StringVar(&opts.target, "target", opts.target, "xDS LDS
target; defaults to host:port")
c.Flags().StringVar(&opts.xdsAddress, "xds-address", opts.xdsAddress,
"ADS server address used when no bootstrap file is present")
c.Flags().StringVar(&opts.bootstrapPath, "bootstrap",
opts.bootstrapPath, "gRPC xDS bootstrap file")
@@ -191,6 +200,12 @@ func (o *xdsClientOptions) run(ctx context.Context) error {
if o.target == "" {
o.target = net.JoinHostPort(o.host, strconv.Itoa(o.port))
}
+ o.path = normalizeRequestPath(o.path)
+ requestHeaders, err := parseRequestHeaders(o.headers)
+ if err != nil {
+ return err
+ }
+ o.requestHeaders = requestHeaders
expected, err := parseExpectedWeights(o.expect)
if err != nil {
return err
@@ -240,19 +255,21 @@ func newSampleADSClient(ctx context.Context, opts
*xdsClientOptions) (*sampleADS
return nil, fmt.Errorf("open ADS stream: %w", err)
}
return &sampleADSClient{
- conn: conn,
- stream: stream,
- node: node,
- target: opts.target,
- host: opts.host,
- port: opts.port,
- subs: map[string][]string{},
- route: map[string]uint32{},
- endpoints: map[string][]xdsEndpoint{},
- clusterTLS: map[string]*tlsv1.UpstreamTlsContext{},
- updates: make(chan struct{}, 1),
- errs: make(chan error, 1),
- bootstrapPath: opts.bootstrapPath,
+ conn: conn,
+ stream: stream,
+ node: node,
+ target: opts.target,
+ host: opts.host,
+ port: opts.port,
+ path: opts.path,
+ requestHeaders: opts.requestHeaders,
+ subs: map[string][]string{},
+ route: map[string]uint32{},
+ endpoints: map[string][]xdsEndpoint{},
+ clusterTLS: map[string]*tlsv1.UpstreamTlsContext{},
+ updates: make(chan struct{}, 1),
+ errs: make(chan error, 1),
+ bootstrapPath: opts.bootstrapPath,
}, nil
}
@@ -408,7 +425,7 @@ func (c *sampleADSClient) handleResponse(resp
*discovery.DiscoveryResponse) erro
return c.subscribe(v1.RouteType, routeNames)
}
case v1.RouteType:
- weights, clusters, err := routeWeightsFromRoutes(resp.Resources)
+ weights, clusters, err :=
routeWeightsFromRoutes(resp.Resources, c.path, c.requestHeaders)
if err != nil {
return err
}
@@ -547,7 +564,7 @@ func routeNamesFromListeners(resources []*anypb.Any)
([]string, error) {
return sortedUnique(out), nil
}
-func routeWeightsFromRoutes(resources []*anypb.Any) (map[string]uint32,
[]string, error) {
+func routeWeightsFromRoutes(resources []*anypb.Any, requestPath string,
requestHeaders http.Header) (map[string]uint32, []string, error) {
weights := map[string]uint32{}
for _, resource := range resources {
rc := &routev1.RouteConfiguration{}
@@ -556,33 +573,95 @@ func routeWeightsFromRoutes(resources []*anypb.Any)
(map[string]uint32, []string
}
for _, vh := range rc.GetVirtualHosts() {
for _, rt := range vh.GetRoutes() {
- action := rt.GetRoute()
- if action == nil {
+ if !routeMatchesRequest(rt.GetMatch(),
requestPath, requestHeaders) {
continue
}
- if clusterName := action.GetCluster();
clusterName != "" {
- weights[clusterName] += 1
- }
- if weighted := action.GetWeightedClusters();
weighted != nil {
- for _, clusterWeight := range
weighted.GetClusters() {
- if clusterWeight.GetName() ==
"" {
- continue
- }
- weight := uint32(1)
- if clusterWeight.GetWeight() !=
nil {
- weight =
clusterWeight.GetWeight().GetValue()
- }
-
weights[clusterWeight.GetName()] += weight
- }
- }
+ addRouteActionWeights(weights, rt.GetRoute())
+ return weights,
sortedWeightClusterNames(weights), nil
}
}
}
+ return weights, sortedWeightClusterNames(weights), nil
+}
+
+func addRouteActionWeights(weights map[string]uint32, action
*routev1.RouteAction) {
+ if action == nil {
+ return
+ }
+ if clusterName := action.GetCluster(); clusterName != "" {
+ weights[clusterName] += 1
+ }
+ if weighted := action.GetWeightedClusters(); weighted != nil {
+ for _, clusterWeight := range weighted.GetClusters() {
+ if clusterWeight.GetName() == "" {
+ continue
+ }
+ weight := uint32(1)
+ if clusterWeight.GetWeight() != nil {
+ weight = clusterWeight.GetWeight().GetValue()
+ }
+ weights[clusterWeight.GetName()] += weight
+ }
+ }
+}
+
+func sortedWeightClusterNames(weights map[string]uint32) []string {
clusters := make([]string, 0, len(weights))
for clusterName := range weights {
clusters = append(clusters, clusterName)
}
- return weights, sortedUnique(clusters), nil
+ return sortedUnique(clusters)
+}
+
+func routeMatchesRequest(match *routev1.RouteMatch, requestPath string,
requestHeaders http.Header) bool {
+ if match == nil {
+ return true
+ }
+ switch spec := match.PathSpecifier.(type) {
+ case *routev1.RouteMatch_Path:
+ if requestPath != spec.Path {
+ return false
+ }
+ case *routev1.RouteMatch_Prefix:
+ if !strings.HasPrefix(requestPath, spec.Prefix) {
+ return false
+ }
+ case *routev1.RouteMatch_SafeRegex:
+ if spec.SafeRegex == nil {
+ return false
+ }
+ ok, err := regexp.MatchString(spec.SafeRegex.Regex, requestPath)
+ if err != nil || !ok {
+ return false
+ }
+ }
+ for _, header := range match.GetHeaders() {
+ if !headerMatchesRequest(header, requestHeaders) {
+ return false
+ }
+ }
+ return true
+}
+
+func headerMatchesRequest(match *routev1.HeaderMatcher, requestHeaders
http.Header) bool {
+ if match == nil {
+ return true
+ }
+ value := requestHeaders.Get(match.GetName())
+ switch spec := match.HeaderMatchSpecifier.(type) {
+ case *routev1.HeaderMatcher_ExactMatch:
+ return value == spec.ExactMatch
+ case *routev1.HeaderMatcher_PrefixMatch:
+ return strings.HasPrefix(value, spec.PrefixMatch)
+ case *routev1.HeaderMatcher_SafeRegexMatch:
+ if spec.SafeRegexMatch == nil {
+ return false
+ }
+ ok, err := regexp.MatchString(spec.SafeRegexMatch.Regex, value)
+ return err == nil && ok
+ default:
+ return value != ""
+ }
}
func edsNamesAndTLSFromClusters(resources []*anypb.Any) ([]string,
map[string]*tlsv1.UpstreamTlsContext, error) {
@@ -697,11 +776,16 @@ func runSampleRequests(ctx context.Context, adsClient
*sampleADSClient, snapshot
return err
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet,
- fmt.Sprintf("%s://%s/", scheme,
net.JoinHostPort(endpoint.Address, strconv.Itoa(int(endpoint.Port)))), nil)
+ fmt.Sprintf("%s://%s%s", scheme,
net.JoinHostPort(endpoint.Address, strconv.Itoa(int(endpoint.Port))),
adsClient.path), nil)
if err != nil {
return err
}
req.Host = snapshot.Host
+ for name, values := range adsClient.requestHeaders {
+ for _, value := range values {
+ req.Header.Add(name, value)
+ }
+ }
resp, err := httpClient.Do(req)
if err != nil {
return err
@@ -887,6 +971,30 @@ func parseExpectedWeights(value string)
(map[string]uint32, error) {
return out, nil
}
+func normalizeRequestPath(path string) string {
+ path = strings.TrimSpace(path)
+ if path == "" {
+ return "/"
+ }
+ if !strings.HasPrefix(path, "/") {
+ return "/" + path
+ }
+ return path
+}
+
+func parseRequestHeaders(values []string) (http.Header, error) {
+ headers := http.Header{}
+ for _, value := range values {
+ key, headerValue, ok := strings.Cut(value, "=")
+ key = strings.TrimSpace(key)
+ if !ok || key == "" {
+ return nil, fmt.Errorf("invalid --header item %q, want
key=value", value)
+ }
+ headers.Add(key, strings.TrimSpace(headerValue))
+ }
+ return headers, nil
+}
+
func subsetWeights(snapshot xdsRouteSnapshot) map[string]uint32 {
out := map[string]uint32{}
for _, dest := range snapshot.Destinations {
diff --git a/dubbod/discovery/cmd/app/xds_client_test.go
b/dubbod/discovery/cmd/app/xds_client_test.go
index 8a133f50..7b759ede 100644
--- a/dubbod/discovery/cmd/app/xds_client_test.go
+++ b/dubbod/discovery/cmd/app/xds_client_test.go
@@ -15,6 +15,9 @@ import (
"time"
tlsv1 "github.com/kdubbo/xds-api/extensions/transport_sockets/tls/v1"
+ routev1 "github.com/kdubbo/xds-api/route/v1"
+ "google.golang.org/protobuf/types/known/anypb"
+ "google.golang.org/protobuf/types/known/wrapperspb"
)
func TestAutoDiscoverServiceTargetSingleService(t *testing.T) {
@@ -205,6 +208,91 @@ func
TestRunSampleRequestsUsesUpdatedSnapshotOnSameStream(t *testing.T) {
}
}
+func TestRunSampleRequestsUsesRequestPathAndHeaders(t *testing.T) {
+ server := httptest.NewServer(http.HandlerFunc(func(w
http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/reviews" {
+ t.Fatalf("path = %q, want /reviews", r.URL.Path)
+ }
+ if got := r.Header.Get("end-user"); got != "terminal-user" {
+ t.Fatalf("end-user header = %q, want terminal-user",
got)
+ }
+ _, _ = fmt.Fprintln(w, "reviews v1")
+ }))
+ defer server.Close()
+
+ endpoint := endpointForServer(t, server)
+ snapshot := xdsRouteSnapshot{
+ Host: "reviews.moviereview.svc.cluster.local",
+ Port: 9080,
+ Destinations: []xdsDestination{{
+ Cluster:
"outbound|9080|v1|reviews.moviereview.svc.cluster.local",
+ Subset: "v1",
+ Weight: 1,
+ Endpoints: []xdsEndpoint{endpoint},
+ }},
+ }
+ client := &sampleADSClient{
+ host: snapshot.Host,
+ port: snapshot.Port,
+ path: "/reviews",
+ requestHeaders: http.Header{"End-User":
[]string{"terminal-user"}},
+ route:
map[string]uint32{snapshot.Destinations[0].Cluster: 1},
+ endpoints:
map[string][]xdsEndpoint{snapshot.Destinations[0].Cluster:
[]xdsEndpoint{endpoint}},
+ }
+
+ if err := runSampleRequests(context.Background(), client, snapshot, 1,
0, time.Second); err != nil {
+ t.Fatalf("runSampleRequests() error = %v", err)
+ }
+}
+
+func TestRouteWeightsFromRoutesFiltersHeaderMatchedRoute(t *testing.T) {
+ resources := []*anypb.Any{mustAnyRouteConfig(t,
&routev1.RouteConfiguration{
+ VirtualHosts: []*routev1.VirtualHost{{
+ Routes: []*routev1.Route{
+ {
+ Match: &routev1.RouteMatch{
+ PathSpecifier:
&routev1.RouteMatch_Prefix{Prefix: "/"},
+ Headers:
[]*routev1.HeaderMatcher{{
+ Name: "end-user",
+ HeaderMatchSpecifier:
&routev1.HeaderMatcher_ExactMatch{
+ ExactMatch:
"terminal-user",
+ },
+ }},
+ },
+ Action:
weightedRouteAction(map[string]uint32{
+
"outbound|9080|v1|reviews.moviereview.svc.cluster.local": 100,
+ }),
+ },
+ {
+ Match:
&routev1.RouteMatch{PathSpecifier: &routev1.RouteMatch_Prefix{Prefix: "/"}},
+ Action:
weightedRouteAction(map[string]uint32{
+
"outbound|9080|v2|reviews.moviereview.svc.cluster.local": 20,
+
"outbound|9080|v3|reviews.moviereview.svc.cluster.local": 80,
+ }),
+ },
+ },
+ }},
+ })}
+
+ weights, _, err := routeWeightsFromRoutes(resources, "/",
http.Header{"End-User": []string{"terminal-user"}})
+ if err != nil {
+ t.Fatalf("routeWeightsFromRoutes() error = %v", err)
+ }
+ if got :=
weights["outbound|9080|v1|reviews.moviereview.svc.cluster.local"]; got != 100
|| len(weights) != 1 {
+ t.Fatalf("terminal-user weights = %v, want v1=100 only",
weights)
+ }
+
+ weights, _, err = routeWeightsFromRoutes(resources, "/", nil)
+ if err != nil {
+ t.Fatalf("routeWeightsFromRoutes() fallback error = %v", err)
+ }
+ if len(weights) != 2 ||
+
weights["outbound|9080|v2|reviews.moviereview.svc.cluster.local"] != 20 ||
+
weights["outbound|9080|v3|reviews.moviereview.svc.cluster.local"] != 80 {
+ t.Fatalf("fallback weights = %v, want v2=20 and v3=80", weights)
+ }
+}
+
func TestSampleRequestClientsDoNotBypassMTLS(t *testing.T) {
clients := newSampleRequestClients(&sampleADSClient{}, time.Second)
destination := xdsDestination{
@@ -295,3 +383,29 @@ func contains(values []string, want string) bool {
}
return false
}
+
+func mustAnyRouteConfig(t *testing.T, rc *routev1.RouteConfiguration)
*anypb.Any {
+ t.Helper()
+ out, err := anypb.New(rc)
+ if err != nil {
+ t.Fatalf("anypb.New() error = %v", err)
+ }
+ return out
+}
+
+func weightedRouteAction(weights map[string]uint32) *routev1.Route_Route {
+ clusters := make([]*routev1.WeightedCluster_ClusterWeight, 0,
len(weights))
+ for name, weight := range weights {
+ clusters = append(clusters,
&routev1.WeightedCluster_ClusterWeight{
+ Name: name,
+ Weight: wrapperspb.UInt32(weight),
+ })
+ }
+ return &routev1.Route_Route{
+ Route: &routev1.RouteAction{
+ ClusterSpecifier: &routev1.RouteAction_WeightedClusters{
+ WeightedClusters:
&routev1.WeightedCluster{Clusters: clusters},
+ },
+ },
+ }
+}
diff --git a/dubbod/discovery/pkg/bootstrap/gui.go
b/dubbod/discovery/pkg/bootstrap/gui.go
index 6ce57095..defef9a5 100644
--- a/dubbod/discovery/pkg/bootstrap/gui.go
+++ b/dubbod/discovery/pkg/bootstrap/gui.go
@@ -86,7 +86,6 @@ type guiOverviewCounts struct {
EndpointServices int `json:"endpointServices"`
XDSConnections int `json:"xdsConnections"`
Registries int `json:"registries"`
- MeshServices int `json:"meshServices"`
PeerAuthentications int `json:"peerAuthentications"`
RequestAuthentications int `json:"requestAuthentications"`
AuthorizationPolicies int `json:"authorizationPolicies"`
@@ -447,7 +446,6 @@ func (s *Server) buildGUIOverview() guiOverview {
EndpointServices:
len(s.environment.EndpointIndex.AllServices()),
XDSConnections: len(s.XDSServer.AllClients()),
Registries: len(registries),
- MeshServices: s.countConfigs(gvk.MeshService),
PeerAuthentications:
s.countConfigs(gvk.PeerAuthentication),
RequestAuthentications:
s.countConfigs(gvk.RequestAuthentication),
AuthorizationPolicies:
s.countConfigs(gvk.AuthorizationPolicy),
@@ -566,11 +564,6 @@ func (s *Server) buildGUIRegistries() []guiRegistry {
func (s *Server) buildGUIConfigKinds() []guiConfigKind {
return []guiConfigKind{
- {
- Kind: "MeshService",
- Count: s.countConfigs(gvk.MeshService),
- Description: "Service-to-service routing and traffic
policy.",
- },
{
Kind: "PeerAuthentication",
Count: s.countConfigs(gvk.PeerAuthentication),
diff --git a/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller.go
b/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller.go
index f153ab06..20984967 100644
--- a/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller.go
+++ b/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller.go
@@ -238,7 +238,7 @@ func proxylessGRPCRuntimeConfigNeedsUpdate(req
*discoverymodel.PushRequest) bool
}
for cfg := range req.ConfigsUpdated {
switch cfg.Kind {
- case kind.MeshService, kind.PeerAuthentication,
kind.RequestAuthentication, kind.AuthorizationPolicy, kind.Service,
kind.EndpointSlice, kind.Endpoints, kind.Pod, kind.Namespace:
+ case kind.HTTPRoute, kind.PeerAuthentication,
kind.RequestAuthentication, kind.AuthorizationPolicy, kind.Service,
kind.EndpointSlice, kind.Endpoints, kind.Pod, kind.Namespace:
return true
}
}
diff --git a/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller_test.go
b/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller_test.go
index 4165c7fe..8f903f6b 100644
--- a/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller_test.go
+++ b/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller_test.go
@@ -35,7 +35,6 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/kube/inject"
"github.com/apache/dubbo-kubernetes/pkg/kube/krt"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
- networking "github.com/kdubbo/api/networking/v1alpha3"
security "github.com/kdubbo/api/security/v1alpha3"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -269,7 +268,6 @@ func
TestBuildRuntimeTrafficConfigCapturesProxylessSecurity(t *testing.T) {
hostname := host.Name("provider.grpc-app.svc.cluster.local")
svc := newProxylessRuntimeTestService("provider", "grpc-app",
string(hostname), 17070)
push := newProxylessRuntimeTestPushContext(t, []config.Config{
- newProxylessMTLSMeshServiceConfig("provider-mtls", "grpc-app",
hostname),
newProxylessStrictPeerAuthenticationConfig("grpc-app-strict-mtls", "grpc-app"),
}, []*discoverymodel.Service{svc})
@@ -282,17 +280,12 @@ func
TestBuildRuntimeTrafficConfigCapturesProxylessSecurity(t *testing.T) {
}
routeConfig := buildRuntimeRouteConfig(push, nil, svc, 17070)
- if len(routeConfig.Destinations) != 2 {
- t.Fatalf("destinations = %d, want 2",
len(routeConfig.Destinations))
+ if len(routeConfig.Destinations) != 1 {
+ t.Fatalf("destinations = %d, want 1",
len(routeConfig.Destinations))
}
- wantWeights := map[string]int{"v1": 50, "v2": 50}
- for _, destination := range routeConfig.Destinations {
- if destination.TLSMode != "DUBBO_MUTUAL" {
- t.Fatalf("destination %s tlsMode = %q, want
DUBBO_MUTUAL", destination.Subset, destination.TLSMode)
- }
- if wantWeights[destination.Subset] != destination.Weight {
- t.Fatalf("destination %s weight = %d, want %d",
destination.Subset, destination.Weight, wantWeights[destination.Subset])
- }
+ destination := routeConfig.Destinations[0]
+ if destination.Host != string(hostname) || destination.Weight != 100 ||
destination.TLSMode != "" {
+ t.Fatalf("destination = %+v, want default host weight 100
without outbound TLS policy", destination)
}
}
@@ -324,9 +317,9 @@ func TestProxylessGRPCRuntimeConfigNeedsUpdate(t
*testing.T) {
want: true,
},
{
- name: "meshservice",
+ name: "httproute",
req: &discoverymodel.PushRequest{
- ConfigsUpdated:
sets.New(discoverymodel.ConfigKey{Kind: kind.MeshService, Name:
"provider-mtls", Namespace: "grpc-app"}),
+ ConfigsUpdated:
sets.New(discoverymodel.ConfigKey{Kind: kind.HTTPRoute, Name:
"provider-routing", Namespace: "grpc-app"}),
},
want: true,
},
@@ -429,40 +422,6 @@ func newProxylessRuntimeTestService(name, namespace,
hostname string, port int)
}
}
-func newProxylessMTLSMeshServiceConfig(name, namespace string, hostname
host.Name) config.Config {
- return config.Config{
- Meta: config.Meta{
- GroupVersionKind: gvk.MeshService,
- Name: name,
- Namespace: namespace,
- Domain: "cluster.local",
- },
- Spec: &networking.MeshService{
- Hosts: []string{string(hostname)},
- TrafficPolicy: &networking.TrafficPolicy{
- Tls: &networking.ClientTLSSettings{
- Mode:
networking.ClientTLSSettings_DUBBO_MUTUAL,
- },
- },
- Routes: []*networking.MeshServiceRoute{{
- Service: []*networking.ServiceDestination{{
- Name: "v1",
- Host: string(hostname),
- Labels: map[string]string{"version":
"v1"},
- Port: &networking.ServicePort{Number:
17070},
- Weight: 50,
- }, {
- Name: "v2",
- Host: string(hostname),
- Labels: map[string]string{"version":
"v2"},
- Port: &networking.ServicePort{Number:
17070},
- Weight: 50,
- }},
- }},
- },
- }
-}
-
func newProxylessStrictPeerAuthenticationConfig(name, namespace string)
config.Config {
return newProxylessPeerAuthenticationConfig(name, namespace,
security.PeerAuthentication_MutualTLS_STRICT)
}
diff --git a/dubbod/discovery/pkg/bootstrap/server.go
b/dubbod/discovery/pkg/bootstrap/server.go
index 46b0a63e..f1330ac9 100644
--- a/dubbod/discovery/pkg/bootstrap/server.go
+++ b/dubbod/discovery/pkg/bootstrap/server.go
@@ -501,8 +501,6 @@ func (s *Server) initRegistryEventHandlers() {
switch schemaID {
case "AuthorizationPolicy":
configKind = kind.AuthorizationPolicy
- case "MeshService":
- configKind = kind.MeshService
case "PeerAuthentication":
configKind = kind.PeerAuthentication
case "RequestAuthentication":
@@ -527,12 +525,11 @@ func (s *Server) initRegistryEventHandlers() {
// Log the config change
log.Infof("%s event for %s/%s/%s", event, configKey.Kind,
configKey.Namespace, configKey.Name)
- // Some configs (MeshService/security policies/HTTPRoute)
require Full push to ensure
+ // Some configs (security policies/HTTPRoute) require Full push
to ensure
// PushContext is re-initialized and configuration is reloaded.
// Security policies must rebuild AuthenticationPolicies to
update inbound mTLS/JWT/authz filters.
// HTTPRoute must rebuild HTTPRoute index to enable Gateway API
routing.
- needsFullPush := configKind == kind.MeshService ||
- configKind == kind.PeerAuthentication ||
+ needsFullPush := configKind == kind.PeerAuthentication ||
configKind == kind.RequestAuthentication ||
configKind == kind.AuthorizationPolicy ||
configKind == kind.HTTPRoute
diff --git a/dubbod/discovery/pkg/bootstrap/service_controller.go
b/dubbod/discovery/pkg/bootstrap/service_controller.go
index 13c39b99..6a555e8f 100644
--- a/dubbod/discovery/pkg/bootstrap/service_controller.go
+++ b/dubbod/discovery/pkg/bootstrap/service_controller.go
@@ -69,7 +69,7 @@ func (s *Server) initKubeRegistry(args *DubboArgs) (err
error) {
args.RegistryOptions.KubeOptions.XDSUpdater = s.XDSServer
args.RegistryOptions.KubeOptions.MeshWatcher = s.environment.Watcher
args.RegistryOptions.KubeOptions.SystemNamespace = args.Namespace
- args.RegistryOptions.KubeOptions.MeshServiceController =
s.ServiceController()
+ args.RegistryOptions.KubeOptions.ServiceController =
s.ServiceController()
kubecontroller.NewMulticluster(args.PodName,
args.RegistryOptions.KubeOptions,
s.dubbodCertBundleWatcher,
diff --git a/dubbod/discovery/pkg/config/kube/crdclient/types.gen.go
b/dubbod/discovery/pkg/config/kube/crdclient/types.gen.go
index 6d67d932..23ad57da 100755
--- a/dubbod/discovery/pkg/config/kube/crdclient/types.gen.go
+++ b/dubbod/discovery/pkg/config/kube/crdclient/types.gen.go
@@ -15,9 +15,7 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/kube"
githubcomkdubboapimetav1alpha1 "github.com/kdubbo/api/meta/v1alpha1"
- githubcomkdubboapinetworkingv1alpha3
"github.com/kdubbo/api/networking/v1alpha3"
githubcomkdubboapisecurityv1alpha3
"github.com/kdubbo/api/security/v1alpha3"
- apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/kdubbo/client-go/pkg/apis/networking/v1alpha3"
apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/kdubbo/client-go/pkg/apis/security/v1alpha3"
k8sioapiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
k8sioapiappsv1 "k8s.io/api/apps/v1"
@@ -52,11 +50,6 @@ func create(c kube.Client, cfg config.Config, objMeta
metav1.ObjectMeta) (metav1
ObjectMeta: objMeta,
Spec:
*(cfg.Spec.(*sigsk8siogatewayapiapisv1.GatewaySpec)),
}, metav1.CreateOptions{})
- case gvk.MeshService:
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(cfg.Namespace).Create(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService{
- ObjectMeta: objMeta,
- Spec:
*(cfg.Spec.(*githubcomkdubboapinetworkingv1alpha3.MeshService)),
- }, metav1.CreateOptions{})
case gvk.PeerAuthentication:
return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).Create(context.TODO(),
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: objMeta,
@@ -94,11 +87,6 @@ func update(c kube.Client, cfg config.Config, objMeta
metav1.ObjectMeta) (metav1
ObjectMeta: objMeta,
Spec:
*(cfg.Spec.(*sigsk8siogatewayapiapisv1.GatewaySpec)),
}, metav1.UpdateOptions{})
- case gvk.MeshService:
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(cfg.Namespace).Update(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService{
- ObjectMeta: objMeta,
- Spec:
*(cfg.Spec.(*githubcomkdubboapinetworkingv1alpha3.MeshService)),
- }, metav1.UpdateOptions{})
case gvk.PeerAuthentication:
return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).Update(context.TODO(),
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: objMeta,
@@ -136,11 +124,6 @@ func updateStatus(c kube.Client, cfg config.Config,
objMeta metav1.ObjectMeta) (
ObjectMeta: objMeta,
Status:
*(cfg.Status.(*sigsk8siogatewayapiapisv1.GatewayStatus)),
}, metav1.UpdateOptions{})
- case gvk.MeshService:
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(cfg.Namespace).UpdateStatus(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService{
- ObjectMeta: objMeta,
- Status:
*(cfg.Status.(*githubcomkdubboapimetav1alpha1.DubboStatus)),
- }, metav1.UpdateOptions{})
case gvk.PeerAuthentication:
return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).UpdateStatus(context.TODO(),
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: objMeta,
@@ -221,21 +204,6 @@ func patch(c kube.Client, orig config.Config, origMeta
metav1.ObjectMeta, mod co
}
return c.GatewayAPI().GatewayV1().Gateways(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes,
metav1.PatchOptions{FieldManager: "pilot-discovery"})
- case gvk.MeshService:
- oldRes :=
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService{
- ObjectMeta: origMeta,
- Spec:
*(orig.Spec.(*githubcomkdubboapinetworkingv1alpha3.MeshService)),
- }
- modRes :=
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService{
- ObjectMeta: modMeta,
- Spec:
*(mod.Spec.(*githubcomkdubboapinetworkingv1alpha3.MeshService)),
- }
- patchBytes, err := genPatchBytes(oldRes, modRes, typ)
- if err != nil {
- return nil, err
- }
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(orig.Namespace).
- Patch(context.TODO(), orig.Name, typ, patchBytes,
metav1.PatchOptions{FieldManager: "pilot-discovery"})
case gvk.PeerAuthentication:
oldRes :=
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: origMeta,
@@ -285,8 +253,6 @@ func delete(c kube.Client, typ config.GroupVersionKind,
name, namespace string,
return
c.GatewayAPI().GatewayV1().HTTPRoutes(namespace).Delete(context.TODO(), name,
deleteOptions)
case gvk.KubernetesGateway:
return
c.GatewayAPI().GatewayV1().Gateways(namespace).Delete(context.TODO(), name,
deleteOptions)
- case gvk.MeshService:
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(namespace).Delete(context.TODO(),
name, deleteOptions)
case gvk.PeerAuthentication:
return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(namespace).Delete(context.TODO(),
name, deleteOptions)
case gvk.RequestAuthentication:
@@ -518,25 +484,6 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
Spec: &obj.Spec,
}
},
- gvk.MeshService: func(r runtime.Object) config.Config {
- obj :=
r.(*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService)
- return config.Config{
- Meta: config.Meta{
- GroupVersionKind: gvk.MeshService,
- Name: obj.Name,
- Namespace: obj.Namespace,
- Labels: obj.Labels,
- Annotations: obj.Annotations,
- ResourceVersion: obj.ResourceVersion,
- CreationTimestamp: obj.CreationTimestamp.Time,
- OwnerReferences: obj.OwnerReferences,
- UID: string(obj.UID),
- Generation: obj.Generation,
- },
- Spec: &obj.Spec,
- Status: &obj.Status,
- }
- },
gvk.MutatingWebhookConfiguration: func(r runtime.Object) config.Config {
obj :=
r.(*k8sioapiadmissionregistrationv1.MutatingWebhookConfiguration)
return config.Config{
diff --git a/dubbod/discovery/pkg/features/experimental.go
b/dubbod/discovery/pkg/features/experimental.go
index b6cd7c04..3c2f7e0e 100644
--- a/dubbod/discovery/pkg/features/experimental.go
+++ b/dubbod/discovery/pkg/features/experimental.go
@@ -25,7 +25,7 @@ var (
"If enabled (default), starts a leader election client and
gains leadership before executing controllers. "+
"If false, it assumes that only one instance of dubbod
is running and skips leader election.").Get()
EnableEnhancedDestinationRuleMerge =
env.Register("ENABLE_ENHANCED_DESTINATIONRULE_MERGE", true,
- "If enabled, Dubbo merges MeshService-derived destination rules
considering their exportTo fields,"+
+ "If enabled, Dubbo merges Gateway API-derived destination rules
considering their exportTo fields,"+
" they will be kept as independent rules if the
exportTos are not equal.").Get()
EnableGatewayAPI = env.Register("DUBBO_ENABLE_GATEWAY_API", true,
"If this is set to true, support for Kubernetes gateway-api
(github.com/kubernetes-sigs/gateway-api) will "+
diff --git a/dubbod/discovery/pkg/model/meshservice.go
b/dubbod/discovery/pkg/model/meshservice.go
deleted file mode 100644
index 02b41bfc..00000000
--- a/dubbod/discovery/pkg/model/meshservice.go
+++ /dev/null
@@ -1,271 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You 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 model
-
-import (
- "github.com/apache/dubbo-kubernetes/pkg/config"
- networking "github.com/kdubbo/api/networking/v1alpha3"
-)
-
-func meshServiceToVirtualServiceConfig(msConfig config.Config) config.Config {
- r := msConfig.DeepCopy()
- ms, ok := r.Spec.(*networking.MeshService)
- if !ok || ms == nil {
- return r
- }
- vs := &networking.VirtualService{
- Hosts: append([]string(nil), ms.Hosts...),
- }
- for _, rule := range ms.Rules {
- if rule == nil {
- continue
- }
- appendMeshServiceHTTPRoutes(&vs.Http, ms, msConfig.Meta,
rule.Route, rule.Match)
- appendMeshServiceHTTPRoutes(&vs.Http, ms, msConfig.Meta,
rule.Routes, nil)
- }
- appendMeshServiceHTTPRoutes(&vs.Http, ms, msConfig.Meta, ms.Routes, nil)
- r.Spec = vs
- return resolveVirtualServiceShortnames(r)
-}
-
-func meshServiceToDestinationRuleConfigs(msConfig config.Config)
[]config.Config {
- r := msConfig.DeepCopy()
- ms, ok := r.Spec.(*networking.MeshService)
- if !ok || ms == nil {
- return []config.Config{r}
- }
- rulesByHost := map[string]*networking.DestinationRule{}
- order := []string{}
- ruleForHost := func(hostname string) *networking.DestinationRule {
- if hostname == "" {
- return nil
- }
- resolved := string(ResolveShortnameToFQDN(hostname, r.Meta))
- if dr := rulesByHost[resolved]; dr != nil {
- return dr
- }
- dr := &networking.DestinationRule{
- Host: resolved,
- TrafficPolicy: ms.TrafficPolicy,
- }
- rulesByHost[resolved] = dr
- order = append(order, resolved)
- return dr
- }
-
- forEachMeshServiceDestination(ms, func(svc
*networking.ServiceDestination) {
- if svc == nil {
- return
- }
- if serviceDestinationUsesLabels(svc) {
- dr := ruleForHost(hostForLabelDestination(ms, svc))
- if dr == nil || svc.Name == "" || hasSubset(dr,
svc.Name) {
- return
- }
- dr.Subsets = append(dr.Subsets, &networking.Subset{
- Name: svc.Name,
- Labels: cloneStringMap(svc.Labels),
- TrafficPolicy: svc.TrafficPolicy,
- })
- return
- }
- if svc.TrafficPolicy != nil {
- if dr := ruleForHost(destinationHostForService(ms, svc,
r.Meta)); dr != nil {
- dr.TrafficPolicy = svc.TrafficPolicy
- }
- } else if ms.TrafficPolicy != nil {
- ruleForHost(destinationHostForService(ms, svc, r.Meta))
- }
- })
-
- if len(order) == 0 {
- if host := firstMeshServiceHost(ms, r.Meta); host != "" {
- order = append(order, host)
- rulesByHost[host] = &networking.DestinationRule{
- Host: host,
- TrafficPolicy: ms.TrafficPolicy,
- }
- }
- }
-
- out := make([]config.Config, 0, len(order))
- for _, hostname := range order {
- dr := rulesByHost[hostname]
- if dr == nil {
- continue
- }
- cfg := msConfig.DeepCopy()
- cfg.Spec = dr
- out = append(out, cfg)
- }
- return out
-}
-
-func appendMeshServiceHTTPRoutes(out *[]*networking.HTTPRoute, ms
*networking.MeshService, meta config.Meta, routes
[]*networking.MeshServiceRoute, matches []*networking.HTTPMatchRequest) {
- httpRoute := &networking.HTTPRoute{
- Match: append([]*networking.HTTPMatchRequest(nil), matches...),
- }
- for _, route := range routes {
- if route == nil {
- continue
- }
- for _, svc := range route.Service {
- if svc == nil {
- continue
- }
- httpRoute.Route = append(httpRoute.Route,
&networking.HTTPRouteDestination{
- Destination: &networking.Destination{
- Host: destinationHostForService(ms,
svc, meta),
- Subset:
destinationSubsetForService(svc),
- },
- Weight: svc.Weight,
- })
- }
- }
- if len(httpRoute.Route) > 0 {
- *out = append(*out, httpRoute)
- }
-}
-
-func forEachMeshServiceDestination(ms *networking.MeshService, visit
func(*networking.ServiceDestination)) {
- for _, rule := range ms.Rules {
- if rule == nil {
- continue
- }
- forEachMeshServiceRouteDestination(rule.Route, visit)
- forEachMeshServiceRouteDestination(rule.Routes, visit)
- }
- forEachMeshServiceRouteDestination(ms.Routes, visit)
-}
-
-func forEachMeshServiceRouteDestination(routes []*networking.MeshServiceRoute,
visit func(*networking.ServiceDestination)) {
- for _, route := range routes {
- if route == nil {
- continue
- }
- for _, svc := range route.Service {
- visit(svc)
- }
- }
-}
-
-func meshServiceToDestinationRuleConfig(msConfig config.Config) config.Config {
- rules := meshServiceToDestinationRuleConfigs(msConfig)
- if len(rules) == 0 {
- return msConfig.DeepCopy()
- }
- return rules[0]
-}
-
-func firstMeshServiceHost(ms *networking.MeshService, meta config.Meta) string
{
- for _, h := range ms.Hosts {
- if h != "" {
- return string(ResolveShortnameToFQDN(h, meta))
- }
- }
- host := ""
- forEachMeshServiceDestination(ms, func(svc
*networking.ServiceDestination) {
- if host == "" && svc != nil && svc.Host != "" {
- host = string(ResolveShortnameToFQDN(svc.Host, meta))
- }
- })
- if host != "" {
- return host
- }
- return ""
-}
-
-func destinationHostForService(ms *networking.MeshService, svc
*networking.ServiceDestination, meta config.Meta) string {
- if svc == nil {
- return firstMeshServiceHost(ms, meta)
- }
- if serviceDestinationUsesLabels(svc) {
- return hostForLabelDestination(ms, svc)
- }
- if svc.Name != "" {
- return string(ResolveShortnameToFQDN(svc.Name, meta))
- }
- if svc.Host != "" {
- return string(ResolveShortnameToFQDN(svc.Host, meta))
- }
- return firstMeshServiceHost(ms, meta)
-}
-
-func destinationSubsetForService(svc *networking.ServiceDestination) string {
- if serviceDestinationUsesLabels(svc) {
- return svc.Name
- }
- return ""
-}
-
-func hostForLabelDestination(ms *networking.MeshService, svc
*networking.ServiceDestination) string {
- if svc != nil && svc.Host != "" {
- return svc.Host
- }
- if len(ms.Hosts) > 0 {
- return ms.Hosts[0]
- }
- return ""
-}
-
-func serviceDestinationUsesLabels(svc *networking.ServiceDestination) bool {
- return svc != nil && len(svc.Labels) > 0
-}
-
-func hasSubset(dr *networking.DestinationRule, name string) bool {
- for _, subset := range dr.Subsets {
- if subset != nil && subset.Name == name {
- return true
- }
- }
- return false
-}
-
-func cloneStringMap(in map[string]string) map[string]string {
- if len(in) == 0 {
- return nil
- }
- out := make(map[string]string, len(in))
- for k, v := range in {
- out[k] = v
- }
- return out
-}
-
-func resolveVirtualServiceShortnames(config config.Config) config.Config {
- // values returned from ConfigStore.List are immutable.
- // Therefore, we make a copy
- r := config.DeepCopy()
- rule := r.Spec.(*networking.VirtualService)
- meta := r.Meta
-
- // resolve top level hosts
- for i, h := range rule.Hosts {
- rule.Hosts[i] = string(ResolveShortnameToFQDN(h, meta))
- }
-
- // resolve host in http route.subset(dubbo destination)
- for _, d := range rule.Http {
- for _, w := range d.Route {
- if w.Destination != nil {
- w.Destination.Host =
string(ResolveShortnameToFQDN(w.Destination.Host, meta))
- }
- }
- }
-
- return r
-}
diff --git a/dubbod/discovery/pkg/model/meshservice_test.go
b/dubbod/discovery/pkg/model/meshservice_test.go
deleted file mode 100644
index f10f8dde..00000000
--- a/dubbod/discovery/pkg/model/meshservice_test.go
+++ /dev/null
@@ -1,196 +0,0 @@
-package model
-
-import (
- "testing"
-
- "github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
- networking "github.com/kdubbo/api/networking/v1alpha3"
-)
-
-func TestMeshServiceToVirtualServiceConfigBuildsServiceWeightedRoute(t
*testing.T) {
- cfg := newModelTestMeshService("reviews-routing", "default",
"reviews.default.svc.cluster.local", []*networking.MeshServiceRoute{
- {Service: []*networking.ServiceDestination{{
- Name: "reviews-1",
- Host: "reviews.default.svc.cluster.local",
- Weight: 20,
- }}},
- {Service: []*networking.ServiceDestination{{
- Name: "reviews-2",
- Host: "reviews.default.svc.cluster.local",
- Weight: 80,
- }}},
- })
-
- got :=
meshServiceToVirtualServiceConfig(cfg).Spec.(*networking.VirtualService)
- if len(got.Http) != 1 {
- t.Fatalf("http routes = %d, want 1", len(got.Http))
- }
- if len(got.Http[0].Route) != 2 {
- t.Fatalf("weighted destinations = %d, want 2",
len(got.Http[0].Route))
- }
-
- assertHTTPDestination(t, got.Http[0].Route[0],
"reviews-1.default.svc.cluster.local", "", 20)
- assertHTTPDestination(t, got.Http[0].Route[1],
"reviews-2.default.svc.cluster.local", "", 80)
-}
-
-func TestMeshServiceToVirtualServiceConfigKeepsLabelSubsetRoute(t *testing.T) {
- cfg := newModelTestMeshService("reviews-routing", "default",
"reviews.default.svc.cluster.local", []*networking.MeshServiceRoute{{
- Service: []*networking.ServiceDestination{
- {
- Name: "v1",
- Host: "reviews.default.svc.cluster.local",
- Labels: map[string]string{"version": "v1"},
- Weight: 20,
- },
- {
- Name: "v2",
- Host: "reviews.default.svc.cluster.local",
- Labels: map[string]string{"version": "v2"},
- Weight: 80,
- },
- },
- }})
-
- got :=
meshServiceToVirtualServiceConfig(cfg).Spec.(*networking.VirtualService)
- if len(got.Http) != 1 || len(got.Http[0].Route) != 2 {
- t.Fatalf("http routes = %v, want one route with two
destinations", got.Http)
- }
- assertHTTPDestination(t, got.Http[0].Route[0],
"reviews.default.svc.cluster.local", "v1", 20)
- assertHTTPDestination(t, got.Http[0].Route[1],
"reviews.default.svc.cluster.local", "v2", 80)
-
- rules := meshServiceToDestinationRuleConfigs(cfg)
- if len(rules) != 1 {
- t.Fatalf("destination rules = %d, want 1", len(rules))
- }
- dr := rules[0].Spec.(*networking.DestinationRule)
- if dr.Host != "reviews.default.svc.cluster.local" {
- t.Fatalf("destination rule host = %q, want
reviews.default.svc.cluster.local", dr.Host)
- }
- if len(dr.Subsets) != 2 {
- t.Fatalf("subsets = %d, want 2", len(dr.Subsets))
- }
- if got := dr.Subsets[1].Labels["version"]; got != "v2" {
- t.Fatalf("subset label = %q, want v2", got)
- }
-}
-
-func TestMeshServiceToVirtualServiceConfigBuildsMatchedRouteBeforeFallback(t
*testing.T) {
- cfg := config.Config{
- Meta: config.Meta{
- GroupVersionKind: gvk.MeshService,
- Name: "product-routing",
- Namespace: "default",
- Domain: "cluster.local",
- },
- Spec: &networking.MeshService{
- Hosts: []string{"product.default.svc.cluster.local"},
- Rules: []*networking.MeshServiceRule{{
- Match: []*networking.HTTPMatchRequest{{
- Uri: &networking.StringMatch{
- MatchType:
&networking.StringMatch_Prefix{Prefix: "/product"},
- },
- Headers:
map[string]*networking.StringMatch{
- "end-user": {
- MatchType:
&networking.StringMatch_Exact{Exact: "jason"},
- },
- },
- }},
- Route: []*networking.MeshServiceRoute{{
- Service:
[]*networking.ServiceDestination{{
- Name: "v1",
- Host:
"product.default.svc.cluster.local",
- Labels:
map[string]string{"version": "v1"},
- Weight: 100,
- }},
- }},
- Routes: []*networking.MeshServiceRoute{{
- Service:
[]*networking.ServiceDestination{{
- Name: "v2",
- Host:
"product.default.svc.cluster.local",
- Labels:
map[string]string{"version": "v2"},
- Weight: 20,
- }, {
- Name: "v3",
- Host:
"product.default.svc.cluster.local",
- Labels:
map[string]string{"version": "v3"},
- Weight: 80,
- }},
- }},
- }},
- },
- }
-
- got :=
meshServiceToVirtualServiceConfig(cfg).Spec.(*networking.VirtualService)
- if len(got.Http) != 2 {
- t.Fatalf("http routes = %d, want matched route plus fallback",
len(got.Http))
- }
- if got.Http[0].GetMatch()[0].GetUri().GetPrefix() != "/product" {
- t.Fatalf("first route uri match = %v, want /product prefix",
got.Http[0].GetMatch())
- }
- if got.Http[0].GetMatch()[0].GetHeaders()["end-user"].GetExact() !=
"jason" {
- t.Fatalf("first route header match = %v, want end-user exact
jason", got.Http[0].GetMatch())
- }
- if len(got.Http[1].GetMatch()) != 0 {
- t.Fatalf("fallback route match = %v, want empty",
got.Http[1].GetMatch())
- }
- assertHTTPDestination(t, got.Http[0].Route[0],
"product.default.svc.cluster.local", "v1", 100)
- assertHTTPDestination(t, got.Http[1].Route[1],
"product.default.svc.cluster.local", "v3", 80)
-}
-
-func TestMeshServiceToDestinationRuleConfigsBuildsServiceTrafficPolicies(t
*testing.T) {
- cfg := newModelTestMeshService("reviews-routing", "default",
"reviews.default.svc.cluster.local", []*networking.MeshServiceRoute{{
- Service: []*networking.ServiceDestination{
- {Name: "reviews-1", Host:
"reviews.default.svc.cluster.local", Weight: 20},
- {Name: "reviews-2", Host:
"reviews.default.svc.cluster.local", Weight: 80},
- },
- }})
- cfg.Spec.(*networking.MeshService).TrafficPolicy =
&networking.TrafficPolicy{
- Tls: &networking.ClientTLSSettings{Mode:
networking.ClientTLSSettings_DUBBO_MUTUAL},
- }
-
- rules := meshServiceToDestinationRuleConfigs(cfg)
- if len(rules) != 2 {
- t.Fatalf("destination rules = %d, want 2", len(rules))
- }
- for i, wantHost := range
[]string{"reviews-1.default.svc.cluster.local",
"reviews-2.default.svc.cluster.local"} {
- dr := rules[i].Spec.(*networking.DestinationRule)
- if dr.Host != wantHost {
- t.Fatalf("destination rule[%d] host = %q, want %q", i,
dr.Host, wantHost)
- }
- if len(dr.Subsets) != 0 {
- t.Fatalf("destination rule[%d] subsets = %d, want 0",
i, len(dr.Subsets))
- }
- if got := dr.GetTrafficPolicy().GetTls().GetMode(); got !=
networking.ClientTLSSettings_DUBBO_MUTUAL {
- t.Fatalf("destination rule[%d] tls mode = %v, want
DUBBO_MUTUAL", i, got)
- }
- }
-}
-
-func newModelTestMeshService(name, namespace, hostname string, routes
[]*networking.MeshServiceRoute) config.Config {
- return config.Config{
- Meta: config.Meta{
- GroupVersionKind: gvk.MeshService,
- Name: name,
- Namespace: namespace,
- Domain: "cluster.local",
- },
- Spec: &networking.MeshService{
- Hosts: []string{hostname},
- Routes: routes,
- },
- }
-}
-
-func assertHTTPDestination(t *testing.T, got *networking.HTTPRouteDestination,
wantHost, wantSubset string, wantWeight int32) {
- t.Helper()
- if got.GetDestination().GetHost() != wantHost {
- t.Fatalf("destination host = %q, want %q",
got.GetDestination().GetHost(), wantHost)
- }
- if got.GetDestination().GetSubset() != wantSubset {
- t.Fatalf("destination subset = %q, want %q",
got.GetDestination().GetSubset(), wantSubset)
- }
- if got.GetWeight() != wantWeight {
- t.Fatalf("destination weight = %d, want %d", got.GetWeight(),
wantWeight)
- }
-}
diff --git a/dubbod/discovery/pkg/model/push_context.go
b/dubbod/discovery/pkg/model/push_context.go
index 22e0043e..6e82a0f3 100644
--- a/dubbod/discovery/pkg/model/push_context.go
+++ b/dubbod/discovery/pkg/model/push_context.go
@@ -587,12 +587,8 @@ func (ps *PushContext) createNewContext(env *Environment) {
log.Debug("creating new PushContext (full initialization)")
ps.initServiceRegistry(env, nil)
// Initialize Kubernetes Gateway API resources if the controller is
enabled.
- // This mirrors Dubbo's behavior, where Gateway API is translated into
- // internal Gateway and MeshService resources during push context
creation.
ps.initKubernetesGateways(env)
- ps.initVirtualServices(env)
ps.initHTTPRoutes(env)
- ps.initDestinationRules(env)
ps.initAuthenticationPolicies(env)
}
@@ -605,32 +601,6 @@ func (ps *PushContext) updateContext(env *Environment,
oldPushContext *PushConte
// len(pushReq.AddressesUpdated) > 0)
servicesChanged := pushReq != nil && len(pushReq.AddressesUpdated) > 0
- // Check if meshServices have changed based on:
- // 1. MeshService updates in ConfigsUpdated
- // 2. Full push (Full: true) - always re-initialize on full push
- meshServicesChanged := pushReq != nil && (pushReq.Full ||
HasConfigsOfKind(pushReq.ConfigsUpdated, kind.MeshService) ||
- len(pushReq.AddressesUpdated) > 0)
-
- if pushReq != nil {
- meshServiceCount := 0
- for cfg := range pushReq.ConfigsUpdated {
- if cfg.Kind == kind.MeshService {
- meshServiceCount++
- }
- }
- if meshServiceCount > 0 {
- log.Debugf("detected %d MeshService config changes",
meshServiceCount)
- }
- }
-
- if pushReq != nil {
- if pushReq.Full {
- log.Debugf("Full push requested, will re-initialize
MeshService-derived indexes")
- }
- log.Debugf("meshServicesChanged=%v, pushReq.ConfigsUpdated
size=%d, Full=%v",
- meshServicesChanged, len(pushReq.ConfigsUpdated),
pushReq != nil && pushReq.Full)
- }
-
// Also check if the actual number of services has changed
// This handles cases where Kubernetes Services are added/removed
without ServiceEntry updates
if !servicesChanged && oldPushContext != nil {
@@ -666,14 +636,6 @@ func (ps *PushContext) updateContext(env *Environment,
oldPushContext *PushConte
httpRoutesChanged := pushReq != nil &&
HasConfigsOfKind(pushReq.ConfigsUpdated, kind.HTTPRoute)
- if meshServicesChanged {
- log.Debugf("MeshServices changed, re-initializing
VirtualService index")
- ps.initVirtualServices(env)
- } else {
- log.Debugf("MeshServices unchanged, reusing old VirtualService
index")
- ps.virtualServiceIndex = oldPushContext.virtualServiceIndex
- }
-
if httpRoutesChanged {
log.Debugf("HTTPRoutes changed, re-initializing HTTPRoute
index")
ps.initHTTPRoutes(env)
@@ -682,14 +644,6 @@ func (ps *PushContext) updateContext(env *Environment,
oldPushContext *PushConte
ps.httpRouteIndex = oldPushContext.httpRouteIndex
}
- if meshServicesChanged {
- log.Debugf("MeshServices changed, re-initializing
DestinationRule index")
- ps.initDestinationRules(env)
- } else {
- log.Debugf("MeshServices unchanged, reusing old DestinationRule
index")
- ps.destinationRuleIndex = oldPushContext.destinationRuleIndex
- }
-
authnPoliciesChanged := pushReq != nil && (pushReq.Full ||
authPolicyKindsChanged(pushReq.ConfigsUpdated))
if authnPoliciesChanged || oldPushContext == nil ||
oldPushContext.AuthenticationPolicies == nil {
log.Debugf("security authentication policy changed (full=%v,
configsUpdatedContainingSecurityPolicy=%v), rebuilding authentication policies",
@@ -805,39 +759,6 @@ func (ps *PushContext) GetAllServices() []*Service {
return ps.servicesExportedToNamespace(NamespaceAll)
}
-func (ps *PushContext) initVirtualServices(env *Environment) {
- log.Debugf("starting MeshService route initialization")
- ps.virtualServiceIndex.referencedDestinations = map[string]sets.String{}
- meshservices := env.List(gvk.MeshService, NamespaceAll)
- log.Debugf("found %d MeshService configs", len(meshservices))
- vsroutes := make([]config.Config, len(meshservices))
-
- for i, r := range meshservices {
- vsroutes[i] = meshServiceToVirtualServiceConfig(r)
- if vs, ok := vsroutes[i].Spec.(*networking.VirtualService); ok {
- log.Debugf("MeshService %s/%s produced hosts %v and %d
HTTP routes",
- r.Namespace, r.Name, vs.Hosts, len(vs.Http))
- } else if ms, ok := r.Spec.(*networking.MeshService); ok {
- log.Debugf("MeshService %s/%s with hosts %v and %d
routes",
- r.Namespace, r.Name, ms.Hosts, len(ms.Routes))
- }
- }
-
- hostToRoutes := make(map[host.Name][]config.Config)
- for i := range vsroutes {
- vs := vsroutes[i].Spec.(*networking.VirtualService)
- for idx, h := range vs.Hosts {
- resolvedHost := string(ResolveShortnameToFQDN(h,
vsroutes[i].Meta))
- vs.Hosts[idx] = resolvedHost
- hostName := host.Name(resolvedHost)
- hostToRoutes[hostName] = append(hostToRoutes[hostName],
vsroutes[i])
- log.Debugf("indexed VirtualService %s/%s for hostname
%s", vsroutes[i].Namespace, vsroutes[i].Name, hostName)
- }
- }
- ps.virtualServiceIndex.hostToRoutes = hostToRoutes
- log.Debugf("indexed VirtualServices for %d hostnames",
len(hostToRoutes))
-}
-
func (ps *PushContext) initHTTPRoutes(env *Environment) {
log.Debugf("starting HTTPRoute initialization")
httproutes := env.List(gvk.HTTPRoute, NamespaceAll)
@@ -1037,33 +958,6 @@ func (ps *PushContext) setDestinationRules(configs
[]config.Config) {
}
}
-func (ps *PushContext) initDestinationRules(env *Environment) {
- configs := env.List(gvk.MeshService, NamespaceAll)
- log.Debugf("initDestinationRules: found %d MeshService configs",
len(configs))
-
- // values returned from ConfigStore.List are immutable.
- // Therefore, we make copies.
- subRules := make([]config.Config, 0, len(configs))
- for i := range configs {
- rules := meshServiceToDestinationRuleConfigs(configs[i])
- for j := range rules {
- subRules = append(subRules, rules[j])
- }
- for _, rule := range rules {
- if dr, ok := rule.Spec.(*networking.DestinationRule);
ok {
- tlsMode := "none"
- if dr.TrafficPolicy != nil &&
dr.TrafficPolicy.Tls != nil {
- tlsMode =
dr.TrafficPolicy.Tls.Mode.String()
- }
- log.Debugf("initDestinationRules: MeshService
%s/%s for host %s with %d subsets, TLS mode: %s",
- configs[i].Namespace, configs[i].Name,
dr.Host, len(dr.Subsets), tlsMode)
- }
- }
- }
-
- ps.setDestinationRules(subRules)
-}
-
func (ps *PushContext) initServiceAccounts(env *Environment, services
[]*Service) {
for _, svc := range services {
var accounts sets.String
diff --git a/dubbod/discovery/pkg/model/push_context_test.go
b/dubbod/discovery/pkg/model/push_context_test.go
index 74519602..02f95714 100644
--- a/dubbod/discovery/pkg/model/push_context_test.go
+++ b/dubbod/discovery/pkg/model/push_context_test.go
@@ -41,7 +41,7 @@ func TestPushRequestCopyMergePreservesQueuedUpdates(t
*testing.T) {
}
incoming := &PushRequest{
Reason: NewReasonStats(ConfigUpdate),
- ConfigsUpdated: sets.New(ConfigKey{Kind: kind.MeshService,
Name: "nginx", Namespace: "app"}),
+ ConfigsUpdated: sets.New(ConfigKey{Kind:
kind.PeerAuthentication, Name: "default", Namespace: "app"}),
AddressesUpdated: sets.New("10.0.0.2"),
Full: true,
Forced: true,
diff --git a/dubbod/discovery/pkg/networking/grpcgen/mtls_test.go
b/dubbod/discovery/pkg/networking/grpcgen/mtls_test.go
index 76d01955..7f5a637d 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/mtls_test.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/mtls_test.go
@@ -5,41 +5,14 @@ import (
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/model"
"github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/host"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
"github.com/apache/dubbo-kubernetes/pkg/dubboagency/grpcxds"
- networking "github.com/kdubbo/api/networking/v1alpha3"
security "github.com/kdubbo/api/security/v1alpha3"
cluster "github.com/kdubbo/xds-api/cluster/v1"
tlsv1 "github.com/kdubbo/xds-api/extensions/transport_sockets/tls/v1"
listener "github.com/kdubbo/xds-api/listener/v1"
)
-func TestMeshServiceDUBBOMutualBuildsUpstreamTLS(t *testing.T) {
- hostname := host.Name("nginx.app.svc.cluster.local")
- clusterName := model.BuildSubsetKey(model.TrafficDirectionOutbound, "",
hostname, 80)
- push := newRDSTestPushContext(t, []config.Config{
- newMTLSMeshServiceConfig("nginx-mtls", "app", hostname),
- }, []*model.Service{
- newRDSTestService("nginx", "app", string(hostname), 80),
- })
-
- resources := (&GrpcConfigGenerator{}).BuildClusters(newMTLSTestProxy(),
push, []string{clusterName})
- c := findCluster(t, resources, clusterName)
- if c.GetTransportSocket() == nil {
- t.Fatalf("cluster %s has no transport socket", clusterName)
- }
-
- tlsContext := &tlsv1.UpstreamTlsContext{}
- if err :=
c.GetTransportSocket().GetTypedConfig().UnmarshalTo(tlsContext); err != nil {
- t.Fatalf("unmarshal upstream tls context: %v", err)
- }
- if tlsContext.GetSni() != string(hostname) {
- t.Fatalf("SNI = %q, want %q", tlsContext.GetSni(), hostname)
- }
- assertCommonTLSContext(t, tlsContext.GetCommonTlsContext())
-}
-
func TestPeerAuthenticationStrictBuildsDownstreamMTLSListener(t *testing.T) {
svc := newRDSTestService("nginx", "app", "nginx.app.svc.cluster.local",
80)
proxy := newMTLSTestProxy()
@@ -154,40 +127,6 @@ func newMTLSTestProxy() *model.Proxy {
}
}
-func newMTLSMeshServiceConfig(name, namespace string, hostname host.Name)
config.Config {
- return config.Config{
- Meta: config.Meta{
- GroupVersionKind: gvk.MeshService,
- Name: name,
- Namespace: namespace,
- Domain: "cluster.local",
- },
- Spec: &networking.MeshService{
- Hosts: []string{string(hostname)},
- TrafficPolicy: &networking.TrafficPolicy{
- Tls: &networking.ClientTLSSettings{
- Mode:
networking.ClientTLSSettings_DUBBO_MUTUAL,
- },
- },
- Routes: []*networking.MeshServiceRoute{{
- Service: []*networking.ServiceDestination{{
- Name: "v1",
- Host: string(hostname),
- Labels: map[string]string{"version":
"v1"},
- Port: &networking.ServicePort{Number:
80},
- Weight: 50,
- }, {
- Name: "v2",
- Host: string(hostname),
- Labels: map[string]string{"version":
"v2"},
- Port: &networking.ServicePort{Number:
80},
- Weight: 50,
- }},
- }},
- },
- }
-}
-
func newStrictPeerAuthenticationConfig(name, namespace string) config.Config {
return newPeerAuthenticationConfig(name, namespace,
security.PeerAuthentication_MutualTLS_STRICT)
}
diff --git a/dubbod/discovery/pkg/networking/grpcgen/rds.go
b/dubbod/discovery/pkg/networking/grpcgen/rds.go
index 95909283..55d3f778 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/rds.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/rds.go
@@ -18,7 +18,6 @@ package grpcgen
import (
"fmt"
- "sort"
"strconv"
"strings"
@@ -28,7 +27,6 @@ import (
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/model"
"github.com/apache/dubbo-kubernetes/pkg/config"
"github.com/apache/dubbo-kubernetes/pkg/config/host"
- networking "github.com/kdubbo/api/networking/v1alpha3"
route "github.com/kdubbo/xds-api/route/v1"
matcher "github.com/kdubbo/xds-api/type/matcher/v1"
"google.golang.org/protobuf/types/known/wrapperspb"
@@ -102,7 +100,7 @@ func buildHTTPRoute(node *model.Proxy, push
*model.PushContext, routeName string
if node.IsRouter() {
// Gateway routers use Gateway API HTTPRoute;
service-to-service proxyless clients
- // must not let an unrelated north-south HTTPRoute
shadow their VirtualService.
+ // must not let an unrelated north-south HTTPRoute
shadow their service route.
httpRoutes := push.HTTPRouteForHost(host.Name("*"))
if len(httpRoutes) == 0 {
log.Debugf("no HTTPRoute found for router host
%s, using default route", hostStr)
@@ -143,16 +141,16 @@ func buildHTTPRoute(node *model.Proxy, push
*model.PushContext, routeName string
log.Warnf("HTTPRoute found but no
routes built")
}
}
- } else if vs := push.VirtualServiceForHost(host.Name(hostStr));
vs != nil {
- log.Infof("found VirtualService for host %s with %d
HTTP routes", hostStr, len(vs.Http))
- if routes := buildRoutesFromVirtualService(vs,
host.Name(hostStr), parsedPort); len(routes) > 0 {
- log.Infof("built %d weighted routes from
VirtualService for host %s", len(routes), hostStr)
+ } else if httpRoutes :=
filterHTTPRoutesByService(push.HTTPRouteForHost(host.Name(hostStr)), svc,
parsedPort); len(httpRoutes) > 0 {
+ log.Infof("found %d service-attached HTTPRoute(s) for
host %s", len(httpRoutes), hostStr)
+ if routes :=
buildRoutesFromGatewayHTTPRoute(httpRoutes, host.Name(hostStr), parsedPort);
len(routes) > 0 {
+ log.Infof("built %d routes from
service-attached HTTPRoute for host %s", len(routes), hostStr)
outboundRoutes = routes
} else {
- log.Warnf("VirtualService found but no routes
built for host %s", hostStr)
+ log.Warnf("service-attached HTTPRoute found but
no routes built for host %s", hostStr)
}
} else {
- log.Debugf("no HTTPRoute or VirtualService found for
host %s, using default route", hostStr)
+ log.Debugf("no service-attached HTTPRoute found for
host %s, using default route", hostStr)
}
return &route.RouteConfiguration{
@@ -330,108 +328,6 @@ func defaultSingleClusterRoute(clusterName string)
*route.Route {
}
}
-func buildRoutesFromVirtualService(vs *networking.VirtualService, hostName
host.Name, defaultPort int) []*route.Route {
- if vs == nil || len(vs.Http) == 0 {
- return nil
- }
- var routes []*route.Route
- for _, httpRoute := range vs.Http {
- if httpRoute == nil {
- continue
- }
- routes = append(routes, buildRoutesFromHTTPRoute(httpRoute,
hostName, defaultPort)...)
- }
- return routes
-}
-
-func buildRoutesFromHTTPRoute(httpRoute *networking.HTTPRoute, hostName
host.Name, defaultPort int) []*route.Route {
- action := buildRouteActionFromHTTPRoute(httpRoute, hostName,
defaultPort)
- if action == nil {
- return nil
- }
- matches := httpRoute.GetMatch()
- if len(matches) == 0 {
- return []*route.Route{{
- Match: defaultRouteMatch(),
- Action: &route.Route_Route{
- Route: action,
- },
- }}
- }
- routes := make([]*route.Route, 0, len(matches))
- for _, match := range matches {
- routes = append(routes, &route.Route{
- Match: buildRouteMatchFromMeshServiceMatch(match),
- Action: &route.Route_Route{
- Route: action,
- },
- })
- }
- return routes
-}
-
-func buildRouteActionFromHTTPRoute(httpRoute *networking.HTTPRoute, hostName
host.Name, defaultPort int) *route.RouteAction {
- if httpRoute == nil || len(httpRoute.Route) == 0 {
- log.Warnf("httpRoute is nil or has no routes")
- return nil
- }
- log.Debugf("processing HTTPRoute with %d route destinations",
len(httpRoute.Route))
- weights := make([]*route.WeightedCluster_ClusterWeight, 0,
len(httpRoute.Route))
- var totalWeight uint32
- for i, dest := range httpRoute.Route {
- if dest == nil {
- log.Warnf("route[%d] is nil", i)
- continue
- }
- destination := dest.Destination
- if destination == nil {
- log.Warnf("route[%d] has nil Destination (weight=%d),
creating default destination with host=%s",
- i, dest.Weight, hostName)
- destination = &networking.Destination{
- Host: string(hostName),
- }
- } else {
- log.Debugf("route[%d] Destination: host=%s, subset=%s,
weight=%d",
- i, destination.Host, destination.Subset,
dest.Weight)
- }
- targetHost := destination.Host
- if targetHost == "" {
- targetHost = string(hostName)
- }
- targetPort := defaultPort
- subsetName := destination.Subset
- clusterName :=
model.BuildSubsetKey(model.TrafficDirectionOutbound, subsetName,
host.Name(targetHost), targetPort)
- weight := dest.Weight
- if weight <= 0 {
- weight = 1
- }
- totalWeight += uint32(weight)
- log.Debugf("route[%d] -> cluster=%s, subset=%s, weight=%d,
host=%s, port=%d",
- i, clusterName, subsetName, weight, targetHost,
targetPort)
- weights = append(weights, &route.WeightedCluster_ClusterWeight{
- Name: clusterName,
- Weight: wrapperspb.UInt32(uint32(weight)),
- })
- }
- if len(weights) == 0 {
- log.Warnf("no valid weights generated")
- return nil
- }
- weightedClusters := &route.WeightedCluster{
- Clusters: weights,
- }
- if totalWeight > 0 {
- weightedClusters.TotalWeight = wrapperspb.UInt32(totalWeight)
- }
- log.Debugf("built WeightedCluster with %d clusters, totalWeight=%d",
len(weights), totalWeight)
-
- return &route.RouteAction{
- ClusterSpecifier: &route.RouteAction_WeightedClusters{
- WeightedClusters: weightedClusters,
- },
- }
-}
-
func defaultRouteMatch() *route.RouteMatch {
return &route.RouteMatch{
PathSpecifier: &route.RouteMatch_Prefix{
@@ -440,79 +336,6 @@ func defaultRouteMatch() *route.RouteMatch {
}
}
-func buildRouteMatchFromMeshServiceMatch(match *networking.HTTPMatchRequest)
*route.RouteMatch {
- if match == nil {
- return defaultRouteMatch()
- }
- routeMatch := &route.RouteMatch{}
- applyRoutePathSpecifier(routeMatch, match.GetUri())
- if routeMatch.PathSpecifier == nil {
- routeMatch.PathSpecifier = &route.RouteMatch_Prefix{Prefix: "/"}
- }
-
- headers := make([]*route.HeaderMatcher, 0, len(match.GetHeaders())+2)
- for _, key := range sortedStringMatchKeys(match.GetHeaders()) {
- if header := headerMatcherFromStringMatch(key,
match.GetHeaders()[key]); header != nil {
- headers = append(headers, header)
- }
- }
- if header := headerMatcherFromStringMatch(":method",
match.GetMethod()); header != nil {
- headers = append(headers, header)
- }
- if header := headerMatcherFromStringMatch(":authority",
match.GetHost()); header != nil {
- headers = append(headers, header)
- }
- if len(headers) > 0 {
- routeMatch.Headers = headers
- }
- return routeMatch
-}
-
-func sortedStringMatchKeys(values map[string]*networking.StringMatch) []string
{
- keys := make([]string, 0, len(values))
- for key := range values {
- keys = append(keys, key)
- }
- sort.Strings(keys)
- return keys
-}
-
-func applyRoutePathSpecifier(routeMatch *route.RouteMatch, match
*networking.StringMatch) {
- if match == nil {
- return
- }
- switch m := match.MatchType.(type) {
- case *networking.StringMatch_Exact:
- routeMatch.PathSpecifier = &route.RouteMatch_Path{Path: m.Exact}
- case *networking.StringMatch_Prefix:
- routeMatch.PathSpecifier = &route.RouteMatch_Prefix{Prefix:
m.Prefix}
- case *networking.StringMatch_Regex:
- routeMatch.PathSpecifier = &route.RouteMatch_SafeRegex{
- SafeRegex: &matcher.RegexMatcher{Regex: m.Regex},
- }
- }
-}
-
-func headerMatcherFromStringMatch(name string, match *networking.StringMatch)
*route.HeaderMatcher {
- if match == nil {
- return nil
- }
- header := &route.HeaderMatcher{Name: name}
- switch m := match.MatchType.(type) {
- case *networking.StringMatch_Exact:
- header.HeaderMatchSpecifier =
&route.HeaderMatcher_ExactMatch{ExactMatch: m.Exact}
- case *networking.StringMatch_Prefix:
- header.HeaderMatchSpecifier =
&route.HeaderMatcher_PrefixMatch{PrefixMatch: m.Prefix}
- case *networking.StringMatch_Regex:
- header.HeaderMatchSpecifier =
&route.HeaderMatcher_SafeRegexMatch{
- SafeRegexMatch: &matcher.RegexMatcher{Regex: m.Regex},
- }
- default:
- return nil
- }
- return header
-}
-
// buildRoutesFromGatewayHTTPRoute converts Gateway API HTTPRoute resources to
XDS Route configurations
func buildRoutesFromGatewayHTTPRoute(httpRoutes []config.Config, hostName
host.Name, defaultPort int) []*route.Route {
if len(httpRoutes) == 0 {
@@ -659,6 +482,58 @@ func filterHTTPRoutesByGateway(httpRoutes []config.Config,
gatewayName, gatewayN
return filtered
}
+func filterHTTPRoutesByService(httpRoutes []config.Config, svc *model.Service,
port int) []config.Config {
+ if svc == nil {
+ return nil
+ }
+ var filtered []config.Config
+ for _, hr := range httpRoutes {
+ hrSpec, ok := hr.Spec.(*sigsk8siogatewayapiapisv1.HTTPRouteSpec)
+ if !ok {
+ continue
+ }
+ if httpRouteReferencesService(hrSpec, hr.Namespace, svc, port) {
+ filtered = append(filtered, hr)
+ log.Debugf("HTTPRoute %s/%s matches Service %s/%s port
%d",
+ hr.Namespace, hr.Name,
svc.Attributes.Namespace, svc.Attributes.Name, port)
+ }
+ }
+ return filtered
+}
+
+func httpRouteReferencesService(hrSpec
*sigsk8siogatewayapiapisv1.HTTPRouteSpec, routeNamespace string, svc
*model.Service, port int) bool {
+ for _, parentRef := range hrSpec.ParentRefs {
+ if !isServiceParentRef(parentRef) {
+ continue
+ }
+ refNamespace := routeNamespace
+ if parentRef.Namespace != nil {
+ refNamespace = string(*parentRef.Namespace)
+ }
+ if refNamespace != svc.Attributes.Namespace ||
string(parentRef.Name) != svc.Attributes.Name {
+ continue
+ }
+ if parentRef.Port != nil && int32(*parentRef.Port) !=
int32(port) {
+ continue
+ }
+ if parentRef.SectionName != nil {
+ svcPort, found := svc.Ports.GetByPort(port)
+ if !found || svcPort.Name !=
string(*parentRef.SectionName) {
+ continue
+ }
+ }
+ return true
+ }
+ return false
+}
+
+func isServiceParentRef(parentRef sigsk8siogatewayapiapisv1.ParentReference)
bool {
+ if parentRef.Kind == nil || string(*parentRef.Kind) != "Service" {
+ return false
+ }
+ return parentRef.Group == nil || string(*parentRef.Group) == ""
+}
+
// buildRouteMatchFromHTTPRouteMatches converts Gateway API HTTPRouteMatch to
XDS RouteMatch
func buildRouteMatchFromHTTPRouteMatches(matches
[]sigsk8siogatewayapiapisv1.HTTPRouteMatch) *route.RouteMatch {
if len(matches) == 0 {
diff --git a/dubbod/discovery/pkg/networking/grpcgen/rds_test.go
b/dubbod/discovery/pkg/networking/grpcgen/rds_test.go
index 2b8f21da..9573a07f 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/rds_test.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/rds_test.go
@@ -29,15 +29,13 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config/schema/collections"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
"github.com/apache/dubbo-kubernetes/pkg/kube/krt"
- networking "github.com/kdubbo/api/networking/v1alpha3"
route "github.com/kdubbo/xds-api/route/v1"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
)
-func
TestBuildHTTPRouteProxylessOutboundPrefersVirtualServiceOverGatewayHTTPRoute(t
*testing.T) {
+func TestBuildHTTPRouteProxylessOutboundIgnoresGatewayAttachedHTTPRoute(t
*testing.T) {
push := newRDSTestPushContext(t, []config.Config{
newWildcardHTTPRouteConfig("httpbin", "default", 8000),
- newWeightedMeshServiceConfig("nginx-weights", "app",
"nginx.app.svc.cluster.local"),
}, []*model.Service{
newRDSTestService("nginx", "app",
"nginx.app.svc.cluster.local", 80),
newRDSTestService("httpbin", "default",
"httpbin.default.svc.cluster.local", 8000),
@@ -61,30 +59,24 @@ func
TestBuildHTTPRouteProxylessOutboundPrefersVirtualServiceOverGatewayHTTPRout
t.Fatalf("routes = %d, want 1", len(rc.VirtualHosts[0].Routes))
}
- got := weightedClustersByName(t, rc.VirtualHosts[0].Routes[0])
- want := map[string]uint32{
- "outbound|80||nginx-v1.app.svc.cluster.local": 20,
- "outbound|80||nginx-v2.app.svc.cluster.local": 80,
- }
- if !reflect.DeepEqual(got, want) {
- t.Fatalf("weighted clusters = %v, want %v", got, want)
- }
- if _, found := got["outbound|8000||httpbin.default.svc.cluster.local"];
found {
- t.Fatalf("proxyless outbound route used Gateway HTTPRoute
backend: %v", got)
+ if got := rc.VirtualHosts[0].Routes[0].GetRoute().GetCluster(); got !=
"outbound|80||nginx.app.svc.cluster.local" {
+ t.Fatalf("route cluster = %q, want default nginx cluster", got)
}
}
-func TestBuildHTTPRouteFromMeshServiceRulesPreservesMatchesAndFallback(t
*testing.T) {
+func TestBuildHTTPRouteProxylessOutboundUsesServiceAttachedHTTPRoute(t
*testing.T) {
push := newRDSTestPushContext(t, []config.Config{
- newMatchedMeshServiceConfig("product-routing", "default",
"product.default.svc.cluster.local"),
+ newServiceAttachedHTTPRouteConfig("reviews-routing",
"moviereview", "reviews", 9080),
}, []*model.Service{
- newRDSTestService("product", "default",
"product.default.svc.cluster.local", 80),
+ newRDSTestService("reviews", "moviereview",
"reviews.moviereview.svc.cluster.local", 9080),
+ newRDSTestService("reviews-v1", "moviereview",
"reviews-v1.moviereview.svc.cluster.local", 9080),
+ newRDSTestService("reviews-v2", "moviereview",
"reviews-v2.moviereview.svc.cluster.local", 9080),
})
rc := buildHTTPRoute(
- &model.Proxy{ID: "consumer.default", Type: model.Proxyless},
+ &model.Proxy{ID: "moviepage.moviereview", Type:
model.Proxyless},
push,
- "outbound|80||product.default.svc.cluster.local",
+ "outbound|9080||reviews.moviereview.svc.cluster.local",
)
if rc == nil {
t.Fatal("buildHTTPRoute() returned nil")
@@ -93,9 +85,7 @@ func
TestBuildHTTPRouteFromMeshServiceRulesPreservesMatchesAndFallback(t *testin
if len(routes) != 2 {
t.Fatalf("routes = %d, want matched route plus fallback",
len(routes))
}
- if got := routes[0].GetMatch().GetPrefix(); got != "/product" {
- t.Fatalf("first route prefix = %q, want /product", got)
- }
+
headers := routes[0].GetMatch().GetHeaders()
if len(headers) != 1 || headers[0].GetName() != "end-user" ||
headers[0].GetExactMatch() != "jason" {
t.Fatalf("first route headers = %v, want end-user exact jason",
headers)
@@ -103,7 +93,7 @@ func
TestBuildHTTPRouteFromMeshServiceRulesPreservesMatchesAndFallback(t *testin
first := weightedClustersByName(t, routes[0])
wantFirst := map[string]uint32{
- "outbound|80|v1|product.default.svc.cluster.local": 100,
+ "outbound|9080||reviews-v2.moviereview.svc.cluster.local": 100,
}
if !reflect.DeepEqual(first, wantFirst) {
t.Fatalf("first route weighted clusters = %v, want %v", first,
wantFirst)
@@ -111,8 +101,7 @@ func
TestBuildHTTPRouteFromMeshServiceRulesPreservesMatchesAndFallback(t *testin
fallback := weightedClustersByName(t, routes[1])
wantFallback := map[string]uint32{
- "outbound|80|v2|product.default.svc.cluster.local": 20,
- "outbound|80|v3|product.default.svc.cluster.local": 80,
+ "outbound|9080||reviews-v1.moviereview.svc.cluster.local": 100,
}
if !reflect.DeepEqual(fallback, wantFallback) {
t.Fatalf("fallback weighted clusters = %v, want %v", fallback,
wantFallback)
@@ -142,83 +131,6 @@ func newRDSTestPushContext(t *testing.T, configs
[]config.Config, services []*mo
return push
}
-func newWeightedMeshServiceConfig(name, namespace, hostname string)
config.Config {
- return config.Config{
- Meta: config.Meta{
- GroupVersionKind: gvk.MeshService,
- Name: name,
- Namespace: namespace,
- Domain: "cluster.local",
- },
- Spec: &networking.MeshService{
- Hosts: []string{hostname},
- Routes: []*networking.MeshServiceRoute{
- {
- Service:
[]*networking.ServiceDestination{
- {
- Name: "nginx-v1",
- Host: hostname,
- Weight: 20,
- },
- {
- Name: "nginx-v2",
- Host: hostname,
- Weight: 80,
- },
- },
- },
- },
- },
- }
-}
-
-func newMatchedMeshServiceConfig(name, namespace, hostname string)
config.Config {
- return config.Config{
- Meta: config.Meta{
- GroupVersionKind: gvk.MeshService,
- Name: name,
- Namespace: namespace,
- Domain: "cluster.local",
- },
- Spec: &networking.MeshService{
- Hosts: []string{hostname},
- Rules: []*networking.MeshServiceRule{{
- Match: []*networking.HTTPMatchRequest{{
- Uri: &networking.StringMatch{
- MatchType:
&networking.StringMatch_Prefix{Prefix: "/product"},
- },
- Headers:
map[string]*networking.StringMatch{
- "end-user": {
- MatchType:
&networking.StringMatch_Exact{Exact: "jason"},
- },
- },
- }},
- Route: []*networking.MeshServiceRoute{{
- Service:
[]*networking.ServiceDestination{{
- Name: "v1",
- Host: hostname,
- Labels:
map[string]string{"version": "v1"},
- Weight: 100,
- }},
- }},
- Routes: []*networking.MeshServiceRoute{{
- Service:
[]*networking.ServiceDestination{{
- Name: "v2",
- Host: hostname,
- Labels:
map[string]string{"version": "v2"},
- Weight: 20,
- }, {
- Name: "v3",
- Host: hostname,
- Labels:
map[string]string{"version": "v3"},
- Weight: 80,
- }},
- }},
- }},
- },
- }
-}
-
func newWildcardHTTPRouteConfig(backendName, backendNamespace string,
backendPort int32) config.Config {
port := gatewayv1.PortNumber(backendPort)
weight := int32(1)
@@ -255,6 +167,69 @@ func newWildcardHTTPRouteConfig(backendName,
backendNamespace string, backendPor
}
}
+func newServiceAttachedHTTPRouteConfig(name, namespace, parentName string,
parentPort int32) config.Config {
+ group := gatewayv1.Group("")
+ kind := gatewayv1.Kind("Service")
+ port := gatewayv1.PortNumber(parentPort)
+ weight := int32(100)
+ pathType := gatewayv1.PathMatchPathPrefix
+ pathValue := "/"
+ headerType := gatewayv1.HeaderMatchExact
+ return config.Config{
+ Meta: config.Meta{
+ GroupVersionKind: gvk.HTTPRoute,
+ Name: name,
+ Namespace: namespace,
+ Domain: "cluster.local",
+ },
+ Spec: &gatewayv1.HTTPRouteSpec{
+ CommonRouteSpec: gatewayv1.CommonRouteSpec{
+ ParentRefs: []gatewayv1.ParentReference{{
+ Group: &group,
+ Kind: &kind,
+ Name: gatewayv1.ObjectName(parentName),
+ Port: &port,
+ }},
+ },
+ Rules: []gatewayv1.HTTPRouteRule{
+ {
+ Matches: []gatewayv1.HTTPRouteMatch{{
+ Path: &gatewayv1.HTTPPathMatch{
+ Type: &pathType,
+ Value: &pathValue,
+ },
+ Headers:
[]gatewayv1.HTTPHeaderMatch{{
+ Type: &headerType,
+ Name:
gatewayv1.HTTPHeaderName("end-user"),
+ Value: "jason",
+ }},
+ }},
+ BackendRefs:
[]gatewayv1.HTTPBackendRef{{
+ BackendRef:
gatewayv1.BackendRef{
+ BackendObjectReference:
gatewayv1.BackendObjectReference{
+ Name:
gatewayv1.ObjectName("reviews-v2"),
+ Port: &port,
+ },
+ Weight: &weight,
+ },
+ }},
+ },
+ {
+ BackendRefs:
[]gatewayv1.HTTPBackendRef{{
+ BackendRef:
gatewayv1.BackendRef{
+ BackendObjectReference:
gatewayv1.BackendObjectReference{
+ Name:
gatewayv1.ObjectName("reviews-v1"),
+ Port: &port,
+ },
+ Weight: &weight,
+ },
+ }},
+ },
+ },
+ },
+ }
+}
+
func newRDSTestService(name, namespace, hostname string, port int)
*model.Service {
return &model.Service{
Hostname: host.Name(hostname),
diff --git a/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
b/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
index 6b711715..5cea8d07 100644
--- a/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
+++ b/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
@@ -136,19 +136,19 @@ func (c *Controller) syncPods() error {
}
type Options struct {
- KubernetesAPIQPS float32
- KubernetesAPIBurst int
- DomainSuffix string
- XDSUpdater model.XDSUpdater
- MeshWatcher meshwatcher.WatcherCollection
- ClusterID cluster.ID
- ClusterAliases map[string]string
- SystemNamespace string
- MeshServiceController *aggregate.Controller
- KrtDebugger *krt.DebugHandler
- SyncTimeout time.Duration
- Revision string
- ConfigCluster bool
+ KubernetesAPIQPS float32
+ KubernetesAPIBurst int
+ DomainSuffix string
+ XDSUpdater model.XDSUpdater
+ MeshWatcher meshwatcher.WatcherCollection
+ ClusterID cluster.ID
+ ClusterAliases map[string]string
+ SystemNamespace string
+ ServiceController *aggregate.Controller
+ KrtDebugger *krt.DebugHandler
+ SyncTimeout time.Duration
+ Revision string
+ ConfigCluster bool
}
func (c *Controller) Services() []*model.Service {
diff --git
a/dubbod/discovery/pkg/serviceregistry/kube/controller/multicluster.go
b/dubbod/discovery/pkg/serviceregistry/kube/controller/multicluster.go
index 0e1aba57..37de6327 100644
--- a/dubbod/discovery/pkg/serviceregistry/kube/controller/multicluster.go
+++ b/dubbod/discovery/pkg/serviceregistry/kube/controller/multicluster.go
@@ -26,7 +26,7 @@ import (
)
type kubeController struct {
- MeshServiceController *aggregate.Controller
+ ServiceController *aggregate.Controller
*Controller
stop chan struct{}
}
@@ -83,9 +83,9 @@ func NewMulticluster(
options.ConfigCluster = configCluster
kubeRegistry := NewController(client, options)
kubeController := &kubeController{
- MeshServiceController: opts.MeshServiceController,
- Controller: kubeRegistry,
- stop: stop,
+ ServiceController: opts.ServiceController,
+ Controller: kubeRegistry,
+ stop: stop,
}
mc.initializeCluster(cluster, kubeController, kubeRegistry,
options, configCluster, stop)
return kubeController
@@ -100,7 +100,7 @@ func (m *Multicluster) initializeCluster(cluster
*multicluster.Cluster, kubeCont
client := cluster.Client
// run after WorkloadHandler is added
- m.opts.MeshServiceController.AddRegistryAndRun(kubeRegistry,
clusterStopCh)
+ m.opts.ServiceController.AddRegistryAndRun(kubeRegistry, clusterStopCh)
go func() {
var shouldLead bool
diff --git a/dubbod/discovery/pkg/xds/cds.go b/dubbod/discovery/pkg/xds/cds.go
index 31566bc1..ef04bb81 100644
--- a/dubbod/discovery/pkg/xds/cds.go
+++ b/dubbod/discovery/pkg/xds/cds.go
@@ -19,7 +19,6 @@ package xds
import (
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/model"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/networking/core"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/kind"
)
type CdsGenerator struct {
@@ -33,15 +32,6 @@ func cdsNeedsPush(req *model.PushRequest, proxy
*model.Proxy) (*model.PushReques
return req, res
}
- // with TLS configuration (DUBBO_MUTUAL), CDS must be pushed to update
cluster TransportSocket.
- // Even if req.Full is false, check MeshService because it carries the
derived destination policy.
- if req != nil && req.ConfigsUpdated != nil {
- if model.HasConfigsOfKind(req.ConfigsUpdated, kind.MeshService)
{
- log.Debugf("MeshService updated, CDS push required to
update cluster TLS config")
- return req, true
- }
- }
-
if !req.Full {
return req, false
}
@@ -57,7 +47,7 @@ func (c CdsGenerator) Generate(proxy *model.Proxy, w
*model.WatchedResource, req
return nil, model.DefaultXdsLogDetails, nil
}
-// GenerateDeltas for CDS currently only builds deltas when services change.
todo implement changes for MeshService, etc
+// GenerateDeltas for CDS currently only builds deltas when services change.
func (c CdsGenerator) GenerateDeltas(proxy *model.Proxy, req
*model.PushRequest,
w *model.WatchedResource,
) (model.Resources, model.DeletedResources, model.XdsLogDetails, bool, error) {
diff --git a/dubbod/discovery/pkg/xds/eds_test.go
b/dubbod/discovery/pkg/xds/eds_test.go
index c02a7534..44b5c2b3 100644
--- a/dubbod/discovery/pkg/xds/eds_test.go
+++ b/dubbod/discovery/pkg/xds/eds_test.go
@@ -47,8 +47,8 @@ func TestEdsUpdatedServicesForRequestTargetsServiceOnlyPush(t
*testing.T) {
func TestEdsUpdatedServicesForRequestFallsBackForUntargetedConfig(t
*testing.T) {
req := &model.PushRequest{
ConfigsUpdated: sets.New(model.ConfigKey{
- Kind: kind.MeshService,
- Name: "nginx",
+ Kind: kind.PeerAuthentication,
+ Name: "default",
Namespace: "app",
}),
}
diff --git a/dubbod/discovery/pkg/xds/endpoints/endpoint_builder_test.go
b/dubbod/discovery/pkg/xds/endpoints/endpoint_builder_test.go
index a3f25413..40677091 100644
--- a/dubbod/discovery/pkg/xds/endpoints/endpoint_builder_test.go
+++ b/dubbod/discovery/pkg/xds/endpoints/endpoint_builder_test.go
@@ -12,38 +12,11 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config/mesh/meshwatcher"
"github.com/apache/dubbo-kubernetes/pkg/config/protocol"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/collections"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
- "github.com/apache/dubbo-kubernetes/pkg/kube/inject"
"github.com/apache/dubbo-kubernetes/pkg/kube/krt"
"github.com/apache/dubbo-kubernetes/pkg/kube/multicluster"
- networking "github.com/kdubbo/api/networking/v1alpha3"
endpoint "github.com/kdubbo/xds-api/endpoint/v1"
)
-func TestBuildClusterLoadAssignmentUsesXServerPortForDUBBOMutual(t *testing.T)
{
- hostname := host.Name("nginx.app.svc.cluster.local")
- svc := newEndpointTestService("nginx", "app", string(hostname), 80)
- push := newEndpointTestPushContext(t, []config.Config{
- newEndpointTestMTLSMeshService("nginx-routing", "app",
hostname),
- }, []*model.Service{svc})
- index := model.NewEndpointIndex(model.DisabledCache{})
- index.UpdateServiceEndpoints(model.ShardKey{}, string(hostname), "app",
[]*model.DubboEndpoint{{
- Addresses: []string{"10.0.0.1"},
- EndpointPort: 80,
- ServicePortName: "http",
- Labels: map[string]string{"version": "v1"},
- HealthStatus: model.Healthy,
- }}, false)
-
- clusterName := model.BuildSubsetKey(model.TrafficDirectionOutbound,
"v1", hostname, 80)
- builder := NewEndpointBuilder(clusterName, newEndpointTestProxy(), push)
- cla := builder.BuildClusterLoadAssignment(index)
-
- if got := firstEndpointPort(t, cla); got != inject.ProxylessXServerPort
{
- t.Fatalf("endpoint port = %d, want xserver port %d", got,
inject.ProxylessXServerPort)
- }
-}
-
func TestBuildClusterLoadAssignmentKeepsAppPortWithoutDUBBOMutual(t
*testing.T) {
hostname := host.Name("nginx.app.svc.cluster.local")
svc := newEndpointTestService("nginx", "app", string(hostname), 80)
@@ -187,32 +160,6 @@ func newEndpointTestService(name, namespace, hostname
string, port int) *model.S
}
}
-func newEndpointTestMTLSMeshService(name, namespace string, hostname
host.Name) config.Config {
- return config.Config{
- Meta: config.Meta{
- GroupVersionKind: gvk.MeshService,
- Name: name,
- Namespace: namespace,
- Domain: "cluster.local",
- },
- Spec: &networking.MeshService{
- Hosts: []string{string(hostname)},
- TrafficPolicy: &networking.TrafficPolicy{
- Tls: &networking.ClientTLSSettings{Mode:
networking.ClientTLSSettings_DUBBO_MUTUAL},
- },
- Routes: []*networking.MeshServiceRoute{{
- Service: []*networking.ServiceDestination{{
- Name: "v1",
- Host: string(hostname),
- Labels: map[string]string{"version":
"v1"},
- Port: &networking.ServicePort{Number:
80},
- Weight: 100,
- }},
- }},
- },
- }
-}
-
type endpointTestServiceDiscovery struct {
services []*model.Service
}
diff --git a/dubbod/discovery/pkg/xds/pushqueue_test.go
b/dubbod/discovery/pkg/xds/pushqueue_test.go
index 5b148970..b7f6d05a 100644
--- a/dubbod/discovery/pkg/xds/pushqueue_test.go
+++ b/dubbod/discovery/pkg/xds/pushqueue_test.go
@@ -34,7 +34,7 @@ func TestPushQueueEnqueueMergesPendingRequest(t *testing.T) {
})
queue.Enqueue(con, &model.PushRequest{
Reason: model.NewReasonStats(model.ConfigUpdate),
- ConfigsUpdated: sets.New(model.ConfigKey{Kind:
kind.MeshService, Name: "nginx", Namespace: "app"}),
+ ConfigsUpdated: sets.New(model.ConfigKey{Kind:
kind.PeerAuthentication, Name: "default", Namespace: "app"}),
Full: true,
})
diff --git a/dubbod/gui/resources/data/app.js b/dubbod/gui/resources/data/app.js
index ee078d61..3a7cd0df 100644
--- a/dubbod/gui/resources/data/app.js
+++ b/dubbod/gui/resources/data/app.js
@@ -344,7 +344,7 @@ const App = () => {
<table className="k-table">
<thead>
<tr>
- <th>Kind (MeshService / MeshConfig)</th>
+ <th>Kind (Gateway API / Policy)</th>
<th>Count</th>
<th>Description</th>
</tr>
diff --git a/manifests/charts/base/files/crd-all.gen.yaml
b/manifests/charts/base/files/crd-all.gen.yaml
index 5d734de9..29a1408d 100644
--- a/manifests/charts/base/files/crd-all.gen.yaml
+++ b/manifests/charts/base/files/crd-all.gen.yaml
@@ -1,423 +1,6 @@
# DO NOT EDIT - Generated by Cue OpenAPI generator based on Dubbo APIs.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
-metadata:
- annotations:
- "helm.sh/resource-policy": keep
- labels:
- app: dubbo
- chart: dubbo
- heritage: Tiller
- release: dubbo
- name: meshservices.networking.dubbo.apache.org
-spec:
- group: networking.dubbo.apache.org
- names:
- categories:
- - dubbo
- - networking
- kind: MeshService
- listKind: MeshServiceList
- plural: meshservices
- shortNames:
- - ms
- singular: meshservice
- scope: Namespaced
- versions:
- - additionalPrinterColumns:
- - description: The destination hosts to which service traffic is being sent
- jsonPath: .spec.hosts
- name: Hosts
- type: string
- - description: 'CreationTimestamp is a timestamp representing the server
time
- when this object was created. It is not guaranteed to be set in
happens-before
- order across separate operations. Clients may not set this value. It
is represented
- in RFC3339 form and is in UTC. Populated by the system. Read-only.
Null for
- lists. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
- jsonPath: .metadata.creationTimestamp
- name: Age
- type: date
- name: v1alpha3
- schema:
- openAPIV3Schema:
- properties:
- spec:
- description: 'Service-to-service routing and traffic policy. See
more
- details at: '
- properties:
- hosts:
- description: Hosts addressed by this service-to-service policy.
- items:
- type: string
- type: array
- routes:
- description: Ordered fallback route entries.
- items:
- properties:
- service:
- description: One route entry can split traffic across
multiple
- service destinations.
- items:
- properties:
- host:
- description: Host is the host addressed by this
route
- policy.
- type: string
- labels:
- additionalProperties:
- type: string
- description: Labels select a subset of endpoints
behind
- host.
- type: object
- name:
- description: Name is the target Kubernetes Service
for
- service-based traffic splitting.
- type: string
- port:
- properties:
- name:
- type: string
- number:
- maximum: 4294967295
- minimum: 0
- type: integer
- type: object
- trafficPolicy:
- properties:
- tls:
- description: TLS related settings for
connections
- to the upstream service.
- properties:
- mode:
- description: |-
- Indicates whether connections to this
port should be secured using TLS.
-
- Valid Options: DISABLE, MUTUAL,
DUBBO_MUTUAL
- enum:
- - DISABLE
- - MUTUAL
- - DUBBO_MUTUAL
- type: string
- type: object
- type: object
- weight:
- format: int32
- type: integer
- required:
- - host
- type: object
- type: array
- type: object
- type: array
- rules:
- description: Ordered routing rules.
- items:
- properties:
- match:
- description: Match conditions for the primary route
entries.
- items:
- properties:
- headers:
- additionalProperties:
- oneOf:
- - not:
- anyOf:
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- properties:
- exact:
- type: string
- prefix:
- type: string
- regex:
- type: string
- type: object
- type: object
- host:
- oneOf:
- - not:
- anyOf:
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- properties:
- exact:
- type: string
- prefix:
- type: string
- regex:
- type: string
- type: object
- method:
- oneOf:
- - not:
- anyOf:
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- properties:
- exact:
- type: string
- prefix:
- type: string
- regex:
- type: string
- type: object
- port:
- maximum: 4294967295
- minimum: 0
- type: integer
- queryParams:
- additionalProperties:
- oneOf:
- - not:
- anyOf:
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- properties:
- exact:
- type: string
- prefix:
- type: string
- regex:
- type: string
- type: object
- type: object
- uri:
- oneOf:
- - not:
- anyOf:
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- - required:
- - exact
- - required:
- - prefix
- - required:
- - regex
- properties:
- exact:
- type: string
- prefix:
- type: string
- regex:
- type: string
- type: object
- type: object
- type: array
- route:
- description: Primary route entries used when match
conditions
- are satisfied.
- items:
- properties:
- service:
- description: One route entry can split traffic
across
- multiple service destinations.
- items:
- properties:
- host:
- description: Host is the host addressed by
this
- route policy.
- type: string
- labels:
- additionalProperties:
- type: string
- description: Labels select a subset of
endpoints
- behind host.
- type: object
- name:
- description: Name is the target Kubernetes
Service
- for service-based traffic splitting.
- type: string
- port:
- properties:
- name:
- type: string
- number:
- maximum: 4294967295
- minimum: 0
- type: integer
- type: object
- trafficPolicy:
- properties:
- tls:
- description: TLS related settings for
connections
- to the upstream service.
- properties:
- mode:
- description: |-
- Indicates whether connections to
this port should be secured using TLS.
-
- Valid Options: DISABLE, MUTUAL,
DUBBO_MUTUAL
- enum:
- - DISABLE
- - MUTUAL
- - DUBBO_MUTUAL
- type: string
- type: object
- type: object
- weight:
- format: int32
- type: integer
- required:
- - host
- type: object
- type: array
- type: object
- type: array
- routes:
- description: Fallback route entries used after primary
match-specific
- routes.
- items:
- properties:
- service:
- description: One route entry can split traffic
across
- multiple service destinations.
- items:
- properties:
- host:
- description: Host is the host addressed by
this
- route policy.
- type: string
- labels:
- additionalProperties:
- type: string
- description: Labels select a subset of
endpoints
- behind host.
- type: object
- name:
- description: Name is the target Kubernetes
Service
- for service-based traffic splitting.
- type: string
- port:
- properties:
- name:
- type: string
- number:
- maximum: 4294967295
- minimum: 0
- type: integer
- type: object
- trafficPolicy:
- properties:
- tls:
- description: TLS related settings for
connections
- to the upstream service.
- properties:
- mode:
- description: |-
- Indicates whether connections to
this port should be secured using TLS.
-
- Valid Options: DISABLE, MUTUAL,
DUBBO_MUTUAL
- enum:
- - DISABLE
- - MUTUAL
- - DUBBO_MUTUAL
- type: string
- type: object
- type: object
- weight:
- format: int32
- type: integer
- required:
- - host
- type: object
- type: array
- type: object
- type: array
- type: object
- type: array
- trafficPolicy:
- description: Default traffic policy for every destination in
this
- MeshService.
- properties:
- tls:
- description: TLS related settings for connections to the
upstream
- service.
- properties:
- mode:
- description: |-
- Indicates whether connections to this port should be
secured using TLS.
-
- Valid Options: DISABLE, MUTUAL, DUBBO_MUTUAL
- enum:
- - DISABLE
- - MUTUAL
- - DUBBO_MUTUAL
- type: string
- type: object
- type: object
- type: object
- status:
- properties:
- conditions:
- items:
- properties:
- observedGeneration:
- anyOf:
- - type: integer
- - type: string
- x-kubernetes-int-or-string: true
- reason:
- type: string
- status:
- type: string
- type:
- type: string
- type: object
- type: array
- type: object
- x-kubernetes-preserve-unknown-fields: true
- type: object
- served: true
- storage: true
- subresources:
- status: {}
----
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
metadata:
annotations:
"helm.sh/resource-policy": keep
diff --git a/manifests/charts/dubbod/templates/clusterrole.yaml
b/manifests/charts/dubbod/templates/clusterrole.yaml
index d33b2acc..7b365dfa 100644
--- a/manifests/charts/dubbod/templates/clusterrole.yaml
+++ b/manifests/charts/dubbod/templates/clusterrole.yaml
@@ -18,7 +18,7 @@ kind: ClusterRole
metadata:
name: dubbod-clusterrole-dubbo-system
rules:
- - apiGroups: [ "security.dubbo.apache.org", "networking.dubbo.apache.org" ]
+ - apiGroups: [ "security.dubbo.apache.org" ]
verbs: [ "get", "watch", "list" ]
resources: [ "*" ]
- apiGroups: ["admissionregistration.k8s.io"]
diff --git
a/manifests/charts/dubbod/templates/validatingwebhookconfiguration.yaml
b/manifests/charts/dubbod/templates/validatingwebhookconfiguration.yaml
index a9649fd3..17963668 100644
--- a/manifests/charts/dubbod/templates/validatingwebhookconfiguration.yaml
+++ b/manifests/charts/dubbod/templates/validatingwebhookconfiguration.yaml
@@ -43,7 +43,6 @@ webhooks:
- UPDATE
apiGroups:
- security.dubbo.apache.org
- - networking.dubbo.apache.org
apiVersions:
- "*"
resources:
diff --git a/pkg/config/schema/codegen/templates/clients.go.tmpl
b/pkg/config/schema/codegen/templates/clients.go.tmpl
index 9f51bfd5..4308f610 100644
--- a/pkg/config/schema/codegen/templates/clients.go.tmpl
+++ b/pkg/config/schema/codegen/templates/clients.go.tmpl
@@ -17,7 +17,6 @@ import (
ktypes "github.com/apache/dubbo-kubernetes/pkg/kube/kubetypes"
"github.com/apache/dubbo-kubernetes/pkg/util/ptr"
- apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/kdubbo/client-go/pkg/apis/networking/v1alpha3"
apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/kdubbo/client-go/pkg/apis/security/v1alpha3"
{{- range .Packages}}
{{.ImportName}} "{{.PackageName}}"
diff --git a/pkg/config/schema/codegen/templates/crdclient.go.tmpl
b/pkg/config/schema/codegen/templates/crdclient.go.tmpl
index 4a439f08..fc2a4c84 100644
--- a/pkg/config/schema/codegen/templates/crdclient.go.tmpl
+++ b/pkg/config/schema/codegen/templates/crdclient.go.tmpl
@@ -14,7 +14,6 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
"github.com/apache/dubbo-kubernetes/pkg/kube"
- apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/kdubbo/client-go/pkg/apis/networking/v1alpha3"
apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/kdubbo/client-go/pkg/apis/security/v1alpha3"
{{- range .Packages}}
{{.ImportName}} "{{.PackageName}}"
diff --git a/pkg/config/schema/codegen/templates/types.go.tmpl
b/pkg/config/schema/codegen/templates/types.go.tmpl
index 0dbf5e19..f064a420 100644
--- a/pkg/config/schema/codegen/templates/types.go.tmpl
+++ b/pkg/config/schema/codegen/templates/types.go.tmpl
@@ -8,7 +8,6 @@ import (
{{- range .Packages}}
{{.ImportName}} "{{.PackageName}}"
{{- end}}
- apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/kdubbo/client-go/pkg/apis/networking/v1alpha3"
apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/kdubbo/client-go/pkg/apis/security/v1alpha3"
)
diff --git a/pkg/config/schema/collections/collections.gen.go
b/pkg/config/schema/collections/collections.gen.go
index 906deef6..3deca42d 100755
--- a/pkg/config/schema/collections/collections.gen.go
+++ b/pkg/config/schema/collections/collections.gen.go
@@ -13,7 +13,6 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config/validation"
githubcomkdubboapimeshv1alpha1 "github.com/kdubbo/api/mesh/v1alpha1"
githubcomkdubboapimetav1alpha1 "github.com/kdubbo/api/meta/v1alpha1"
- githubcomkdubboapinetworkingv1alpha3
"github.com/kdubbo/api/networking/v1alpha3"
githubcomkdubboapisecurityv1alpha3
"github.com/kdubbo/api/security/v1alpha3"
k8sioapiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
k8sioapiappsv1 "k8s.io/api/apps/v1"
@@ -231,21 +230,6 @@ var (
ValidateProto: validation.EmptyValidate,
}.MustBuild()
- MeshService = resource.Builder{
- Identifier: "MeshService",
- Group: "networking.dubbo.apache.org",
- Kind: "MeshService",
- Plural: "meshservices",
- Version: "v1alpha3",
- Proto: "dubbo.networking.v1alpha3.MeshService",
StatusProto: "dubbo.meta.v1alpha1.DubboStatus",
- ReflectType:
reflect.TypeOf(&githubcomkdubboapinetworkingv1alpha3.MeshService{}).Elem(),
StatusType:
reflect.TypeOf(&githubcomkdubboapimetav1alpha1.DubboStatus{}).Elem(),
- ProtoPackage: "github.com/kdubbo/api/networking/v1alpha3",
StatusPackage: "github.com/kdubbo/api/meta/v1alpha1",
- ClusterScoped: false,
- Synthetic: false,
- Builtin: false,
- ValidateProto: validation.EmptyValidate,
- }.MustBuild()
-
MutatingWebhookConfiguration = resource.Builder{
Identifier: "MutatingWebhookConfiguration",
Group: "admissionregistration.k8s.io",
@@ -441,7 +425,6 @@ var (
MustAdd(KubernetesGateway).
MustAdd(Lease).
MustAdd(MeshConfig).
- MustAdd(MeshService).
MustAdd(MutatingWebhookConfiguration).
MustAdd(Namespace).
MustAdd(Node).
@@ -484,7 +467,6 @@ var (
// Dubbo contains only collections used by Dubbo.
Dubbo = collection.NewSchemasBuilder().
MustAdd(AuthorizationPolicy).
- MustAdd(MeshService).
MustAdd(PeerAuthentication).
MustAdd(RequestAuthentication).
Build()
@@ -495,7 +477,6 @@ var (
MustAdd(GatewayClass).
MustAdd(HTTPRoute).
MustAdd(KubernetesGateway).
- MustAdd(MeshService).
MustAdd(PeerAuthentication).
MustAdd(RequestAuthentication).
Build()
@@ -506,7 +487,6 @@ var (
MustAdd(GatewayClass).
MustAdd(HTTPRoute).
MustAdd(KubernetesGateway).
- MustAdd(MeshService).
MustAdd(PeerAuthentication).
MustAdd(RequestAuthentication).
Build()
diff --git a/pkg/config/schema/gvk/resources.gen.go
b/pkg/config/schema/gvk/resources.gen.go
index 6a55df55..777f04e2 100755
--- a/pkg/config/schema/gvk/resources.gen.go
+++ b/pkg/config/schema/gvk/resources.gen.go
@@ -26,7 +26,6 @@ var (
KubernetesGateway_v1 = config.GroupVersionKind{Group:
"gateway.networking.k8s.io", Version: "v1", Kind: "Gateway"}
Lease = config.GroupVersionKind{Group:
"coordination.k8s.io", Version: "v1", Kind: "Lease"}
MeshConfig = config.GroupVersionKind{Group: "",
Version: "v1alpha1", Kind: "MeshConfig"}
- MeshService = config.GroupVersionKind{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Kind: "MeshService"}
MutatingWebhookConfiguration = config.GroupVersionKind{Group:
"admissionregistration.k8s.io", Version: "v1", Kind:
"MutatingWebhookConfiguration"}
Namespace = config.GroupVersionKind{Group: "",
Version: "v1", Kind: "Namespace"}
Node = config.GroupVersionKind{Group: "",
Version: "v1", Kind: "Node"}
@@ -76,8 +75,6 @@ func ToGVR(g config.GroupVersionKind)
(schema.GroupVersionResource, bool) {
return gvr.Lease, true
case MeshConfig:
return gvr.MeshConfig, true
- case MeshService:
- return gvr.MeshService, true
case MutatingWebhookConfiguration:
return gvr.MutatingWebhookConfiguration, true
case Namespace:
@@ -135,8 +132,6 @@ func MustToKind(g config.GroupVersionKind) kind.Kind {
return kind.Lease
case MeshConfig:
return kind.MeshConfig
- case MeshService:
- return kind.MeshService
case MutatingWebhookConfiguration:
return kind.MutatingWebhookConfiguration
case Namespace:
@@ -205,8 +200,6 @@ func FromGVR(g schema.GroupVersionResource)
(config.GroupVersionKind, bool) {
return Lease, true
case gvr.MeshConfig:
return MeshConfig, true
- case gvr.MeshService:
- return MeshService, true
case gvr.MutatingWebhookConfiguration:
return MutatingWebhookConfiguration, true
case gvr.Namespace:
diff --git a/pkg/config/schema/gvr/resources.gen.go
b/pkg/config/schema/gvr/resources.gen.go
index 7c5a8b35..5affdbcc 100755
--- a/pkg/config/schema/gvr/resources.gen.go
+++ b/pkg/config/schema/gvr/resources.gen.go
@@ -21,7 +21,6 @@ var (
KubernetesGateway_v1 = schema.GroupVersionResource{Group:
"gateway.networking.k8s.io", Version: "v1", Resource: "gateways"}
Lease = schema.GroupVersionResource{Group:
"coordination.k8s.io", Version: "v1", Resource: "leases"}
MeshConfig = schema.GroupVersionResource{Group: "",
Version: "v1alpha1", Resource: "meshconfigs"}
- MeshService = schema.GroupVersionResource{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Resource: "meshservices"}
MutatingWebhookConfiguration = schema.GroupVersionResource{Group:
"admissionregistration.k8s.io", Version: "v1", Resource:
"mutatingwebhookconfigurations"}
Namespace = schema.GroupVersionResource{Group: "",
Version: "v1", Resource: "namespaces"}
Node = schema.GroupVersionResource{Group: "",
Version: "v1", Resource: "nodes"}
@@ -68,8 +67,6 @@ func IsClusterScoped(g schema.GroupVersionResource) bool {
return false
case Lease:
return false
- case MeshService:
- return false
case MutatingWebhookConfiguration:
return true
case Namespace:
diff --git a/pkg/config/schema/kind/resources.gen.go
b/pkg/config/schema/kind/resources.gen.go
index b231391e..4707c01f 100755
--- a/pkg/config/schema/kind/resources.gen.go
+++ b/pkg/config/schema/kind/resources.gen.go
@@ -19,7 +19,6 @@ const (
KubernetesGateway
Lease
MeshConfig
- MeshService
MutatingWebhookConfiguration
Namespace
Node
@@ -66,8 +65,6 @@ func (k Kind) String() string {
return "Lease"
case MeshConfig:
return "MeshConfig"
- case MeshService:
- return "MeshService"
case MutatingWebhookConfiguration:
return "MutatingWebhookConfiguration"
case Namespace:
@@ -129,8 +126,6 @@ func FromString(s string) Kind {
return Lease
case "MeshConfig":
return MeshConfig
- case "MeshService":
- return MeshService
case "MutatingWebhookConfiguration":
return MutatingWebhookConfiguration
case "Namespace":
diff --git a/pkg/config/schema/kubeclient/resources.gen.go
b/pkg/config/schema/kubeclient/resources.gen.go
index 8186512d..23ac843a 100755
--- a/pkg/config/schema/kubeclient/resources.gen.go
+++ b/pkg/config/schema/kubeclient/resources.gen.go
@@ -17,7 +17,6 @@ import (
ktypes "github.com/apache/dubbo-kubernetes/pkg/kube/kubetypes"
"github.com/apache/dubbo-kubernetes/pkg/util/ptr"
- apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/kdubbo/client-go/pkg/apis/networking/v1alpha3"
apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/kdubbo/client-go/pkg/apis/security/v1alpha3"
k8sioapiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
k8sioapiappsv1 "k8s.io/api/apps/v1"
@@ -56,8 +55,6 @@ func GetWriteClient[T runtime.Object](c ClientGetter,
namespace string) ktypes.W
return
c.GatewayAPI().GatewayV1().Gateways(namespace).(ktypes.WriteAPI[T])
case *k8sioapicoordinationv1.Lease:
return
c.Kube().CoordinationV1().Leases(namespace).(ktypes.WriteAPI[T])
- case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService:
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(namespace).(ktypes.WriteAPI[T])
case *k8sioapiadmissionregistrationv1.MutatingWebhookConfiguration:
return
c.Kube().AdmissionregistrationV1().MutatingWebhookConfigurations().(ktypes.WriteAPI[T])
case *k8sioapicorev1.Namespace:
@@ -113,8 +110,6 @@ func GetClient[T, TL runtime.Object](c ClientGetter,
namespace string) ktypes.Re
return
c.GatewayAPI().GatewayV1().Gateways(namespace).(ktypes.ReadWriteAPI[T, TL])
case *k8sioapicoordinationv1.Lease:
return
c.Kube().CoordinationV1().Leases(namespace).(ktypes.ReadWriteAPI[T, TL])
- case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService:
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(namespace).(ktypes.ReadWriteAPI[T,
TL])
case *k8sioapiadmissionregistrationv1.MutatingWebhookConfiguration:
return
c.Kube().AdmissionregistrationV1().MutatingWebhookConfigurations().(ktypes.ReadWriteAPI[T,
TL])
case *k8sioapicorev1.Namespace:
@@ -170,8 +165,6 @@ func gvrToObject(g schema.GroupVersionResource)
runtime.Object {
return &sigsk8siogatewayapiapisv1.Gateway{}
case gvr.Lease:
return &k8sioapicoordinationv1.Lease{}
- case gvr.MeshService:
- return
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService{}
case gvr.MutatingWebhookConfiguration:
return
&k8sioapiadmissionregistrationv1.MutatingWebhookConfiguration{}
case gvr.Namespace:
@@ -290,13 +283,6 @@ func getInformerFiltered(c ClientGetter, opts
ktypes.InformerOptions, g schema.G
w = func(options metav1.ListOptions) (watch.Interface, error) {
return
c.Kube().CoordinationV1().Leases(opts.Namespace).Watch(context.Background(),
options)
}
- case gvr.MeshService:
- l = func(options metav1.ListOptions) (runtime.Object, error) {
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(opts.Namespace).List(context.Background(),
options)
- }
- w = func(options metav1.ListOptions) (watch.Interface, error) {
- return
c.Dubbo().NetworkingV1alpha3().MeshServices(opts.Namespace).Watch(context.Background(),
options)
- }
case gvr.MutatingWebhookConfiguration:
l = func(options metav1.ListOptions) (runtime.Object, error) {
return
c.Kube().AdmissionregistrationV1().MutatingWebhookConfigurations().List(context.Background(),
options)
diff --git a/pkg/config/schema/kubetypes/resources.gen.go
b/pkg/config/schema/kubetypes/resources.gen.go
index 3b350689..00b5cac3 100755
--- a/pkg/config/schema/kubetypes/resources.gen.go
+++ b/pkg/config/schema/kubetypes/resources.gen.go
@@ -6,9 +6,7 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
githubcomkdubboapimeshv1alpha1 "github.com/kdubbo/api/mesh/v1alpha1"
- githubcomkdubboapinetworkingv1alpha3
"github.com/kdubbo/api/networking/v1alpha3"
githubcomkdubboapisecurityv1alpha3
"github.com/kdubbo/api/security/v1alpha3"
- apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/kdubbo/client-go/pkg/apis/networking/v1alpha3"
apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/kdubbo/client-go/pkg/apis/security/v1alpha3"
k8sioapiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
k8sioapiappsv1 "k8s.io/api/apps/v1"
@@ -51,10 +49,6 @@ func getGvk(obj any) (config.GroupVersionKind, bool) {
return gvk.Lease, true
case *githubcomkdubboapimeshv1alpha1.MeshConfig:
return gvk.MeshConfig, true
- case *githubcomkdubboapinetworkingv1alpha3.MeshService:
- return gvk.MeshService, true
- case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.MeshService:
- return gvk.MeshService, true
case *k8sioapiadmissionregistrationv1.MutatingWebhookConfiguration:
return gvk.MutatingWebhookConfiguration, true
case *k8sioapicorev1.Namespace:
diff --git a/pkg/config/schema/metadata.yaml b/pkg/config/schema/metadata.yaml
index b1e77feb..36059afa 100644
--- a/pkg/config/schema/metadata.yaml
+++ b/pkg/config/schema/metadata.yaml
@@ -201,15 +201,6 @@ resources:
statusProto: "dubbo.meta.v1alpha1.DubboStatus"
statusProtoPackage: "github.com/kdubbo/api/meta/v1alpha1"
- - kind: "MeshService"
- plural: "meshservices"
- group: "networking.dubbo.apache.org"
- version: "v1alpha3"
- proto: "dubbo.networking.v1alpha3.MeshService"
- protoPackage: "github.com/kdubbo/api/networking/v1alpha3"
- statusProto: "dubbo.meta.v1alpha1.DubboStatus"
- statusProtoPackage: "github.com/kdubbo/api/meta/v1alpha1"
-
- kind: "MeshConfig"
plural: "meshconfigs"
group: ""
diff --git a/samples/app/meshservice.yaml b/samples/app/httproute.yaml
similarity index 66%
rename from samples/app/meshservice.yaml
rename to samples/app/httproute.yaml
index c0568eb1..91328734 100644
--- a/samples/app/meshservice.yaml
+++ b/samples/app/httproute.yaml
@@ -13,27 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-apiVersion: networking.dubbo.apache.org/v1alpha3
-kind: MeshService
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
metadata:
name: nginx-routing
namespace: app
spec:
- hosts:
- - nginx.app.svc.cluster.local
- trafficPolicy:
- tls:
- mode: DUBBO_MUTUAL
+ parentRefs:
+ - group: ""
+ kind: Service
+ name: nginx
+ port: 80
rules:
- - routes:
- - service:
- - name: v1
- host: nginx.app.svc.cluster.local
- labels:
- version: v1
- weight: 50
- - name: v2
- host: nginx.app.svc.cluster.local
- labels:
- version: v2
- weight: 50
+ - backendRefs:
+ - name: nginx-v1
+ port: 80
+ weight: 50
+ - name: nginx-v2
+ port: 80
+ weight: 50
diff --git a/samples/moviereview/deployment.yaml
b/samples/moviereview/deployment.yaml
index cd649908..37e969ec 100644
--- a/samples/moviereview/deployment.yaml
+++ b/samples/moviereview/deployment.yaml
@@ -34,7 +34,7 @@ spec:
- name: http
port: 80
targetPort: 9080
- nodePort: 19080
+ nodePort: 30980
protocol: TCP
---
apiVersion: v1
@@ -87,6 +87,60 @@ spec:
---
apiVersion: v1
kind: Service
+metadata:
+ name: reviews-v1
+ namespace: moviereview
+ labels:
+ app: reviews
+ version: v1
+spec:
+ selector:
+ app: reviews
+ version: v1
+ ports:
+ - name: http
+ port: 9080
+ targetPort: 9080
+ protocol: TCP
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: reviews-v2
+ namespace: moviereview
+ labels:
+ app: reviews
+ version: v2
+spec:
+ selector:
+ app: reviews
+ version: v2
+ ports:
+ - name: http
+ port: 9080
+ targetPort: 9080
+ protocol: TCP
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: reviews-v3
+ namespace: moviereview
+ labels:
+ app: reviews
+ version: v3
+spec:
+ selector:
+ app: reviews
+ version: v3
+ ports:
+ - name: http
+ port: 9080
+ targetPort: 9080
+ protocol: TCP
+---
+apiVersion: v1
+kind: Service
metadata:
name: ratings
namespace: moviereview
@@ -138,13 +192,13 @@ spec:
readinessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 3
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 10
periodSeconds: 10
---
@@ -180,13 +234,13 @@ spec:
readinessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 3
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 10
periodSeconds: 10
---
@@ -222,13 +276,13 @@ spec:
readinessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 3
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 10
periodSeconds: 10
---
@@ -264,13 +318,13 @@ spec:
readinessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 3
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 10
periodSeconds: 10
---
@@ -309,13 +363,13 @@ spec:
readinessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 3
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 10
periodSeconds: 10
---
@@ -354,12 +408,12 @@ spec:
readinessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 3
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
- port: 9080
+ port: 15080
initialDelaySeconds: 10
periodSeconds: 10