@@ -62,8 +62,8 @@ type InfrastructureConfig struct {
6262
6363var (
6464 // The cluster-policy-controller will automatically approve the
65- // CertificateSigningRequest resources issued for the prometheus-k8s
66- // service account .
65+ // CertificateSigningRequest resources issued for the prometheus and metrics-server
66+ // service accounts .
6767 // See https://github.com/openshift/cluster-policy-controller/blob/cc787e1b1e177696817b66689a03471914083a67/pkg/cmd/controller/csr.go#L21-L46.
6868 csrOption = csr.CSROption {
6969 ObjectMeta : metav1.ObjectMeta {
7676 SignerName : certapiv1 .KubeAPIServerClientSignerName ,
7777 }
7878
79+ csrMetricsServerOption = csr.CSROption {
80+ ObjectMeta : metav1.ObjectMeta {
81+ GenerateName : "system:openshift:openshift-monitoring-" ,
82+ Labels : map [string ]string {
83+ "metrics.openshift.io/csr.subject" : "metrics-server" ,
84+ },
85+ },
86+ Subject : & pkix.Name {CommonName : "system:serviceaccount:openshift-monitoring:metrics-server" },
87+ SignerName : certapiv1 .KubeAPIServerClientSignerName ,
88+ }
89+
7990 // To identify "invalid UWM config only" failures
8091 ErrUserWorkloadInvalidConfiguration = fmt .Errorf ("invalid UWM configuration" )
8192)
@@ -154,6 +165,7 @@ const (
154165 alertmanagerCABundleConfigMap = "openshift-monitoring/alertmanager-trusted-ca-bundle"
155166 grpcTLS = "openshift-monitoring/grpc-tls"
156167 metricsClientCerts = "openshift-monitoring/metrics-client-certs"
168+ metricsServerClientCerts = "openshift-monitoring/metrics-server-client-certs"
157169 federateClientCerts = "openshift-monitoring/federate-client-certs"
158170
159171 // Canonical name of the cluster-wide infrastructure resource.
@@ -527,9 +539,35 @@ func New(
527539 return nil , fmt .Errorf ("failed to create federate certificate controller: %w" , err )
528540 }
529541
530- o .controllersToRunFunc = append (o .controllersToRunFunc , csrFederateController .Run , csrController .Run )
542+ csrMetricsServerController , err := csr .NewClientCertificateController (
543+ csr.ClientCertOption {
544+ SecretNamespace : "openshift-monitoring" ,
545+ SecretName : "metrics-server-client-certs" ,
546+ AdditionalAnnotations : certrotation.AdditionalAnnotations {
547+ JiraComponent : "Monitoring" ,
548+ },
549+ },
550+ csrMetricsServerOption ,
551+ kubeInformersOperatorNS .Certificates ().V1 ().CertificateSigningRequests (),
552+ o .client .KubernetesInterface ().CertificatesV1 ().CertificateSigningRequests (),
553+ kubeInformersOperatorNS .Core ().V1 ().Secrets (),
554+ o .client .KubernetesInterface ().CoreV1 (),
555+ o .client .EventRecorder (),
556+ "OpenShiftMonitoringMetricsServerClientCertRequester" ,
557+ )
558+
559+ if err != nil {
560+ return nil , fmt .Errorf ("failed to create client certificate controller: %w" , err )
561+ }
531562
532- o .controllersToRunFunc = append (o .controllersToRunFunc , o .ruleController .Run , o .relabelController .Run )
563+ o .controllersToRunFunc = append (
564+ o .controllersToRunFunc ,
565+ csrFederateController .Run ,
566+ csrController .Run ,
567+ csrMetricsServerController .Run ,
568+ o .ruleController .Run ,
569+ o .relabelController .Run ,
570+ )
533571
534572 return o , nil
535573}
@@ -663,6 +701,7 @@ func (o *Operator) handleEvent(obj interface{}) {
663701 case cmoConfigMap :
664702 case apiAuthenticationConfigMap :
665703 case kubeletServingCAConfigMap :
704+ case metricsServerClientCerts :
666705 case telemeterCABundleConfigMap :
667706 case alertmanagerCABundleConfigMap :
668707 case grpcTLS :
0 commit comments