|
5 | 5 | "context"
|
6 | 6 | "encoding/json"
|
7 | 7 | "fmt"
|
| 8 | + "reflect" |
8 | 9 | "sort"
|
9 | 10 | "strconv"
|
10 | 11 | "strings"
|
@@ -237,6 +238,11 @@ func createTargetConfig(ctx context.Context, c TargetConfigController, recorder
|
237 | 238 | errors = append(errors, fmt.Errorf("%q: %v", "configmap/trusted-ca-bundle", err))
|
238 | 239 | }
|
239 | 240 |
|
| 241 | + err = ensureKubeAPIServerExtensionAuthenticationCA(ctx, c.kubeClient.CoreV1(), recorder) |
| 242 | + if err != nil { |
| 243 | + errors = append(errors, fmt.Errorf("%q: %v", "configmap/extension-apiserver-authentication", err)) |
| 244 | + } |
| 245 | + |
240 | 246 | err = ensureLocalhostRecoverySAToken(ctx, c.kubeClient.CoreV1(), recorder)
|
241 | 247 | if err != nil {
|
242 | 248 | errors = append(errors, fmt.Errorf("%q: %v", "serviceaccount/localhost-recovery-client", err))
|
@@ -507,6 +513,25 @@ func ensureKubeAPIServerTrustedCA(ctx context.Context, client coreclientv1.CoreV
|
507 | 513 | return err
|
508 | 514 | }
|
509 | 515 |
|
| 516 | +func ensureKubeAPIServerExtensionAuthenticationCA(ctx context.Context, client coreclientv1.CoreV1Interface, recorder events.Recorder) error { |
| 517 | + required := resourceread.ReadConfigMapV1OrDie(bindata.MustAsset("assets/kube-apiserver/extension-apiserver-authentication-cm.yaml")) |
| 518 | + cmCLient := client.ConfigMaps("kube-system") |
| 519 | + |
| 520 | + cm, err := cmCLient.Get(ctx, "extension-apiserver-authentication", metav1.GetOptions{}) |
| 521 | + if err != nil { |
| 522 | + return err |
| 523 | + } |
| 524 | + |
| 525 | + // update if annotations modified by the user |
| 526 | + if !reflect.DeepEqual(cm.Annotations, required.Annotations) { |
| 527 | + cm.Annotations = required.Annotations |
| 528 | + _, err = cmCLient.Update(ctx, cm, metav1.UpdateOptions{}) |
| 529 | + return err |
| 530 | + } |
| 531 | + |
| 532 | + return err |
| 533 | +} |
| 534 | + |
510 | 535 | func ensureLocalhostRecoverySAToken(ctx context.Context, client coreclientv1.CoreV1Interface, recorder events.Recorder) error {
|
511 | 536 | requiredSA := resourceread.ReadServiceAccountV1OrDie(bindata.MustAsset("assets/kube-apiserver/localhost-recovery-sa.yaml"))
|
512 | 537 | requiredToken := resourceread.ReadSecretV1OrDie(bindata.MustAsset("assets/kube-apiserver/localhost-recovery-token.yaml"))
|
|
0 commit comments