@@ -237,6 +237,11 @@ func createTargetConfig(ctx context.Context, c TargetConfigController, recorder
237237 errors = append (errors , fmt .Errorf ("%q: %v" , "configmap/trusted-ca-bundle" , err ))
238238 }
239239
240+ err = ensureKubeAPIServerExtensionAuthenticationCA (ctx , c .kubeClient .CoreV1 (), recorder )
241+ if err != nil {
242+ errors = append (errors , fmt .Errorf ("%q: %v" , "configmap/extension-apiserver-authentication" , err ))
243+ }
244+
240245 err = ensureLocalhostRecoverySAToken (ctx , c .kubeClient .CoreV1 (), recorder )
241246 if err != nil {
242247 errors = append (errors , fmt .Errorf ("%q: %v" , "serviceaccount/localhost-recovery-client" , err ))
@@ -507,6 +512,42 @@ func ensureKubeAPIServerTrustedCA(ctx context.Context, client coreclientv1.CoreV
507512 return err
508513}
509514
515+ func ensureKubeAPIServerExtensionAuthenticationCA (ctx context.Context , client coreclientv1.CoreV1Interface , recorder events.Recorder ) error {
516+ required := resourceread .ReadConfigMapV1OrDie (bindata .MustAsset ("assets/kube-apiserver/extension-apiserver-authentication-cm.yaml" ))
517+ cmCLient := client .ConfigMaps ("kube-system" )
518+
519+ cm , err := cmCLient .Get (ctx , "extension-apiserver-authentication" , metav1.GetOptions {})
520+ if err != nil {
521+ // kube-apiserver creates this CM; don't degrade while waiting.
522+ if apierrors .IsNotFound (err ) {
523+ return nil
524+ }
525+ return err
526+ }
527+
528+ // Ensure that the config map is updated with the required annotations
529+ modified := false
530+ if cm .Annotations == nil {
531+ cm .Annotations = make (map [string ]string )
532+ modified = true
533+ }
534+
535+ for key , expected := range required .Annotations {
536+ if actual , ok := cm .Annotations [key ]; ! ok || actual != expected {
537+ cm .Annotations [key ] = expected
538+ modified = true
539+ }
540+ }
541+
542+ if modified {
543+ updatedCM , err := cmCLient .Update (ctx , cm , metav1.UpdateOptions {})
544+ resourcehelper .ReportUpdateEvent (recorder , updatedCM , err )
545+ return err
546+ }
547+
548+ return err
549+ }
550+
510551func ensureLocalhostRecoverySAToken (ctx context.Context , client coreclientv1.CoreV1Interface , recorder events.Recorder ) error {
511552 requiredSA := resourceread .ReadServiceAccountV1OrDie (bindata .MustAsset ("assets/kube-apiserver/localhost-recovery-sa.yaml" ))
512553 requiredToken := resourceread .ReadSecretV1OrDie (bindata .MustAsset ("assets/kube-apiserver/localhost-recovery-token.yaml" ))
0 commit comments