Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
65de86e7
Unverified
Commit
65de86e7
authored
Jun 20, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jun 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #78602 from paulgmiller/release-1.14
cherry pick of #74027: proxy: add some useful metrics
parents
cb7218fa
85bdd816
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
0 deletions
+79
-0
BUILD
pkg/proxy/BUILD
+1
-0
endpoints.go
pkg/proxy/endpoints.go
+5
-0
proxier.go
pkg/proxy/iptables/proxier.go
+1
-0
proxier.go
pkg/proxy/ipvs/proxier.go
+1
-0
metrics.go
pkg/proxy/metrics/metrics.go
+55
-0
service.go
pkg/proxy/service.go
+4
-0
metrics.go
pkg/proxy/winkernel/metrics.go
+11
-0
proxier.go
pkg/proxy/winkernel/proxier.go
+1
-0
No files found.
pkg/proxy/BUILD
View file @
65de86e7
...
@@ -17,6 +17,7 @@ go_library(
...
@@ -17,6 +17,7 @@ go_library(
importpath = "k8s.io/kubernetes/pkg/proxy",
importpath = "k8s.io/kubernetes/pkg/proxy",
deps = [
deps = [
"//pkg/api/v1/service:go_default_library",
"//pkg/api/v1/service:go_default_library",
"//pkg/proxy/metrics:go_default_library",
"//pkg/proxy/util:go_default_library",
"//pkg/proxy/util:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
...
...
pkg/proxy/endpoints.go
View file @
65de86e7
...
@@ -29,6 +29,7 @@ import (
...
@@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/tools/record"
"k8s.io/kubernetes/pkg/proxy/metrics"
utilproxy
"k8s.io/kubernetes/pkg/proxy/util"
utilproxy
"k8s.io/kubernetes/pkg/proxy/util"
utilnet
"k8s.io/utils/net"
utilnet
"k8s.io/utils/net"
)
)
...
@@ -127,6 +128,7 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
...
@@ -127,6 +128,7 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
if
endpoints
==
nil
{
if
endpoints
==
nil
{
return
false
return
false
}
}
metrics
.
EndpointChangesTotal
.
Inc
()
namespacedName
:=
types
.
NamespacedName
{
Namespace
:
endpoints
.
Namespace
,
Name
:
endpoints
.
Name
}
namespacedName
:=
types
.
NamespacedName
{
Namespace
:
endpoints
.
Namespace
,
Name
:
endpoints
.
Name
}
ect
.
lock
.
Lock
()
ect
.
lock
.
Lock
()
...
@@ -154,6 +156,8 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
...
@@ -154,6 +156,8 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
// should be exported.
// should be exported.
delete
(
ect
.
lastChangeTriggerTimes
,
namespacedName
)
delete
(
ect
.
lastChangeTriggerTimes
,
namespacedName
)
}
}
metrics
.
EndpointChangesPending
.
Set
(
float64
(
len
(
ect
.
items
)))
return
len
(
ect
.
items
)
>
0
return
len
(
ect
.
items
)
>
0
}
}
...
@@ -295,6 +299,7 @@ func (endpointsMap EndpointsMap) apply(changes *EndpointChangeTracker, staleEndp
...
@@ -295,6 +299,7 @@ func (endpointsMap EndpointsMap) apply(changes *EndpointChangeTracker, staleEndp
detectStaleConnections
(
change
.
previous
,
change
.
current
,
staleEndpoints
,
staleServiceNames
)
detectStaleConnections
(
change
.
previous
,
change
.
current
,
staleEndpoints
,
staleServiceNames
)
}
}
changes
.
items
=
make
(
map
[
types
.
NamespacedName
]
*
endpointsChange
)
changes
.
items
=
make
(
map
[
types
.
NamespacedName
]
*
endpointsChange
)
metrics
.
EndpointChangesPending
.
Set
(
0
)
for
_
,
lastChangeTriggerTime
:=
range
changes
.
lastChangeTriggerTimes
{
for
_
,
lastChangeTriggerTime
:=
range
changes
.
lastChangeTriggerTimes
{
*
lastChangeTriggerTimes
=
append
(
*
lastChangeTriggerTimes
,
lastChangeTriggerTime
...
)
*
lastChangeTriggerTimes
=
append
(
*
lastChangeTriggerTimes
,
lastChangeTriggerTime
...
)
}
}
...
...
pkg/proxy/iptables/proxier.go
View file @
65de86e7
...
@@ -1387,6 +1387,7 @@ func (proxier *Proxier) syncProxyRules() {
...
@@ -1387,6 +1387,7 @@ func (proxier *Proxier) syncProxyRules() {
if
proxier
.
healthzServer
!=
nil
{
if
proxier
.
healthzServer
!=
nil
{
proxier
.
healthzServer
.
UpdateTimestamp
()
proxier
.
healthzServer
.
UpdateTimestamp
()
}
}
metrics
.
SyncProxyRulesLastTimestamp
.
SetToCurrentTime
()
// Update healthchecks. The endpoints list might include services that are
// Update healthchecks. The endpoints list might include services that are
// not "OnlyLocal", but the services list will not, and the healthChecker
// not "OnlyLocal", but the services list will not, and the healthChecker
...
...
pkg/proxy/ipvs/proxier.go
View file @
65de86e7
...
@@ -1245,6 +1245,7 @@ func (proxier *Proxier) syncProxyRules() {
...
@@ -1245,6 +1245,7 @@ func (proxier *Proxier) syncProxyRules() {
if
proxier
.
healthzServer
!=
nil
{
if
proxier
.
healthzServer
!=
nil
{
proxier
.
healthzServer
.
UpdateTimestamp
()
proxier
.
healthzServer
.
UpdateTimestamp
()
}
}
metrics
.
SyncProxyRulesLastTimestamp
.
SetToCurrentTime
()
// Update healthchecks. The endpoints list might include services that are
// Update healthchecks. The endpoints list might include services that are
// not "OnlyLocal", but the services list will not, and the healthChecker
// not "OnlyLocal", but the services list will not, and the healthChecker
...
...
pkg/proxy/metrics/metrics.go
View file @
65de86e7
...
@@ -46,6 +46,16 @@ var (
...
@@ -46,6 +46,16 @@ var (
},
},
)
)
// SyncProxyRulesLastTimestamp is the timestamp proxy rules were last
// successfully synced.
SyncProxyRulesLastTimestamp
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Subsystem
:
kubeProxySubsystem
,
Name
:
"sync_proxy_rules_last_timestamp_seconds"
,
Help
:
"The last time proxy rules were successfully synced"
,
},
)
// NetworkProgrammingLatency is defined as the time it took to program the network - from the time
// NetworkProgrammingLatency is defined as the time it took to program the network - from the time
// the service or pod has changed to the time the change was propagated and the proper kube-proxy
// the service or pod has changed to the time the change was propagated and the proper kube-proxy
// rules were synced. Exported for each endpoints object that were part of the rules sync.
// rules were synced. Exported for each endpoints object that were part of the rules sync.
...
@@ -63,6 +73,46 @@ var (
...
@@ -63,6 +73,46 @@ var (
Buckets
:
prometheus
.
ExponentialBuckets
(
0.001
,
2
,
20
),
Buckets
:
prometheus
.
ExponentialBuckets
(
0.001
,
2
,
20
),
},
},
)
)
// EndpointChangesPending is the number of pending endpoint changes that
// have not yet been synced to the proxy.
EndpointChangesPending
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Subsystem
:
kubeProxySubsystem
,
Name
:
"sync_proxy_rules_endpoint_changes_pending"
,
Help
:
"Pending proxy rules Endpoint changes"
,
},
)
// EndpointChangesTotal is the number of endpoint changes that the proxy
// has seen.
EndpointChangesTotal
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Subsystem
:
kubeProxySubsystem
,
Name
:
"sync_proxy_rules_endpoint_changes_total"
,
Help
:
"Cumulative proxy rules Endpoint changes"
,
},
)
// ServiceChangesPending is the number of pending service changes that
// have not yet been synced to the proxy.
ServiceChangesPending
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Subsystem
:
kubeProxySubsystem
,
Name
:
"sync_proxy_rules_service_changes_pending"
,
Help
:
"Pending proxy rules Service changes"
,
},
)
// ServiceChangesTotal is the number of service changes that the proxy has
// seen.
ServiceChangesTotal
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Subsystem
:
kubeProxySubsystem
,
Name
:
"sync_proxy_rules_service_changes_total"
,
Help
:
"Cumulative proxy rules Service changes"
,
},
)
)
)
var
registerMetricsOnce
sync
.
Once
var
registerMetricsOnce
sync
.
Once
...
@@ -72,7 +122,12 @@ func RegisterMetrics() {
...
@@ -72,7 +122,12 @@ func RegisterMetrics() {
registerMetricsOnce
.
Do
(
func
()
{
registerMetricsOnce
.
Do
(
func
()
{
prometheus
.
MustRegister
(
SyncProxyRulesLatency
)
prometheus
.
MustRegister
(
SyncProxyRulesLatency
)
prometheus
.
MustRegister
(
DeprecatedSyncProxyRulesLatency
)
prometheus
.
MustRegister
(
DeprecatedSyncProxyRulesLatency
)
prometheus
.
MustRegister
(
SyncProxyRulesLastTimestamp
)
prometheus
.
MustRegister
(
NetworkProgrammingLatency
)
prometheus
.
MustRegister
(
NetworkProgrammingLatency
)
prometheus
.
MustRegister
(
EndpointChangesPending
)
prometheus
.
MustRegister
(
EndpointChangesTotal
)
prometheus
.
MustRegister
(
ServiceChangesPending
)
prometheus
.
MustRegister
(
ServiceChangesTotal
)
})
})
}
}
...
...
pkg/proxy/service.go
View file @
65de86e7
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/tools/record"
apiservice
"k8s.io/kubernetes/pkg/api/v1/service"
apiservice
"k8s.io/kubernetes/pkg/api/v1/service"
"k8s.io/kubernetes/pkg/proxy/metrics"
utilproxy
"k8s.io/kubernetes/pkg/proxy/util"
utilproxy
"k8s.io/kubernetes/pkg/proxy/util"
utilnet
"k8s.io/utils/net"
utilnet
"k8s.io/utils/net"
)
)
...
@@ -198,6 +199,7 @@ func (sct *ServiceChangeTracker) Update(previous, current *v1.Service) bool {
...
@@ -198,6 +199,7 @@ func (sct *ServiceChangeTracker) Update(previous, current *v1.Service) bool {
if
svc
==
nil
{
if
svc
==
nil
{
return
false
return
false
}
}
metrics
.
ServiceChangesTotal
.
Inc
()
namespacedName
:=
types
.
NamespacedName
{
Namespace
:
svc
.
Namespace
,
Name
:
svc
.
Name
}
namespacedName
:=
types
.
NamespacedName
{
Namespace
:
svc
.
Namespace
,
Name
:
svc
.
Name
}
sct
.
lock
.
Lock
()
sct
.
lock
.
Lock
()
...
@@ -214,6 +216,7 @@ func (sct *ServiceChangeTracker) Update(previous, current *v1.Service) bool {
...
@@ -214,6 +216,7 @@ func (sct *ServiceChangeTracker) Update(previous, current *v1.Service) bool {
if
reflect
.
DeepEqual
(
change
.
previous
,
change
.
current
)
{
if
reflect
.
DeepEqual
(
change
.
previous
,
change
.
current
)
{
delete
(
sct
.
items
,
namespacedName
)
delete
(
sct
.
items
,
namespacedName
)
}
}
metrics
.
ServiceChangesPending
.
Set
(
float64
(
len
(
sct
.
items
)))
return
len
(
sct
.
items
)
>
0
return
len
(
sct
.
items
)
>
0
}
}
...
@@ -296,6 +299,7 @@ func (serviceMap *ServiceMap) apply(changes *ServiceChangeTracker, UDPStaleClust
...
@@ -296,6 +299,7 @@ func (serviceMap *ServiceMap) apply(changes *ServiceChangeTracker, UDPStaleClust
}
}
// clear changes after applying them to ServiceMap.
// clear changes after applying them to ServiceMap.
changes
.
items
=
make
(
map
[
types
.
NamespacedName
]
*
serviceChange
)
changes
.
items
=
make
(
map
[
types
.
NamespacedName
]
*
serviceChange
)
metrics
.
ServiceChangesPending
.
Set
(
0
)
return
return
}
}
...
...
pkg/proxy/winkernel/metrics.go
View file @
65de86e7
...
@@ -43,6 +43,16 @@ var (
...
@@ -43,6 +43,16 @@ var (
Buckets
:
prometheus
.
ExponentialBuckets
(
1000
,
2
,
15
),
Buckets
:
prometheus
.
ExponentialBuckets
(
1000
,
2
,
15
),
},
},
)
)
// SyncProxyRulesLastTimestamp is the timestamp proxy rules were last
// successfully synced.
SyncProxyRulesLastTimestamp
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Subsystem
:
kubeProxySubsystem
,
Name
:
"sync_proxy_rules_last_timestamp_seconds"
,
Help
:
"The last time proxy rules were successfully synced"
,
},
)
)
)
var
registerMetricsOnce
sync
.
Once
var
registerMetricsOnce
sync
.
Once
...
@@ -51,6 +61,7 @@ func RegisterMetrics() {
...
@@ -51,6 +61,7 @@ func RegisterMetrics() {
registerMetricsOnce
.
Do
(
func
()
{
registerMetricsOnce
.
Do
(
func
()
{
prometheus
.
MustRegister
(
SyncProxyRulesLatency
)
prometheus
.
MustRegister
(
SyncProxyRulesLatency
)
prometheus
.
MustRegister
(
DeprecatedSyncProxyRulesLatency
)
prometheus
.
MustRegister
(
DeprecatedSyncProxyRulesLatency
)
prometheus
.
MustRegister
(
SyncProxyRulesLastTimestamp
)
})
})
}
}
...
...
pkg/proxy/winkernel/proxier.go
View file @
65de86e7
...
@@ -1197,6 +1197,7 @@ func (proxier *Proxier) syncProxyRules() {
...
@@ -1197,6 +1197,7 @@ func (proxier *Proxier) syncProxyRules() {
if
proxier
.
healthzServer
!=
nil
{
if
proxier
.
healthzServer
!=
nil
{
proxier
.
healthzServer
.
UpdateTimestamp
()
proxier
.
healthzServer
.
UpdateTimestamp
()
}
}
SyncProxyRulesLastTimestamp
.
SetToCurrentTime
()
// Update healthchecks. The endpoints list might include services that are
// Update healthchecks. The endpoints list might include services that are
// not "OnlyLocal", but the services list will not, and the healthChecker
// not "OnlyLocal", but the services list will not, and the healthChecker
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment