@@ -25,7 +25,7 @@ import (
25
25
"sort"
26
26
27
27
certificates "k8s.io/api/certificates/v1beta1"
28
- "k8s.io/api/core/v1"
28
+ v1 "k8s.io/api/core/v1"
29
29
"k8s.io/apimachinery/pkg/types"
30
30
clientset "k8s.io/client-go/kubernetes"
31
31
certificatesclient "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
@@ -52,17 +52,38 @@ func NewKubeletServerCertificateManager(kubeClient clientset.Interface, kubeCfg
52
52
if err != nil {
53
53
return nil , fmt .Errorf ("failed to initialize server certificate store: %v" , err )
54
54
}
55
- var certificateExpiration = compbasemetrics .NewGauge (
55
+ certificateExpiration : = compbasemetrics .NewGauge (
56
56
& compbasemetrics.GaugeOpts {
57
- Namespace : metrics .KubeletSubsystem ,
58
- Subsystem : "certificate_manager" ,
59
- Name : "server_expiration_seconds" ,
57
+ Subsystem : metrics .KubeletSubsystem ,
58
+ Name : "certificate_manager_server_expiration_seconds" ,
60
59
Help : "Gauge of the lifetime of a certificate. The value is the date the certificate will expire in seconds since January 1, 1970 UTC." ,
61
60
StabilityLevel : compbasemetrics .ALPHA ,
62
61
},
63
62
)
64
63
legacyregistry .MustRegister (certificateExpiration )
65
64
65
+ certificateRotationAge := compbasemetrics .NewHistogram (
66
+ & compbasemetrics.HistogramOpts {
67
+ Subsystem : metrics .KubeletSubsystem ,
68
+ Name : "certificate_manager_server_rotation_seconds" ,
69
+ Help : "Histogram of the number of seconds the previous certificate lived before being rotated." ,
70
+ Buckets : []float64 {
71
+ 60 , // 1 minute
72
+ 3600 , // 1 hour
73
+ 14400 , // 4 hours
74
+ 86400 , // 1 day
75
+ 604800 , // 1 week
76
+ 2592000 , // 1 month
77
+ 7776000 , // 3 months
78
+ 15552000 , // 6 months
79
+ 31104000 , // 1 year
80
+ 124416000 , // 4 years
81
+ },
82
+ StabilityLevel : compbasemetrics .ALPHA ,
83
+ },
84
+ )
85
+ legacyregistry .MustRegister (certificateRotationAge )
86
+
66
87
getTemplate := func () * x509.CertificateRequest {
67
88
hostnames , ips := addressesToHostnamesAndIPs (getAddresses ())
68
89
// don't return a template if we have no addresses to request for
@@ -100,6 +121,7 @@ func NewKubeletServerCertificateManager(kubeClient clientset.Interface, kubeCfg
100
121
},
101
122
CertificateStore : certificateStore ,
102
123
CertificateExpiration : certificateExpiration ,
124
+ CertificateRotation : certificateRotationAge ,
103
125
})
104
126
if err != nil {
105
127
return nil , fmt .Errorf ("failed to initialize server certificate manager: %v" , err )
0 commit comments