From acfcaff6c46362275c588927ddb8418755231c3b Mon Sep 17 00:00:00 2001 From: Xunzhuo Date: Sun, 15 May 2022 09:26:14 +0800 Subject: [PATCH] traffic mirroring api Signed-off-by: Xunzhuo --- .../metaprotocol.aeraki.io.v1alpha1.pb.html | 50 ++- .../v1alpha1/metaprotocol_metarouter.pb.go | 421 +++++++++++++++--- .../v1alpha1/metaprotocol_metarouter.proto | 9 +- .../metaprotocol_metarouter_deepcopy.gen.go | 21 + .../metaprotocol_metarouter_json.gen.go | 11 + .../customresourcedefinitions.gen.yaml | 26 ++ k8s/crd.yaml | 26 ++ 7 files changed, 495 insertions(+), 69 deletions(-) diff --git a/api/metaprotocol/v1alpha1/metaprotocol.aeraki.io.v1alpha1.pb.html b/api/metaprotocol/v1alpha1/metaprotocol.aeraki.io.v1alpha1.pb.html index 69b94d27f..fb7771e9d 100644 --- a/api/metaprotocol/v1alpha1/metaprotocol.aeraki.io.v1alpha1.pb.html +++ b/api/metaprotocol/v1alpha1/metaprotocol.aeraki.io.v1alpha1.pb.html @@ -2,7 +2,7 @@ title: metaprotocol.aeraki.io.v1alpha1 layout: protoc-gen-docs generator: protoc-gen-docs -number_of_entries: 15 +number_of_entries: 16 ---

$schema: metaprotocol.aeraki.io.v1alpha1.ApplicationProtocol $title: Application Protocol @@ -154,6 +154,28 @@

MetaRoute

beginning of document). Weights associated with the service version determine the proportion of traffic it receives.

+ + +No + + + +mirror +Destination + + + +No + + + +mirrorPercentage +Percent + +

Percentage of the traffic to be mirrored by the mirror field. +If this field is absent, all the traffic (100%) will be mirrored. +Max value is 100.

+ No @@ -571,6 +593,32 @@

GlobalRateLimit

+

Percent

+
+

Percent specifies a percentage in the range of [0.0, 100.0].

+ + + + + + + + + + + + + + + + + + +
FieldTypeDescriptionRequired
valuedouble + +No +
+

LocalRateLimit.TokenBucket

Configures a token bucket which is used for rate limiting.

diff --git a/api/metaprotocol/v1alpha1/metaprotocol_metarouter.pb.go b/api/metaprotocol/v1alpha1/metaprotocol_metarouter.pb.go index 8a4fd6b43..a2da4ce83 100644 --- a/api/metaprotocol/v1alpha1/metaprotocol_metarouter.pb.go +++ b/api/metaprotocol/v1alpha1/metaprotocol_metarouter.pb.go @@ -54,6 +54,7 @@ package v1alpha1 import ( + encoding_binary "encoding/binary" fmt "fmt" proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" @@ -176,7 +177,12 @@ type MetaRoute struct { // can be one of several versions of a service (see glossary in // beginning of document). Weights associated with the service version // determine the proportion of traffic it receives. - Route []*MetaRouteDestination `protobuf:"bytes,3,rep,name=route,proto3" json:"route,omitempty"` + Route []*MetaRouteDestination `protobuf:"bytes,3,rep,name=route,proto3" json:"route,omitempty"` + Mirror *Destination `protobuf:"bytes,5,opt,name=mirror,proto3" json:"mirror,omitempty"` + // Percentage of the traffic to be mirrored by the `mirror` field. + // If this field is absent, all the traffic (100%) will be mirrored. + // Max value is 100. + MirrorPercentage *Percent `protobuf:"bytes,6,opt,name=mirror_percentage,json=mirrorPercentage,proto3" json:"mirror_percentage,omitempty"` // Specifies a list of key-value pairs that should be mutated for each request. How to interpret the key-value pairs // depends on the codec implementation RequestMutation []*KeyValue `protobuf:"bytes,19,rep,name=request_mutation,json=requestMutation,proto3" json:"request_mutation,omitempty"` @@ -242,6 +248,20 @@ func (m *MetaRoute) GetRoute() []*MetaRouteDestination { return nil } +func (m *MetaRoute) GetMirror() *Destination { + if m != nil { + return m.Mirror + } + return nil +} + +func (m *MetaRoute) GetMirrorPercentage() *Percent { + if m != nil { + return m.MirrorPercentage + } + return nil +} + func (m *MetaRoute) GetRequestMutation() []*KeyValue { if m != nil { return m.RequestMutation @@ -1014,6 +1034,54 @@ func (m *GlobalRateLimit_Descriptor) GetDescriptorKey() string { return "" } +// Percent specifies a percentage in the range of [0.0, 100.0]. +type Percent struct { + Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Percent) Reset() { *m = Percent{} } +func (m *Percent) String() string { return proto.CompactTextString(m) } +func (*Percent) ProtoMessage() {} +func (*Percent) Descriptor() ([]byte, []int) { + return fileDescriptor_1e2715e051935576, []int{10} +} +func (m *Percent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Percent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Percent.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Percent) XXX_Merge(src proto.Message) { + xxx_messageInfo_Percent.Merge(m, src) +} +func (m *Percent) XXX_Size() int { + return m.Size() +} +func (m *Percent) XXX_DiscardUnknown() { + xxx_messageInfo_Percent.DiscardUnknown(m) +} + +var xxx_messageInfo_Percent proto.InternalMessageInfo + +func (m *Percent) GetValue() float64 { + if m != nil { + return m.Value + } + return 0 +} + func init() { proto.RegisterType((*MetaRouter)(nil), "metaprotocol.aeraki.io.v1alpha1.MetaRouter") proto.RegisterType((*MetaRoute)(nil), "metaprotocol.aeraki.io.v1alpha1.MetaRoute") @@ -1029,6 +1097,7 @@ func init() { proto.RegisterType((*LocalRateLimit_Condition)(nil), "metaprotocol.aeraki.io.v1alpha1.LocalRateLimit.Condition") proto.RegisterType((*GlobalRateLimit)(nil), "metaprotocol.aeraki.io.v1alpha1.GlobalRateLimit") proto.RegisterType((*GlobalRateLimit_Descriptor)(nil), "metaprotocol.aeraki.io.v1alpha1.GlobalRateLimit.Descriptor") + proto.RegisterType((*Percent)(nil), "metaprotocol.aeraki.io.v1alpha1.Percent") } func init() { @@ -1036,71 +1105,74 @@ func init() { } var fileDescriptor_1e2715e051935576 = []byte{ - // 1010 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 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xb4, 0x7d, 0x0c, 0x30, 0xad, 0x93, - 0x75, 0x58, 0x88, 0xa5, 0x88, 0x51, 0xaa, 0x99, 0xb7, 0x68, 0x92, 0x24, 0x77, 0x60, 0x79, 0xaa, - 0xf6, 0x32, 0xe7, 0x2f, 0x0c, 0x74, 0x69, 0x5a, 0xda, 0xc7, 0x71, 0x6f, 0xef, 0xb7, 0x8b, 0x35, - 0xe7, 0xf7, 0x8b, 0x35, 0xe7, 0xd5, 0xc5, 0x9a, 0xf3, 0xcd, 0xfd, 0x21, 0x57, 0xa3, 0xb4, 0xef, - 0xfa, 0x22, 0xec, 0x9a, 0xa6, 0xef, 0x86, 0x98, 0x8c, 0xec, 0xe7, 0xee, 0x6b, 0xff, 0x4c, 0xf6, - 0x6b, 0x3a, 0x75, 0xef, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xa5, 0x27, 0xd2, 0x70, 0x0a, - 0x00, 0x00, + // 1069 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x5d, 0x6f, 0x1b, 0x45, + 0x17, 0xc7, 0xbb, 0x7e, 0x7b, 0xe2, 0xe3, 0xbc, 0x38, 0xf3, 0x84, 0xe2, 0x1a, 0x48, 0x22, 0x5f, + 0x85, 0x8a, 0xae, 0x49, 0x2a, 0x54, 0xa0, 0x48, 0x28, 0x6e, 0x52, 0xda, 0xa6, 0x11, 0xd1, 0x26, + 0xad, 0x14, 0x84, 0x58, 0x8d, 0xd7, 0x27, 0xf6, 0x28, 0xbb, 0x3b, 0xcb, 0xec, 0x38, 0x8d, 0x2f, + 0x11, 0x1f, 0x84, 0x8f, 0xc1, 0x0d, 0x97, 0x5c, 0x70, 0x89, 0xf8, 0x00, 0xa8, 0xca, 0x07, 0x41, + 0x68, 0x5e, 0xd6, 0x5e, 0x07, 0x2a, 0xc7, 0xc0, 0x9d, 0xcf, 0x39, 0xfe, 0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, 0x16, 0x95, 0xe8, 0xa9, 0xd5, 0x34, 0x7f, 0x72, 0xa0, 0x3a, 0xde, + 0x13, 0x79, 0x96, 0x0d, 0x0e, 0xe7, 0x1f, 0x0d, 0x0e, 0xdb, 0x67, 0xcc, 0xf4, 0x08, 0xae, 0x5d, + 0x67, 0xe1, 0x5f, 0x5f, 0xa7, 0xfd, 0x2c, 0x72, 0x77, 0xda, 0xfa, 0xad, 0x08, 0x2b, 0xd7, 0x06, + 0xe6, 0x7f, 0xba, 0x89, 0x77, 0xa0, 0xd2, 0xe3, 0x11, 0x65, 0x71, 0xbe, 0x91, 0x5a, 0x17, 0xe9, + 0x40, 0xd6, 0xf2, 0x7d, 0xc9, 0x22, 0xe4, 0x43, 0x39, 0xf3, 0x0a, 0xbc, 0x65, 0xab, 0x38, 0x31, + 0x02, 0xb2, 0x09, 0x8b, 0x3d, 0x8c, 0x47, 0x3e, 0x8f, 0xfd, 0x33, 0xca, 0x42, 0xfd, 0x4a, 0x58, + 0xf0, 0x40, 0xf9, 0xbe, 0x8c, 0x1f, 0x53, 0x16, 0x92, 0x6d, 0x20, 0x93, 0x57, 0x84, 0x9f, 0xa2, + 0xb8, 0x60, 0x01, 0xea, 0x21, 0x6a, 0xd3, 0xa9, 0x8b, 0x6c, 0xeb, 0xc7, 0x26, 0x48, 0xba, 0xba, + 0x03, 0x05, 0x82, 0x25, 0x92, 0x8b, 0xb4, 0x51, 0xd1, 0xa5, 0xfe, 0x70, 0xde, 0x97, 0x87, 0xea, + 0x48, 0x96, 0x31, 0x69, 0x48, 0x19, 0xb4, 0x79, 0x0a, 0x30, 0x89, 0x93, 0x0d, 0x58, 0x48, 0x04, + 0x4f, 0x50, 0xc8, 0xa9, 0x59, 0x34, 0x76, 0x92, 0xbb, 0xb0, 0x3c, 0x51, 0xfb, 0xaa, 0xf3, 0xe7, + 0x0e, 0x74, 0x69, 0x12, 0x3a, 0xc0, 0x51, 0x6b, 0x03, 0xfe, 0x67, 0x67, 0xb3, 0x7a, 0xfe, 0x99, + 0x99, 0xa0, 0xa0, 0x8e, 0xed, 0xf2, 0x9d, 0xfd, 0x5f, 0xae, 0xd6, 0x9d, 0x5f, 0xaf, 0xd6, 0x9d, + 0xd7, 0x57, 0xeb, 0xce, 0x57, 0x0f, 0xfa, 0x4c, 0x0e, 0x86, 0x5d, 0x37, 0xe0, 0x51, 0xdb, 0xec, + 0xea, 0x5e, 0x84, 0xe9, 0xc0, 0xfe, 0x6e, 0xbf, 0xf1, 0x29, 0xdc, 0xad, 0x68, 0xd7, 0xfd, 0x3f, + 0x03, 0x00, 0x00, 0xff, 0xff, 0xae, 0xf6, 0xad, 0x2e, 0x2e, 0x0b, 0x00, 0x00, } func (m *MetaRouter) Marshal() (dAtA []byte, err error) { @@ -1233,6 +1305,30 @@ func (m *MetaRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x9a } } + if m.MirrorPercentage != nil { + { + size, err := m.MirrorPercentage.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetaprotocolMetarouter(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.Mirror != nil { + { + size, err := m.Mirror.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetaprotocolMetarouter(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } if len(m.Route) > 0 { for iNdEx := len(m.Route) - 1; iNdEx >= 0; iNdEx-- { { @@ -1860,6 +1956,39 @@ func (m *GlobalRateLimit_Descriptor) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *Percent) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Percent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Percent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Value != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x9 + } + return len(dAtA) - i, nil +} + func encodeVarintMetaprotocolMetarouter(dAtA []byte, offset int, v uint64) int { offset -= sovMetaprotocolMetarouter(v) base := offset @@ -1923,6 +2052,14 @@ func (m *MetaRoute) Size() (n int) { n += 1 + l + sovMetaprotocolMetarouter(uint64(l)) } } + if m.Mirror != nil { + l = m.Mirror.Size() + n += 1 + l + sovMetaprotocolMetarouter(uint64(l)) + } + if m.MirrorPercentage != nil { + l = m.MirrorPercentage.Size() + n += 1 + l + sovMetaprotocolMetarouter(uint64(l)) + } if len(m.RequestMutation) > 0 { for _, e := range m.RequestMutation { l = e.Size() @@ -2211,6 +2348,21 @@ func (m *GlobalRateLimit_Descriptor) Size() (n int) { return n } +func (m *Percent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 9 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func sovMetaprotocolMetarouter(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2540,6 +2692,78 @@ func (m *MetaRoute) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Mirror", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaprotocolMetarouter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetaprotocolMetarouter + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetaprotocolMetarouter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Mirror == nil { + m.Mirror = &Destination{} + } + if err := m.Mirror.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MirrorPercentage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaprotocolMetarouter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetaprotocolMetarouter + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetaprotocolMetarouter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.MirrorPercentage == nil { + m.MirrorPercentage = &Percent{} + } + if err := m.MirrorPercentage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 19: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RequestMutation", wireType) @@ -4177,6 +4401,71 @@ func (m *GlobalRateLimit_Descriptor) Unmarshal(dAtA []byte) error { } return nil } +func (m *Percent) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaprotocolMetarouter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Percent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Percent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := skipMetaprotocolMetarouter(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthMetaprotocolMetarouter + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthMetaprotocolMetarouter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipMetaprotocolMetarouter(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/api/metaprotocol/v1alpha1/metaprotocol_metarouter.proto b/api/metaprotocol/v1alpha1/metaprotocol_metarouter.proto index 1935a4ac8..dc360dbca 100644 --- a/api/metaprotocol/v1alpha1/metaprotocol_metarouter.proto +++ b/api/metaprotocol/v1alpha1/metaprotocol_metarouter.proto @@ -114,12 +114,12 @@ message MetaRoute { //MetaFaultInjection fault = 4; - //MetaDestination mirror = 5; + Destination mirror = 5; // Percentage of the traffic to be mirrored by the `mirror` field. // If this field is absent, all the traffic (100%) will be mirrored. // Max value is 100. - // Percent mirror_percentage = 6; + Percent mirror_percentage = 6; // Specifies a list of key-value pairs that should be mutated for each request. How to interpret the key-value pairs // depends on the codec implementation @@ -295,4 +295,9 @@ message GlobalRateLimit { // Defines what properties in the requests should be sent to the rate limit service repeated GlobalRateLimit.Descriptor descriptors = 6 [(google.api.field_behavior) = REQUIRED]; +} + +// Percent specifies a percentage in the range of [0.0, 100.0]. +message Percent { + double value = 1; } \ No newline at end of file diff --git a/api/metaprotocol/v1alpha1/metaprotocol_metarouter_deepcopy.gen.go b/api/metaprotocol/v1alpha1/metaprotocol_metarouter_deepcopy.gen.go index a6f676b05..d15746c52 100644 --- a/api/metaprotocol/v1alpha1/metaprotocol_metarouter_deepcopy.gen.go +++ b/api/metaprotocol/v1alpha1/metaprotocol_metarouter_deepcopy.gen.go @@ -338,3 +338,24 @@ func (in *GlobalRateLimit_Descriptor) DeepCopy() *GlobalRateLimit_Descriptor { func (in *GlobalRateLimit_Descriptor) DeepCopyInterface() interface{} { return in.DeepCopy() } + +// DeepCopyInto supports using Percent within kubernetes types, where deepcopy-gen is used. +func (in *Percent) DeepCopyInto(out *Percent) { + p := proto.Clone(in).(*Percent) + *out = *p +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Percent. Required by controller-gen. +func (in *Percent) DeepCopy() *Percent { + if in == nil { + return nil + } + out := new(Percent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new Percent. Required by controller-gen. +func (in *Percent) DeepCopyInterface() interface{} { + return in.DeepCopy() +} diff --git a/api/metaprotocol/v1alpha1/metaprotocol_metarouter_json.gen.go b/api/metaprotocol/v1alpha1/metaprotocol_metarouter_json.gen.go index 6d5e2a799..ea991cebc 100644 --- a/api/metaprotocol/v1alpha1/metaprotocol_metarouter_json.gen.go +++ b/api/metaprotocol/v1alpha1/metaprotocol_metarouter_json.gen.go @@ -211,6 +211,17 @@ func (this *GlobalRateLimit_Descriptor) UnmarshalJSON(b []byte) error { return MetaprotocolMetarouterUnmarshaler.Unmarshal(bytes.NewReader(b), this) } +// MarshalJSON is a custom marshaler for Percent +func (this *Percent) MarshalJSON() ([]byte, error) { + str, err := MetaprotocolMetarouterMarshaler.MarshalToString(this) + return []byte(str), err +} + +// UnmarshalJSON is a custom unmarshaler for Percent +func (this *Percent) UnmarshalJSON(b []byte) error { + return MetaprotocolMetarouterUnmarshaler.Unmarshal(bytes.NewReader(b), this) +} + var ( MetaprotocolMetarouterMarshaler = &github_com_gogo_protobuf_jsonpb.Marshaler{} MetaprotocolMetarouterUnmarshaler = &github_com_gogo_protobuf_jsonpb.Unmarshaler{AllowUnknownFields: true} diff --git a/crd/kubernetes/customresourcedefinitions.gen.yaml b/crd/kubernetes/customresourcedefinitions.gen.yaml index 90869fbe6..b4ef37821 100644 --- a/crd/kubernetes/customresourcedefinitions.gen.yaml +++ b/crd/kubernetes/customresourcedefinitions.gen.yaml @@ -392,6 +392,32 @@ spec: attribute is specified, presence of the attribute is checked. type: object type: object + mirror: + properties: + host: + description: The name of a service from the service registry. + format: string + type: string + port: + description: Specifies the port on the host that is being + addressed. + properties: + number: + type: integer + type: object + subset: + description: The name of a subset within the service. + format: string + type: string + type: object + mirrorPercentage: + description: Percentage of the traffic to be mirrored by the + `mirror` field. + properties: + value: + format: double + type: number + type: object name: description: The name assigned to the route for debugging purposes. format: string diff --git a/k8s/crd.yaml b/k8s/crd.yaml index 90869fbe6..b4ef37821 100644 --- a/k8s/crd.yaml +++ b/k8s/crd.yaml @@ -392,6 +392,32 @@ spec: attribute is specified, presence of the attribute is checked. type: object type: object + mirror: + properties: + host: + description: The name of a service from the service registry. + format: string + type: string + port: + description: Specifies the port on the host that is being + addressed. + properties: + number: + type: integer + type: object + subset: + description: The name of a subset within the service. + format: string + type: string + type: object + mirrorPercentage: + description: Percentage of the traffic to be mirrored by the + `mirror` field. + properties: + value: + format: double + type: number + type: object name: description: The name assigned to the route for debugging purposes. format: string