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
dab9b84b
Commit
dab9b84b
authored
Oct 16, 2017
by
m1093782566
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add proxy metrics in app level
parent
1ab5075c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
7 deletions
+39
-7
BUILD
cmd/kube-proxy/app/BUILD
+1
-0
server_others.go
cmd/kube-proxy/app/server_others.go
+3
-1
BUILD
pkg/proxy/BUILD
+1
-0
BUILD
pkg/proxy/iptables/BUILD
+1
-2
proxier.go
pkg/proxy/iptables/proxier.go
+2
-1
BUILD
pkg/proxy/ipvs/BUILD
+1
-0
proxier.go
pkg/proxy/ipvs/proxier.go
+2
-0
BUILD
pkg/proxy/metrics/BUILD
+23
-0
metrics.go
pkg/proxy/metrics/metrics.go
+5
-3
No files found.
cmd/kube-proxy/app/BUILD
View file @
dab9b84b
...
@@ -36,6 +36,7 @@ go_library(
...
@@ -36,6 +36,7 @@ go_library(
"//pkg/proxy/healthcheck:go_default_library",
"//pkg/proxy/healthcheck:go_default_library",
"//pkg/proxy/iptables:go_default_library",
"//pkg/proxy/iptables:go_default_library",
"//pkg/proxy/ipvs:go_default_library",
"//pkg/proxy/ipvs:go_default_library",
"//pkg/proxy/metrics:go_default_library",
"//pkg/proxy/userspace:go_default_library",
"//pkg/proxy/userspace:go_default_library",
"//pkg/util/configz:go_default_library",
"//pkg/util/configz:go_default_library",
"//pkg/util/dbus:go_default_library",
"//pkg/util/dbus:go_default_library",
...
...
cmd/kube-proxy/app/server_others.go
View file @
dab9b84b
...
@@ -39,6 +39,7 @@ import (
...
@@ -39,6 +39,7 @@ import (
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/proxy/iptables"
"k8s.io/kubernetes/pkg/proxy/iptables"
"k8s.io/kubernetes/pkg/proxy/ipvs"
"k8s.io/kubernetes/pkg/proxy/ipvs"
"k8s.io/kubernetes/pkg/proxy/metrics"
"k8s.io/kubernetes/pkg/proxy/userspace"
"k8s.io/kubernetes/pkg/proxy/userspace"
"k8s.io/kubernetes/pkg/util/configz"
"k8s.io/kubernetes/pkg/util/configz"
utildbus
"k8s.io/kubernetes/pkg/util/dbus"
utildbus
"k8s.io/kubernetes/pkg/util/dbus"
...
@@ -143,7 +144,6 @@ func NewProxyServer(config *componentconfig.KubeProxyConfiguration, cleanupAndEx
...
@@ -143,7 +144,6 @@ func NewProxyServer(config *componentconfig.KubeProxyConfiguration, cleanupAndEx
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to create proxier: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"unable to create proxier: %v"
,
err
)
}
}
iptables
.
RegisterMetrics
()
proxier
=
proxierIPTables
proxier
=
proxierIPTables
serviceEventHandler
=
proxierIPTables
serviceEventHandler
=
proxierIPTables
endpointsEventHandler
=
proxierIPTables
endpointsEventHandler
=
proxierIPTables
...
@@ -218,6 +218,8 @@ func NewProxyServer(config *componentconfig.KubeProxyConfiguration, cleanupAndEx
...
@@ -218,6 +218,8 @@ func NewProxyServer(config *componentconfig.KubeProxyConfiguration, cleanupAndEx
iptInterface
.
AddReloadFunc
(
proxier
.
Sync
)
iptInterface
.
AddReloadFunc
(
proxier
.
Sync
)
metrics
.
RegisterMetrics
()
return
&
ProxyServer
{
return
&
ProxyServer
{
Client
:
client
,
Client
:
client
,
EventClient
:
eventClient
,
EventClient
:
eventClient
,
...
...
pkg/proxy/BUILD
View file @
dab9b84b
...
@@ -30,6 +30,7 @@ filegroup(
...
@@ -30,6 +30,7 @@ filegroup(
"//pkg/proxy/healthcheck:all-srcs",
"//pkg/proxy/healthcheck:all-srcs",
"//pkg/proxy/iptables:all-srcs",
"//pkg/proxy/iptables:all-srcs",
"//pkg/proxy/ipvs:all-srcs",
"//pkg/proxy/ipvs:all-srcs",
"//pkg/proxy/metrics:all-srcs",
"//pkg/proxy/userspace:all-srcs",
"//pkg/proxy/userspace:all-srcs",
"//pkg/proxy/util:all-srcs",
"//pkg/proxy/util:all-srcs",
"//pkg/proxy/winkernel:all-srcs",
"//pkg/proxy/winkernel:all-srcs",
...
...
pkg/proxy/iptables/BUILD
View file @
dab9b84b
...
@@ -9,7 +9,6 @@ load(
...
@@ -9,7 +9,6 @@ load(
go_library(
go_library(
name = "go_default_library",
name = "go_default_library",
srcs = [
srcs = [
"metrics.go",
"proxier.go",
"proxier.go",
],
],
importpath = "k8s.io/kubernetes/pkg/proxy/iptables",
importpath = "k8s.io/kubernetes/pkg/proxy/iptables",
...
@@ -20,13 +19,13 @@ go_library(
...
@@ -20,13 +19,13 @@ go_library(
"//pkg/features:go_default_library",
"//pkg/features:go_default_library",
"//pkg/proxy:go_default_library",
"//pkg/proxy:go_default_library",
"//pkg/proxy/healthcheck:go_default_library",
"//pkg/proxy/healthcheck:go_default_library",
"//pkg/proxy/metrics:go_default_library",
"//pkg/proxy/util:go_default_library",
"//pkg/proxy/util:go_default_library",
"//pkg/util/async:go_default_library",
"//pkg/util/async:go_default_library",
"//pkg/util/iptables:go_default_library",
"//pkg/util/iptables:go_default_library",
"//pkg/util/sysctl:go_default_library",
"//pkg/util/sysctl:go_default_library",
"//pkg/util/version:go_default_library",
"//pkg/util/version:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
...
...
pkg/proxy/iptables/proxier.go
View file @
dab9b84b
...
@@ -47,6 +47,7 @@ import (
...
@@ -47,6 +47,7 @@ import (
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/proxy"
"k8s.io/kubernetes/pkg/proxy"
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/proxy/metrics"
utilproxy
"k8s.io/kubernetes/pkg/proxy/util"
utilproxy
"k8s.io/kubernetes/pkg/proxy/util"
"k8s.io/kubernetes/pkg/util/async"
"k8s.io/kubernetes/pkg/util/async"
utiliptables
"k8s.io/kubernetes/pkg/util/iptables"
utiliptables
"k8s.io/kubernetes/pkg/util/iptables"
...
@@ -954,7 +955,7 @@ func (proxier *Proxier) syncProxyRules() {
...
@@ -954,7 +955,7 @@ func (proxier *Proxier) syncProxyRules() {
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
SyncProxyRulesLatency
.
Observe
(
s
inceInMicroseconds
(
start
))
metrics
.
SyncProxyRulesLatency
.
Observe
(
metrics
.
S
inceInMicroseconds
(
start
))
glog
.
V
(
4
)
.
Infof
(
"syncProxyRules took %v"
,
time
.
Since
(
start
))
glog
.
V
(
4
)
.
Infof
(
"syncProxyRules took %v"
,
time
.
Since
(
start
))
}()
}()
// don't sync rules till we've received services and endpoints
// don't sync rules till we've received services and endpoints
...
...
pkg/proxy/ipvs/BUILD
View file @
dab9b84b
...
@@ -50,6 +50,7 @@ go_library(
...
@@ -50,6 +50,7 @@ go_library(
"//pkg/features:go_default_library",
"//pkg/features:go_default_library",
"//pkg/proxy:go_default_library",
"//pkg/proxy:go_default_library",
"//pkg/proxy/healthcheck:go_default_library",
"//pkg/proxy/healthcheck:go_default_library",
"//pkg/proxy/metrics:go_default_library",
"//pkg/proxy/util:go_default_library",
"//pkg/proxy/util:go_default_library",
"//pkg/util/async:go_default_library",
"//pkg/util/async:go_default_library",
"//pkg/util/iptables:go_default_library",
"//pkg/util/iptables:go_default_library",
...
...
pkg/proxy/ipvs/proxier.go
View file @
dab9b84b
...
@@ -46,6 +46,7 @@ import (
...
@@ -46,6 +46,7 @@ import (
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/proxy"
"k8s.io/kubernetes/pkg/proxy"
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/proxy/metrics"
utilproxy
"k8s.io/kubernetes/pkg/proxy/util"
utilproxy
"k8s.io/kubernetes/pkg/proxy/util"
"k8s.io/kubernetes/pkg/util/async"
"k8s.io/kubernetes/pkg/util/async"
utiliptables
"k8s.io/kubernetes/pkg/util/iptables"
utiliptables
"k8s.io/kubernetes/pkg/util/iptables"
...
@@ -868,6 +869,7 @@ func (proxier *Proxier) syncProxyRules() {
...
@@ -868,6 +869,7 @@ func (proxier *Proxier) syncProxyRules() {
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
metrics
.
SyncProxyRulesLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
glog
.
V
(
4
)
.
Infof
(
"syncProxyRules took %v"
,
time
.
Since
(
start
))
glog
.
V
(
4
)
.
Infof
(
"syncProxyRules took %v"
,
time
.
Since
(
start
))
}()
}()
// don't sync rules till we've received services and endpoints
// don't sync rules till we've received services and endpoints
...
...
pkg/proxy/metrics/BUILD
0 → 100644
View file @
dab9b84b
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["metrics.go"],
importpath = "k8s.io/kubernetes/pkg/proxy/metrics",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/prometheus/client_golang/prometheus:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
pkg/proxy/
iptable
s/metrics.go
→
pkg/proxy/
metric
s/metrics.go
View file @
dab9b84b
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
iptable
s
package
metric
s
import
(
import
(
"sync"
"sync"
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
const
kubeProxySubsystem
=
"kubeproxy"
const
kubeProxySubsystem
=
"kubeproxy"
var
(
var
(
// SyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules.
SyncProxyRulesLatency
=
prometheus
.
NewHistogram
(
SyncProxyRulesLatency
=
prometheus
.
NewHistogram
(
prometheus
.
HistogramOpts
{
prometheus
.
HistogramOpts
{
Subsystem
:
kubeProxySubsystem
,
Subsystem
:
kubeProxySubsystem
,
...
@@ -38,13 +39,14 @@ var (
...
@@ -38,13 +39,14 @@ var (
var
registerMetricsOnce
sync
.
Once
var
registerMetricsOnce
sync
.
Once
// RegisterMetrics registers sync proxy rules latency metrics
func
RegisterMetrics
()
{
func
RegisterMetrics
()
{
registerMetricsOnce
.
Do
(
func
()
{
registerMetricsOnce
.
Do
(
func
()
{
prometheus
.
MustRegister
(
SyncProxyRulesLatency
)
prometheus
.
MustRegister
(
SyncProxyRulesLatency
)
})
})
}
}
//
G
ets the time since the specified start in microseconds.
//
SinceInMicroseconds g
ets the time since the specified start in microseconds.
func
s
inceInMicroseconds
(
start
time
.
Time
)
float64
{
func
S
inceInMicroseconds
(
start
time
.
Time
)
float64
{
return
float64
(
time
.
Since
(
start
)
.
Nanoseconds
()
/
time
.
Microsecond
.
Nanoseconds
())
return
float64
(
time
.
Since
(
start
)
.
Nanoseconds
()
/
time
.
Microsecond
.
Nanoseconds
())
}
}
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