mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
Merge pull request #82279 from deads2k/which-cert
add identification for particular certificate controllers
This commit is contained in:
commit
1146e0c4ad
@ -45,6 +45,7 @@ func startCSRSigningController(ctx ControllerContext) (http.Handler, bool, error
|
|||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
}
|
}
|
||||||
if ctx.ComponentConfig.CSRSigningController.ClusterSigningCertFile == "" || ctx.ComponentConfig.CSRSigningController.ClusterSigningKeyFile == "" {
|
if ctx.ComponentConfig.CSRSigningController.ClusterSigningCertFile == "" || ctx.ComponentConfig.CSRSigningController.ClusterSigningKeyFile == "" {
|
||||||
|
klog.V(2).Info("skipping CSR signer controller because no csr cert/key was specified")
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +80,7 @@ func startCSRSigningController(ctx ControllerContext) (http.Handler, bool, error
|
|||||||
// setting up the signing controller. This isn't
|
// setting up the signing controller. This isn't
|
||||||
// actually a problem since the signer is not a
|
// actually a problem since the signer is not a
|
||||||
// required controller.
|
// required controller.
|
||||||
|
klog.V(2).Info("skipping CSR signer controller because no csr cert/key was specified and the default files are missing")
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
default:
|
default:
|
||||||
// Note that '!filesExist && !usesDefaults' is obviously
|
// Note that '!filesExist && !usesDefaults' is obviously
|
||||||
|
@ -49,6 +49,7 @@ func NewCSRApprovingController(client clientset.Interface, csrInformer certifica
|
|||||||
recognizers: recognizers(),
|
recognizers: recognizers(),
|
||||||
}
|
}
|
||||||
return certificates.NewCertificateController(
|
return certificates.NewCertificateController(
|
||||||
|
"csrapproving",
|
||||||
client,
|
client,
|
||||||
csrInformer,
|
csrInformer,
|
||||||
approver.handle,
|
approver.handle,
|
||||||
|
@ -40,6 +40,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CertificateController struct {
|
type CertificateController struct {
|
||||||
|
// name is an identifier for this particular controller instance.
|
||||||
|
name string
|
||||||
|
|
||||||
kubeClient clientset.Interface
|
kubeClient clientset.Interface
|
||||||
|
|
||||||
csrLister certificateslisters.CertificateSigningRequestLister
|
csrLister certificateslisters.CertificateSigningRequestLister
|
||||||
@ -51,6 +54,7 @@ type CertificateController struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewCertificateController(
|
func NewCertificateController(
|
||||||
|
name string,
|
||||||
kubeClient clientset.Interface,
|
kubeClient clientset.Interface,
|
||||||
csrInformer certificatesinformers.CertificateSigningRequestInformer,
|
csrInformer certificatesinformers.CertificateSigningRequestInformer,
|
||||||
handler func(*certificates.CertificateSigningRequest) error,
|
handler func(*certificates.CertificateSigningRequest) error,
|
||||||
@ -61,6 +65,7 @@ func NewCertificateController(
|
|||||||
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
|
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
|
||||||
|
|
||||||
cc := &CertificateController{
|
cc := &CertificateController{
|
||||||
|
name: name,
|
||||||
kubeClient: kubeClient,
|
kubeClient: kubeClient,
|
||||||
queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewMaxOfRateLimiter(
|
queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewMaxOfRateLimiter(
|
||||||
workqueue.NewItemExponentialFailureRateLimiter(200*time.Millisecond, 1000*time.Second),
|
workqueue.NewItemExponentialFailureRateLimiter(200*time.Millisecond, 1000*time.Second),
|
||||||
@ -110,10 +115,10 @@ func (cc *CertificateController) Run(workers int, stopCh <-chan struct{}) {
|
|||||||
defer utilruntime.HandleCrash()
|
defer utilruntime.HandleCrash()
|
||||||
defer cc.queue.ShutDown()
|
defer cc.queue.ShutDown()
|
||||||
|
|
||||||
klog.Infof("Starting certificate controller")
|
klog.Infof("Starting certificate controller %q", cc.name)
|
||||||
defer klog.Infof("Shutting down certificate controller")
|
defer klog.Infof("Shutting down certificate controller %q", cc.name)
|
||||||
|
|
||||||
if !cache.WaitForNamedCacheSync("certificate", stopCh, cc.csrsSynced) {
|
if !cache.WaitForNamedCacheSync(fmt.Sprintf("certificate-%s", cc.name), stopCh, cc.csrsSynced) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ func TestCertificateController(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
controller := NewCertificateController(
|
controller := NewCertificateController(
|
||||||
|
"test",
|
||||||
client,
|
client,
|
||||||
informerFactory.Certificates().V1beta1().CertificateSigningRequests(),
|
informerFactory.Certificates().V1beta1().CertificateSigningRequests(),
|
||||||
handler,
|
handler,
|
||||||
|
@ -47,6 +47,7 @@ func NewCSRSigningController(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return certificates.NewCertificateController(
|
return certificates.NewCertificateController(
|
||||||
|
"csrsigning",
|
||||||
client,
|
client,
|
||||||
csrInformer,
|
csrInformer,
|
||||||
signer.handle,
|
signer.handle,
|
||||||
|
Loading…
Reference in New Issue
Block a user