Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upstream group and subsets #601

Merged
merged 25 commits into from Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/v0.13.6/upstream_groups.yaml
@@ -0,0 +1,7 @@
changelog:
- type: NEW_FEATURE
description: Allow configuring upstream groups for routes.
issueLink: https://github.com/solo-io/gloo/pull/601
- type: NEW_FEATURE
description: Allow doing user-defined subset load balancing.
issueLink: https://github.com/solo-io/gloo/pull/601
1 change: 1 addition & 0 deletions docs/v1/gateway.solo.io.project.sk.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/v1/gloo.solo.io.project.sk.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions install/helm/gloo/templates/100-gloo-crds.yaml
Expand Up @@ -90,4 +90,22 @@ spec:
scope: Namespaced
version: v1
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: upstreamgroups.gloo.solo.io
annotations:
"helm.sh/hook": crd-install
spec:
group: gloo.solo.io
names:
kind: UpstreamGroup
listKind: UpstreamGroupList
plural: upstreamgroups
shortNames:
- ug
singular: upstreamgroup
scope: Namespaced
version: v1
---
{{- end}}
Expand Up @@ -19,7 +19,7 @@ rules:
resources: ["customresourcedefinitions"]
verbs: ["get", "create"]
- apiGroups: ["gloo.solo.io"]
resources: ["settings", "upstreams", "proxies","virtualservices"]
resources: ["settings", "upstreams","upstreamgroups", "proxies","virtualservices"]
verbs: ["*"]
- apiGroups: ["gateway.solo.io"]
resources: ["virtualservices", "gateways"]
Expand Down
9 changes: 8 additions & 1 deletion projects/gloo/api/v1/plugins/kubernetes/kubernetes.proto
Expand Up @@ -7,6 +7,7 @@ import "gogoproto/gogo.proto";
option (gogoproto.equal_all) = true;

import "github.com/solo-io/gloo/projects/gloo/api/v1/plugins/service_spec.proto";
import "github.com/solo-io/gloo/projects/gloo/api/v1/plugins/subset_spec.proto";

// Upstream Spec for Kubernetes Upstreams
// Kubernetes Upstreams represent a set of one or more addressable pods for a Kubernetes Service
Expand All @@ -25,6 +26,12 @@ message UpstreamSpec {
// any are provided here.
// (see [Kubernetes labels and selectors](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/)
map<string, string> selector = 4;
// An optional Service Spec describing the service listening at this address
// An optional Service Spec describing the service listening at this address
.plugins.gloo.solo.io.ServiceSpec service_spec = 5;


// Subset configuration. For discovery sources that has labels (like kubernetes). this
// configuration allows you to partition the upstream to a set of subsets.
// for each unique set of keys and values, a subset will be created.
.plugins.gloo.solo.io.SubsetSpec subset_spec = 6;
}
14 changes: 14 additions & 0 deletions projects/gloo/api/v1/plugins/subset_spec.proto
@@ -0,0 +1,14 @@
syntax = "proto3";
package plugins.gloo.solo.io;
option go_package = "github.com/solo-io/gloo/projects/gloo/pkg/api/v1/plugins";

import "gogoproto/gogo.proto";
option (gogoproto.equal_all) = true;

message SubsetSpec {
repeated Selector selectors =1;
}

message Selector {
repeated string keys = 1;
}
28 changes: 28 additions & 0 deletions projects/gloo/api/v1/proxy.proto
Expand Up @@ -10,6 +10,7 @@ import "github.com/solo-io/solo-kit/api/v1/status.proto";
import "github.com/solo-io/solo-kit/api/v1/ref.proto";

import "github.com/solo-io/gloo/projects/gloo/api/v1/ssl.proto";
import "github.com/solo-io/gloo/projects/gloo/api/v1/subset.proto";
import "github.com/solo-io/gloo/projects/gloo/api/v1/plugins.proto";
/*
@solo-kit:resource.short_name=px
Expand Down Expand Up @@ -248,6 +249,9 @@ message RouteAction {
Destination single = 1;
// Use MultiDestination to load balance requests between multiple upstreams (by weight)
MultiDestination multi = 2;

// Use a reference to an upstream group for routing.
core.solo.io.ResourceRef upstream_group = 3;
};
}

Expand All @@ -261,8 +265,32 @@ message Destination {
// destination config. If the destination config is required for the upstream and not provided by the user,
// Gloo will invalidate the destination and its parent resources.
DestinationSpec destination_spec = 2;

// If specified, traffic will only be routed to a subset of the upstream. If upstream doesn't
// contain the specified subset, we will fallback to normal upstream routing.
Subset subset = 3;
}


/*
@solo-kit:resource.short_name=ug
@solo-kit:resource.plural_name=upstreamgroups
*/
message UpstreamGroup {

// The destinations that are part of this upstream group.
repeated WeightedDestination destinations = 1;

// Status indicates the validation status of this resource.
// Status is read-only by clients, and set by gloo during validation
core.solo.io.Status status = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "testdiff:\"ignore\""];

// Metadata contains the object metadata for this resource
core.solo.io.Metadata metadata = 7 [(gogoproto.nullable) = false];
}



// MultiDestination is a container for a set of weighted destinations. Gloo will load balance traffic for a single
// route across multiple destinations according to their specified weights.
message MultiDestination {
Expand Down
4 changes: 4 additions & 0 deletions projects/gloo/api/v1/solo-kit.json
Expand Up @@ -24,6 +24,10 @@
"name": "Proxy",
"package": "gloo.solo.io"
},
{
"name": "UpstreamGroup",
"package": "gloo.solo.io"
},
{
"name": "Secret",
"package": "gloo.solo.io"
Expand Down
10 changes: 10 additions & 0 deletions projects/gloo/api/v1/subset.proto
@@ -0,0 +1,10 @@
syntax = "proto3";
package gloo.solo.io;
option go_package = "github.com/solo-io/gloo/projects/gloo/pkg/api/v1";

import "gogoproto/gogo.proto";
option (gogoproto.equal_all) = true;

message Subset {
map<string, string> values = 1;
}
2 changes: 1 addition & 1 deletion projects/gloo/cli/pkg/cmd/install/uninstall_test.go
Expand Up @@ -37,7 +37,7 @@ func (k *MockKubectl) Kubectl(stdin io.Reader, args ...string) error {
var _ = Describe("Uninstall", func() {

const (
deleteCrds = "delete crd gateways.gateway.solo.io proxies.gloo.solo.io settings.gloo.solo.io upstreams.gloo.solo.io virtualservices.gateway.solo.io"
deleteCrds = "delete crd gateways.gateway.solo.io proxies.gloo.solo.io settings.gloo.solo.io upstreams.gloo.solo.io upstreamgroups.gloo.solo.io virtualservices.gateway.solo.io"
)

var flagSet *pflag.FlagSet
Expand Down
1 change: 1 addition & 0 deletions projects/gloo/cli/pkg/cmd/install/util.go
Expand Up @@ -49,6 +49,7 @@ func init() {
"proxies.gloo.solo.io",
"settings.gloo.solo.io",
"upstreams.gloo.solo.io",
"upstreamgroups.gloo.solo.io",
"virtualservices.gateway.solo.io",
}

Expand Down
2 changes: 2 additions & 0 deletions projects/gloo/cli/pkg/printers/virtualservice.go
Expand Up @@ -80,6 +80,8 @@ func destinationString(route *gloov1.Route) string {
return fmt.Sprintf("%v destinations", len(dest.Multi.Destinations))
case *gloov1.RouteAction_Single:
return dest.Single.Upstream.Name
case *gloov1.RouteAction_UpstreamGroup:
return fmt.Sprintf("upstream group: %s.%s", dest.UpstreamGroup.Name, dest.UpstreamGroup.Namespace)
}
case *gloov1.Route_DirectResponseAction:
return strconv.Itoa(int(action.DirectResponseAction.Status))
Expand Down