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

Add support for gtp with multiple traffic policies #162

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
d457913
Bootstrapping admiral
aattuluri Sep 19, 2019
7b9a2ff
Add circle ci config
aattuluri Sep 19, 2019
c9e80a5
Fix the working directory for builds
aattuluri Sep 19, 2019
76b9561
Bootstrapping admiral
aattuluri Sep 19, 2019
85aeeaa
Add circle ci config
aattuluri Sep 19, 2019
fe313cc
Fix the working directory for builds
aattuluri Sep 19, 2019
306ad93
Merge branch 'master' of https://github.com/aattuluri/admiral
aattuluri Sep 19, 2019
a9fa409
Add build status badge.
aattuluri Sep 19, 2019
4ae717d
Revert "Add build status badge."
aattuluri Sep 19, 2019
ff09cfb
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 19, 2019
eb51849
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 20, 2019
928c0d2
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 20, 2019
2fb3364
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 23, 2019
ea3ed61
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 23, 2019
15e7845
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 24, 2019
3b34036
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 29, 2019
656bf71
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 29, 2019
0245314
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 29, 2019
111c3de
Merge remote-tracking branch 'upstream/master'
aattuluri Oct 4, 2019
e39651c
Merge remote-tracking branch 'upstream/master'
aattuluri Oct 4, 2019
b280c0b
Merge remote-tracking branch 'upstream/master'
aattuluri Oct 6, 2019
4b74679
Merge remote-tracking branch 'upstream/master'
aattuluri Oct 16, 2019
09b8a5b
Merge remote-tracking branch 'upstream/master'
aattuluri Oct 30, 2019
6546170
Merge remote-tracking branch 'upstream/master'
aattuluri Dec 27, 2019
1b0dfeb
Merge remote-tracking branch 'upstream/master'
aattuluri Jan 2, 2020
9b0010b
Merge remote-tracking branch 'upstream/master'
aattuluri Jan 9, 2020
7b68379
Merge remote-tracking branch 'upstream/master'
aattuluri Jan 21, 2020
5ae2f4c
Merge remote-tracking branch 'upstream/master'
aattuluri Jan 24, 2020
6e297db
Publish images: i) latest from master, ii) TAG if its set and iii) co…
aattuluri Jan 24, 2020
d6674b9
Merge remote-tracking branch 'upstream/master'
aattuluri Feb 19, 2020
e45ef03
Merge remote-tracking branch 'upstream/master'
aattuluri Feb 26, 2020
9096f16
Merge remote-tracking branch 'upstream/master'
aattuluri Feb 27, 2020
1e7a3d5
Merge remote-tracking branch 'upstream/master'
aattuluri Mar 8, 2020
a9e55b3
Merge remote-tracking branch 'upstream/master'
aattuluri Mar 20, 2020
c40a8be
Merge remote-tracking branch 'upstream/master'
aattuluri Mar 27, 2020
798b06a
Merge remote-tracking branch 'upstream/master'
aattuluri Apr 6, 2020
f028e1e
Merge remote-tracking branch 'upstream/master'
aattuluri Apr 16, 2020
0956d03
Merge remote-tracking branch 'upstream/master'
aattuluri Apr 27, 2020
cecd2ca
Merge remote-tracking branch 'upstream/master'
aattuluri May 13, 2020
b46682c
Merge remote-tracking branch 'upstream/master'
aattuluri May 14, 2020
2d3460c
Merge remote-tracking branch 'upstream/master'
aattuluri May 26, 2020
77c46e0
Merge remote-tracking branch 'upstream/master'
aattuluri Jun 15, 2020
82a4223
Merge remote-tracking branch 'upstream/master'
aattuluri Jul 24, 2020
065b6d4
Merge remote-tracking branch 'upstream/master'
aattuluri Aug 26, 2020
933650b
Merge remote-tracking branch 'upstream/master'
aattuluri Sep 20, 2020
d2e76cb
Merge remote-tracking branch 'upstream/master'
aattuluri Nov 2, 2020
63b4c60
Merge remote-tracking branch 'upstream/master'
aattuluri Nov 6, 2020
7b6626f
Merge remote-tracking branch 'upstream/master'
aattuluri Nov 12, 2020
9f04b35
Add support for multiple traffic policies in gtp
aattuluri Nov 1, 2020
6fd2496
Make env label configurable.
aattuluri Nov 12, 2020
e4de7ea
Move env group label to label set
aattuluri Nov 12, 2020
0ae9efa
Refactor
aattuluri Nov 12, 2020
9dbabf6
Minor changes.
aattuluri Nov 13, 2020
bf7a620
Merge remote-tracking branch 'upstream/master' into Add-support-for-g…
aattuluri Jan 4, 2021
83f16d7
Working changes
aattuluri Jan 11, 2021
9201da0
Fix the host creation
aattuluri Jan 11, 2021
f9f7b53
Refactor generating SEs and DRs from gtp
aattuluri Jan 11, 2021
884e6ad
Fix bugs
aattuluri Jan 11, 2021
f009d5f
Fix sample configurations and bumped the default thresholds
aattuluri Jan 12, 2021
c7bd8cc
Remove unwanted code.
aattuluri Jan 12, 2021
5f15d7f
Fix remote sample bug
aattuluri Jan 12, 2021
67b06b3
Change minikube version and configuration for the build
aattuluri Jan 12, 2021
8b1198f
Run on larger circle ci instance, remove nodes
aattuluri Jan 12, 2021
8a7dad9
Label nodes with locality for tests.
aattuluri Jan 12, 2021
689b546
Switch back to original state
aattuluri Jan 13, 2021
41aa613
Remove nodes tagging for remote
aattuluri Jan 13, 2021
2ec6e1c
Temporariliy disable tests for 1.6
aattuluri Jan 13, 2021
09b3bc4
Code review feedback
aattuluri Jan 13, 2021
a2bbe74
Fix installation
aattuluri Jan 13, 2021
5cd2555
Adjust time
aattuluri Jan 13, 2021
b05bbb1
Adding a dnsPrefix field to gtp and deprecating dns field.
aattuluri Jan 14, 2021
6ef572c
Fix tests and docs
aattuluri Jan 15, 2021
14992a4
Wait a bit longer
aattuluri Jan 15, 2021
3b296e8
Change image pull policy. Tune tests.
aattuluri Jan 15, 2021
fa7aad3
Adjust grpc pod resources.
aattuluri Jan 15, 2021
455b816
Retry tests to account for instability
aattuluri Jan 15, 2021
5132b1f
Adding admiral logs to debug better
aattuluri Jan 15, 2021
5e33f2e
Remove admiral logging
aattuluri Jan 15, 2021
fd39127
More buffer
aattuluri Jan 16, 2021
8c999eb
Add back istio 1.5
aattuluri Jan 16, 2021
b4fe020
Add to example for dnsPrefix usage.
aattuluri Jan 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
environment:
K8S_VERSION: v1.16.8
KUBECONFIG: /home/circleci/.kube/config
MINIKUBE_VERSION: v1.13.0
MINIKUBE_VERSION: v1.16.0
MINIKUBE_WANTUPDATENOTIFICATION: false
MINIKUBE_WANTREPORTERRORPROMPT: false
MINIKUBE_HOME: /home/circleci
Expand Down Expand Up @@ -97,12 +97,11 @@ jobs:
export IS_LOCAL=false
./run.sh "1.16.8" "1.6.13" "../out"
- run:
name: Run Integration Test for Istio 1.7.4
name: Run Integration Test for Istio 1.7.6
josephpeacock marked this conversation as resolved.
Show resolved Hide resolved
command: |
cd tests
export IS_LOCAL=false
./run.sh "1.16.8" "1.7.4" "../out"

./run.sh "1.16.8" "1.7.6" "../out"
publish-github-release:
docker:
- image: circleci/golang:1.11
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dep:
$(DEP_PATH)dep ensure -v

setup:
$(GOGET) -u github.com/golang/protobuf/protoc-gen-go
$(GOGET) -u github.com/golang/protobuf/protoc-gen-go@v1.3.2


gen-all: api-gen crd-gen
Expand All @@ -66,13 +66,12 @@ install-protoc-mac:

api-gen:
#make sure the protobuf matches the generation plugin
go install github.com/golang/protobuf/protoc-gen-go
$(GOCMD) generate ./...
go install k8s.io/code-generator/cmd/deepcopy-gen

crd-gen:
go get -d -u -fix k8s.io/code-generator
go get -d -u -fix k8s.io/apimachinery
go get -d -u -fix k8s.io/code-generator@v0.17.3
go get -d -u -fix k8s.io/apimachinery@v0.17.3
go get -d -u -fix k8s.io/gengo
$(GOPATH)/src/k8s.io/code-generator/generate-groups.sh all "$(ROOT_PACKAGE)/pkg/client" "$(ROOT_PACKAGE)/pkg/apis" "$(CUSTOM_RESOURCE_NAME):$(CUSTOM_RESOURCE_VERSION)"

Expand Down Expand Up @@ -133,5 +132,7 @@ gen-yaml:
kustomize build ./install/sample/overlays/remote > ./out/yaml/remotecluster_sample.yaml
cp ./install/sample/sample_dep.yaml ./out/yaml/sample_dep.yaml
cp ./install/sample/gtp.yaml ./out/yaml/gtp.yaml
cp ./install/sample/gtp_failover.yaml ./out/yaml/gtp_failover.yaml
cp ./install/sample/gtp_topology.yaml ./out/yaml/gtp_topology.yaml
cp ./install/sample/grpc-client.yaml ./out/yaml/grpc-client.yaml
cp ./install/scripts/*.sh ./out/scripts/
66 changes: 39 additions & 27 deletions admiral/pkg/apis/admiral/model/globalrouting.pb.go

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

12 changes: 8 additions & 4 deletions admiral/pkg/apis/admiral/model/globalrouting.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ option go_package = "model";
// identity: my-identity
// env: prd
// policy:
// - dns: prd.accounts.global
// - dnsPrefix: prd.accounts.global
// lbType: topology
// - dns: prd.accounts-us-west2
// - dnsPrefix: prd.accounts-us-west2
// lbType: failover
// target:
// - region: us-west2
// weight: 90
// - region: us-east2
// weight: 10
// - dns: prd.accounts-us-east2
// - dnsPrefix: prd.accounts-us-east2
// lbType: failover
// target:
// - region: us-west2
Expand All @@ -52,7 +52,7 @@ message TrafficPolicy {

// REQUIRED: dns that can be used by client. This name will have the
// traffic type applied to it
string dns = 1;
string dns = 1 [deprecated=true];

// REQUIRED: type of global load distrubtion
LbType lbType = 2;
Expand All @@ -70,6 +70,10 @@ message TrafficPolicy {

//weigth of primary and secondary must each 100
repeated TrafficGroup target = 3;

//REQUIRED: dnsPrefix that will be prefixed for the service names being generated with this traffic policy
//Ex: dnsPrefix = west => generated service name = west.stage.servicename.global
string dnsPrefix = 4;
}

message TrafficGroup {
Expand Down
7 changes: 7 additions & 0 deletions admiral/pkg/client/clientset/versioned/clientset.go

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

23 changes: 14 additions & 9 deletions admiral/pkg/clusters/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,25 @@ func makeVirtualService(host string, gateways []string, destination string, port
Http: []*v1alpha32.HTTPRoute{{Route: []*v1alpha32.HTTPRouteDestination{{Destination: &v1alpha32.Destination{Host: destination, Port: &v1alpha32.PortSelector{Number: port}}}}}}}
}

func getDestinationRule(host string, locality string, gtpWrapper *v1.GlobalTrafficPolicy) *v1alpha32.DestinationRule {
func getDestinationRule(host string, locality string, gtpTrafficPolicy *model.TrafficPolicy) *v1alpha32.DestinationRule {
var dr = &v1alpha32.DestinationRule{}
dr.Host = host
dr.TrafficPolicy = &v1alpha32.TrafficPolicy{Tls: &v1alpha32.TLSSettings{Mode: v1alpha32.TLSSettings_ISTIO_MUTUAL}}
if gtpWrapper != nil {
processGtp := true
if len(locality) == 0 {
log.Warnf(LogErrFormat, "Process", "GlobalTrafficPolicy", host, "", "Skipping gtp processing, locality of the cluster nodes cannot be determined. Is this minikube?")
processGtp = false
}
outlierDetection := &v1alpha32.OutlierDetection{
josephpeacock marked this conversation as resolved.
Show resolved Hide resolved
BaseEjectionTime: &types.Duration{Seconds: 120},
ConsecutiveErrors: int32(10),
Interval: &types.Duration{Seconds: 5},
}
if gtpTrafficPolicy != nil && processGtp {
var loadBalancerSettings = &v1alpha32.LoadBalancerSettings{
LbPolicy: &v1alpha32.LoadBalancerSettings_Simple{Simple: v1alpha32.LoadBalancerSettings_ROUND_ROBIN},
}
gtp := gtpWrapper.Spec
gtpTrafficPolicy := gtp.Policy[0]

if len(gtpTrafficPolicy.Target) > 0 {
var localityLbSettings = &v1alpha32.LocalityLoadBalancerSetting{}

Expand All @@ -209,11 +218,7 @@ func getDestinationRule(host string, locality string, gtpWrapper *v1.GlobalTraff
dr.TrafficPolicy.LoadBalancer = loadBalancerSettings
}
}
dr.TrafficPolicy.OutlierDetection = &v1alpha32.OutlierDetection{
BaseEjectionTime: &types.Duration{Seconds: 120},
ConsecutiveErrors: int32(10),
Interval: &types.Duration{Seconds: 5},
}
dr.TrafficPolicy.OutlierDetection = outlierDetection
return dr
}

Expand Down
65 changes: 26 additions & 39 deletions admiral/pkg/clusters/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,85 +112,72 @@ func TestGetDestinationRule(t *testing.T) {
},
}

topologyGTPBody := model.GlobalTrafficPolicy{
Policy: []*model.TrafficPolicy{
topologyGTPPolicy := &model.TrafficPolicy{
LbType: model.TrafficPolicy_TOPOLOGY,
Target: []*model.TrafficGroup{
{
LbType: model.TrafficPolicy_TOPOLOGY,
Target: []*model.TrafficGroup{
{
Region: "us-west-2",
Weight: 100,
},
},
Region: "us-west-2",
Weight: 100,
},
},
}

topologyGTP := v1.GlobalTrafficPolicy{
Spec: topologyGTPBody,
}
topologyGTP.Name = "myGTP"
topologyGTP.Namespace = "myNS"

failoverGTPBody := model.GlobalTrafficPolicy{
Policy: []*model.TrafficPolicy{
failoverGTPPolicy := &model.TrafficPolicy{
LbType: model.TrafficPolicy_FAILOVER,
Target: []*model.TrafficGroup{
{
LbType: model.TrafficPolicy_FAILOVER,
Target: []*model.TrafficGroup{
{
Region: "us-west-2",
Weight: 100,
},
{
Region: "us-east-2",
Weight: 0,
},
},
Region: "us-west-2",
Weight: 100,
},
{
Region: "us-east-2",
Weight: 0,
},
},
}

failoverGTP := v1.GlobalTrafficPolicy{
Spec: failoverGTPBody,
}
failoverGTP.Name = "myGTP"
failoverGTP.Namespace = "myNS"

//Struct of test case info. Name is required.
testCases := []struct {
name string
host string
locality string
gtp *v1.GlobalTrafficPolicy
gtpPolicy *model.TrafficPolicy
destinationRule *v1alpha3.DestinationRule
}{
{
name: "Should handle a nil GTP",
host: "qa.myservice.global",
locality: "uswest2",
gtp: nil,
gtpPolicy: nil,
destinationRule: &noGtpDr,
},
{
name: "Should return default DR with empty locality",
host: "qa.myservice.global",
locality: "",
gtpPolicy: failoverGTPPolicy,
destinationRule: &noGtpDr,
},
{
name: "Should handle a topology GTP",
host: "qa.myservice.global",
locality: "uswest2",
gtp: &topologyGTP,
gtpPolicy: topologyGTPPolicy,
destinationRule: &basicGtpDr,
},
{
name: "Should handle a failover GTP",
host: "qa.myservice.global",
locality: "uswest2",
gtp: &failoverGTP,
gtpPolicy: failoverGTPPolicy,
destinationRule: &failoverGtpDr,
},
}

//Run the test for every provided case
for _, c := range testCases {
t.Run(c.name, func(t *testing.T) {
result := getDestinationRule(c.host, c.locality, c.gtp)
result := getDestinationRule(c.host, c.locality, c.gtpPolicy)
if !cmp.Equal(result, c.destinationRule) {
t.Fatalf("DestinationRule Mismatch. Diff: %v", cmp.Diff(result, c.destinationRule))
}
Expand Down
Loading