Skip to content

Commit

Permalink
mixer: implement reporter attributes (istio#5959)
Browse files Browse the repository at this point in the history
* implement reporter attributes

Signed-off-by: Kuat Yessenov <kuat@google.com>

* format

Signed-off-by: Kuat Yessenov <kuat@google.com>
  • Loading branch information
kyessenov authored and istio-testing committed Jun 4, 2018
1 parent bc7033b commit 3002592
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ spec:
valueType: TIMESTAMP
context.time:
valueType: TIMESTAMP
context.reporter.local:
valueType: BOOL
context.reporter.uid:
valueType: STRING
api.service:
valueType: STRING
api.version:
Expand Down
4 changes: 4 additions & 0 deletions mixer/testdata/config/attributes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ spec:
valueType: TIMESTAMP
context.time:
valueType: TIMESTAMP
context.reporter.local:
valueType: BOOL
context.reporter.uid:
valueType: STRING
api.service:
valueType: STRING
api.version:
Expand Down
16 changes: 16 additions & 0 deletions pilot/docker/envoy_pilot.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ static_resources:
bytes_value: {{ .PodIP }}
destination.port:
int64_value: 15003
context.reporter.local:
bool_value: true
context.reporter.uid:
string_value: kubernetes://{{ .PodName }}.{{ .PodNamespace }}
transport:
check_cluster: mixer_check_server
report_cluster: mixer_report_server
Expand Down Expand Up @@ -160,6 +164,10 @@ static_resources:
bytes_value: {{ .PodIP }}
destination.port:
int64_value: 15011
context.reporter.local:
bool_value: true
context.reporter.uid:
string_value: kubernetes://{{ .PodName }}.{{ .PodNamespace }}
transport:
check_cluster: mixer_check_server
report_cluster: mixer_report_server
Expand Down Expand Up @@ -225,6 +233,10 @@ static_resources:
bytes_value: {{ .PodIP }}
destination.port:
int64_value: 15005
context.reporter.local:
bool_value: true
context.reporter.uid:
string_value: kubernetes://{{ .PodName }}.{{ .PodNamespace }}
transport:
check_cluster: mixer_check_server
report_cluster: mixer_report_server
Expand Down Expand Up @@ -290,6 +302,10 @@ static_resources:
bytes_value: {{ .PodIP }}
destination.port:
int64_value: 15007
context.reporter.local:
bool_value: true
context.reporter.uid:
string_value: kubernetes://{{ .PodName }}.{{ .PodNamespace }}
transport:
check_cluster: mixer_check_server
report_cluster: mixer_report_server
Expand Down
16 changes: 8 additions & 8 deletions pilot/docker/envoy_policy.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ static_resources:
filter_chains:
- filters:
- config:
access_log:
- config:
path: /dev/stdout
name: envoy.file_access_log
codec_type: HTTP2
http2_protocol_options:
max_concurrent_streams: 1073741824
Expand All @@ -88,6 +84,10 @@ static_resources:
bytes_value: {{ .PodIP }}
destination.port:
int64_value: 15004
context.reporter.local:
bool_value: true
context.reporter.uid:
string_value: kubernetes://{{ .PodName }}.{{ .PodNamespace }}
transport:
check_cluster: mixer_check_server
report_cluster: mixer_report_server
Expand Down Expand Up @@ -133,10 +133,6 @@ static_resources:
filter_chains:
- filters:
- config:
access_log:
- config:
path: /dev/stdout
name: envoy.file_access_log
codec_type: HTTP2
http2_protocol_options:
max_concurrent_streams: 1073741824
Expand All @@ -160,6 +156,10 @@ static_resources:
bytes_value: {{ .PodIP }}
destination.port:
int64_value: 9091
context.reporter.local:
bool_value: true
context.reporter.uid:
string_value: kubernetes://{{ .PodName }}.{{ .PodNamespace }}
transport:
check_cluster: mixer_check_server
report_cluster: mixer_report_server
Expand Down
16 changes: 8 additions & 8 deletions pilot/docker/envoy_telemetry.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ static_resources:
filter_chains:
- filters:
- config:
access_log:
- config:
path: /dev/stdout
name: envoy.file_access_log
codec_type: HTTP2
http2_protocol_options:
max_concurrent_streams: 1073741824
Expand All @@ -60,6 +56,10 @@ static_resources:
bytes_value: {{ .PodIP }}
destination.port:
int64_value: 15004
context.reporter.local:
bool_value: true
context.reporter.uid:
string_value: kubernetes://{{ .PodName }}.{{ .PodNamespace }}
transport:
check_cluster: mixer_check_server
report_cluster: in.9092
Expand Down Expand Up @@ -105,10 +105,6 @@ static_resources:
filter_chains:
- filters:
- config:
access_log:
- config:
path: /dev/stdout
name: envoy.file_access_log
codec_type: HTTP2
http2_protocol_options:
max_concurrent_streams: 1073741824
Expand All @@ -132,6 +128,10 @@ static_resources:
bytes_value: {{ .PodIP }}
destination.port:
int64_value: 9091
context.reporter.local:
bool_value: true
context.reporter.uid:
string_value: kubernetes://{{ .PodName }}.{{ .PodNamespace }}
transport:
check_cluster: mixer_check_server
report_cluster: in.9092
Expand Down
15 changes: 14 additions & 1 deletion pilot/pkg/networking/plugin/mixer/mixer.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ func buildHTTPMixerFilterConfig(mesh *meshconfig.MeshConfig, role model.Proxy, n

mxConfig := &mccpb.HttpClientConfig{
MixerAttributes: &mpb.Attributes{
Attributes: map[string]*mpb.Attributes_AttributeValue{},
Attributes: map[string]*mpb.Attributes_AttributeValue{
"context.reporter.uid": {
Value: &mpb.Attributes_AttributeValue_StringValue{StringValue: "kubernetes://" + role.ID},
},
},
},
ServiceConfigs: map[string]*mccpb.ServiceConfig{},
Transport: transport,
Expand All @@ -247,6 +251,9 @@ func buildHTTPMixerFilterConfig(mesh *meshconfig.MeshConfig, role model.Proxy, n
// for outboundRoutes there are no default MixerAttributes except for gateway.
// specific MixerAttributes are in per route configuration.
v1.AddStandardNodeAttributes(mxConfig.MixerAttributes.Attributes, v1.AttrDestinationPrefix, role.IPAddress, role.ID, labels)
mxConfig.MixerAttributes.Attributes["context.reporter.local"] = &mpb.Attributes_AttributeValue{
Value: &mpb.Attributes_AttributeValue_BoolValue{BoolValue: true},
}
}

if role.Type == model.Sidecar && !outboundRoute {
Expand Down Expand Up @@ -275,6 +282,12 @@ func buildHTTPMixerFilterConfig(mesh *meshconfig.MeshConfig, role model.Proxy, n
func buildTCPMixerFilterConfig(mesh *meshconfig.MeshConfig, role model.Proxy, instance *model.ServiceInstance) *mccpb.TcpClientConfig {
attrs := v1.StandardNodeAttributes(v1.AttrDestinationPrefix, role.IPAddress, role.ID, nil)
attrs[v1.AttrDestinationService] = &mpb.Attributes_AttributeValue{Value: &mpb.Attributes_AttributeValue_StringValue{instance.Service.Hostname.String()}}
attrs["context.reporter.uid"] = &mpb.Attributes_AttributeValue{
Value: &mpb.Attributes_AttributeValue_StringValue{StringValue: "kubernetes://" + role.ID},
}
attrs["context.reporter.local"] = &mpb.Attributes_AttributeValue{
Value: &mpb.Attributes_AttributeValue_BoolValue{BoolValue: true},
}

mcs, _, _ := net.SplitHostPort(mesh.MixerCheckServer)
mrs, _, _ := net.SplitHostPort(mesh.MixerReportServer)
Expand Down

0 comments on commit 3002592

Please sign in to comment.