Skip to content

Commit

Permalink
Routing policy addition (#243) (#150)
Browse files Browse the repository at this point in the history
* Adding the routing policy

Co-authored-by: psikka1 <pankaj_sikka@intuit.com>
Co-authored-by: vgonuguntla <vinay_gonuguntla@intuit.com>
  • Loading branch information
2 people authored and GitHub Enterprise committed Aug 17, 2022
1 parent 42e10d3 commit 4378d0a
Show file tree
Hide file tree
Showing 48 changed files with 2,254 additions and 59 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CUSTOM_RESOURCE_VERSION=v1

MAIN_PATH_ADMIRAL=./admiral/cmd/admiral/main.go
OPSYS:=$(shell $(GOCMD) env GOOS)
DEEPCOPYGEN=deepcopy-gen

PATH:=$(GOBIN):$(PATH)

Expand All @@ -56,8 +57,10 @@ dep:
setup:
$(GOGET) -u github.com/golang/protobuf/protoc-gen-go@v1.3.2

model-gen:
$(DEEPCOPYGEN) -i ./admiral/pkg/apis/admiral/model/ -O zz_generated.deepcopy

gen-all: api-gen crd-gen
gen-all: api-gen model-gen crd-gen

install-protoc-mac:
curl -OL https://github.com/google/protobuf/releases/download/v$(PROTOC_VER)/$(PROTOC_ZIP)
Expand Down Expand Up @@ -167,4 +170,5 @@ gen-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/prometheus/prometheus.yaml ./out/yaml/prometheus.yaml
cp ./install/scripts/*.sh ./out/scripts/
cp ./install/sample/rp.yaml ./out/yaml/rp.yaml
cp ./install/scripts/*.sh ./out/scripts/
14 changes: 9 additions & 5 deletions admiral/cmd/admiral/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,15 @@ func GetRootCmd(args []string) *cobra.Command {
rootCmd.PersistentFlags().StringVar(&params.SecretResolverConfigPath, "secret_resolver_config_path", "/etc/config/resolver_config.yaml",
"Path to the secret resolver config")
rootCmd.PersistentFlags().BoolVar(&params.MetricsEnabled, "metrics", true, "Enable prometheus metrics collections")
rootCmd.PersistentFlags().StringVar(&params.AdmiralStateCheckerName,"admiral_state_checker_name","NoOPStateChecker","The value of the admiral_state_checker_name label to configure the DR Strategy for Admiral")
rootCmd.PersistentFlags().StringVar(&params.DRStateStoreConfigPath,"dr_state_store_config_path","","Location of config file which has details for data store. Ex:- Dynamo DB connection details")
rootCmd.PersistentFlags().StringVar(&params.ServiceEntryIPPrefix,"se_ip_prefix","240.0","IP prefix for the auto generated IPs for service entries. Only the first two octets: Eg- 240.0")


rootCmd.PersistentFlags().StringVar(&params.AdmiralStateCheckerName, "admiral_state_checker_name", "NoOPStateChecker", "The value of the admiral_state_checker_name label to configure the DR Strategy for Admiral")
rootCmd.PersistentFlags().StringVar(&params.DRStateStoreConfigPath, "dr_state_store_config_path", "", "Location of config file which has details for data store. Ex:- Dynamo DB connection details")
rootCmd.PersistentFlags().StringVar(&params.ServiceEntryIPPrefix, "se_ip_prefix", "240.0", "IP prefix for the auto generated IPs for service entries. Only the first two octets: Eg- 240.0")
rootCmd.PersistentFlags().StringVar(&params.EnvoyFilterVersion, "envoy_filter_version", "",
"The value of envoy filter version is used to match the proxy version for envoy filter created by routing policy")
rootCmd.PersistentFlags().StringVar(&params.EnvoyFilterAdditionalConfig, "envoy_filter_additional_config", "",
"The value of envoy filter is to add additional config to the filter config section")
rootCmd.PersistentFlags().BoolVar(&params.EnableRoutingPolicy, "enable_routing_policy", false,
"If Routing Policy feature needs to be enabled")
return rootCmd
}

Expand Down
14 changes: 14 additions & 0 deletions admiral/crd/routingPolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: routingpolicies.admiral.io
spec:
group: admiral.io
version: v1alpha1
names:
kind: RoutingPolicy
plural: routingpolicies
shortNames:
- rp
- rps
scope: Namespaced
1 change: 1 addition & 0 deletions admiral/pkg/apis/admiral/model/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package model

//go:generate protoc -I . dependency.proto --go_out=plugins=grpc:.
//go:generate protoc -I . globalrouting.proto --go_out=plugins=grpc:.
//go:generate protoc -I . routingpolicy.proto --go_out=plugins=grpc:.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:deepcopy-gen=package,register
100 changes: 100 additions & 0 deletions admiral/pkg/apis/admiral/model/routingpolicy.pb.go

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

32 changes: 32 additions & 0 deletions admiral/pkg/apis/admiral/model/routingpolicy.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";

package admiral.global.v1alpha;

option go_package = "model";

//```
// apiVersion: admiral.io/v1alpha1
// kind: RoutingPolicy
// metadata:
// name: greeting-routing-policy
// annotations:
// admiral.io/env: stage
// labels:
// identity: greeting
// spec:
// plugin: greeting
// hosts:
// - qal.greeting.mesh
// config:
// cachePrefix: cache-v1
// cachettlSec: "86400"
// dispatcherUrl: qal.greeting.dispatcher.mesh
// algo: greetingDispatcher
// pathPrefix: "/wpcatalog,/consumercatalog,/v1/company/{id}/auth/hydrate,/consumercatalog"
//```

message RoutingPolicy {
string plugin = 1;
repeated string hosts = 2;
map<string, string> config = 3;
}
34 changes: 34 additions & 0 deletions admiral/pkg/apis/admiral/model/zz_generated.deepcopy.go

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

2 changes: 2 additions & 0 deletions admiral/pkg/apis/admiral/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&DependencyList{},
&GlobalTrafficPolicy{},
&GlobalTrafficPolicyList{},
&RoutingPolicy{},
&RoutingPolicyList{},
)

// register the type in the scheme
Expand Down
26 changes: 26 additions & 0 deletions admiral/pkg/apis/admiral/v1/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,29 @@ type GlobalTrafficPolicyList struct {

Items []GlobalTrafficPolicy `json:"items"`
}

//generic cdr object to wrap the GlobalTrafficPolicy api
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type RoutingPolicy struct {
meta_v1.TypeMeta `json:",inline"`
meta_v1.ObjectMeta `json:"metadata"`
Spec model.RoutingPolicy `json:"spec"`
Status RoutingPolicyStatus `json:"status"`
}

// FooStatus is the status for a Foo resource

type RoutingPolicyStatus struct {
ClusterSynced int32 `json:"clustersSynced"`
State string `json:"state"`
}

// FooList is a list of Foo resources
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type RoutingPolicyList struct {
meta_v1.TypeMeta `json:",inline"`
meta_v1.ListMeta `json:"metadata"`

Items []RoutingPolicy `json:"items"`
}
77 changes: 77 additions & 0 deletions admiral/pkg/apis/admiral/v1/zz_generated.deepcopy.go

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.

Loading

0 comments on commit 4378d0a

Please sign in to comment.