mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #128989 from Henrywu573/kube-proxy-statuz-new
Add statusz endpoint for kube-proxy
This commit is contained in:
commit
54eddbd50f
@ -60,7 +60,9 @@ import (
|
||||
"k8s.io/component-base/metrics/prometheus/slis"
|
||||
"k8s.io/component-base/version"
|
||||
"k8s.io/component-base/version/verflag"
|
||||
zpagesfeatures "k8s.io/component-base/zpages/features"
|
||||
"k8s.io/component-base/zpages/flagz"
|
||||
"k8s.io/component-base/zpages/statusz"
|
||||
nodeutil "k8s.io/component-helpers/node/util"
|
||||
"k8s.io/klog/v2"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
@ -78,6 +80,11 @@ import (
|
||||
netutils "k8s.io/utils/net"
|
||||
)
|
||||
|
||||
const (
|
||||
// kubeProxy defines variable used internally when referring to kube-proxy component
|
||||
kubeProxy = "kube-proxy"
|
||||
)
|
||||
|
||||
func init() {
|
||||
utilruntime.Must(metricsfeatures.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
|
||||
utilruntime.Must(logsapi.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
|
||||
@ -93,7 +100,7 @@ func NewProxyCommand() *cobra.Command {
|
||||
opts := NewOptions()
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "kube-proxy",
|
||||
Use: kubeProxy,
|
||||
Long: `The Kubernetes network proxy runs on each node. This
|
||||
reflects services as defined in the Kubernetes API on each node and can do simple
|
||||
TCP, UDP, and SCTP stream forwarding or round robin TCP, UDP, and SCTP forwarding across a set of backends.
|
||||
@ -214,7 +221,7 @@ func newProxyServer(ctx context.Context, config *kubeproxyconfig.KubeProxyConfig
|
||||
}
|
||||
|
||||
s.Broadcaster = events.NewBroadcaster(&events.EventSinkImpl{Interface: s.Client.EventsV1()})
|
||||
s.Recorder = s.Broadcaster.NewRecorder(proxyconfigscheme.Scheme, "kube-proxy")
|
||||
s.Recorder = s.Broadcaster.NewRecorder(proxyconfigscheme.Scheme, kubeProxy)
|
||||
|
||||
s.NodeRef = &v1.ObjectReference{
|
||||
Kind: "Node",
|
||||
@ -443,7 +450,7 @@ func serveMetrics(ctx context.Context, bindAddress string, proxyMode kubeproxyco
|
||||
return
|
||||
}
|
||||
|
||||
proxyMux := mux.NewPathRecorderMux("kube-proxy")
|
||||
proxyMux := mux.NewPathRecorderMux(kubeProxy)
|
||||
healthz.InstallHandler(proxyMux)
|
||||
slis.SLIMetricsWithReset{}.Install(proxyMux)
|
||||
|
||||
@ -466,6 +473,10 @@ func serveMetrics(ctx context.Context, bindAddress string, proxyMode kubeproxyco
|
||||
flagz.Install(proxyMux, "kube-proxy", flagzReader)
|
||||
}
|
||||
|
||||
if utilfeature.DefaultFeatureGate.Enabled(zpagesfeatures.ComponentStatusz) {
|
||||
statusz.Install(proxyMux, kubeProxy, statusz.NewRegistry())
|
||||
}
|
||||
|
||||
fn := func() {
|
||||
var err error
|
||||
defer func() {
|
||||
|
Loading…
Reference in New Issue
Block a user