Skip to content

Commit e3a54c1

Browse files
author
Vadim Rutkovsky
committed
nodekubeconfigcontroller: set ownership component for node kubeconfigs
Kubeconfigs are parsed as TLS artifact registry sources, so secrets containing kubeconfigs should have necessary annotations
1 parent 890ef6e commit e3a54c1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/operator/nodekubeconfigcontroller/nodekubeconfigcontroller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"time"
99

10+
"github.com/openshift/api/annotations"
1011
operatorv1 "github.com/openshift/api/operator/v1"
1112
configv1informers "github.com/openshift/client-go/config/informers/externalversions/config/v1"
1213
configv1listers "github.com/openshift/client-go/config/listers/config/v1"
@@ -147,6 +148,11 @@ func ensureNodeKubeconfigs(ctx context.Context, client coreclientv1.CoreV1Interf
147148
requiredSecret.StringData[k] = data
148149
}
149150

151+
if requiredSecret.Annotations == nil {
152+
requiredSecret.Annotations = map[string]string{}
153+
}
154+
requiredSecret.Annotations[annotations.OpenShiftComponent] = "kube-apiserver"
155+
150156
_, _, err = resourceapply.ApplySecret(ctx, client, recorder, requiredSecret)
151157
if err != nil {
152158
return err

pkg/operator/nodekubeconfigcontroller/nodekubeconfigcontroller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/google/go-cmp/cmp"
8+
"github.com/openshift/api/annotations"
89
configv1 "github.com/openshift/api/config/v1"
910
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
1011
"github.com/openshift/library-go/pkg/operator/events"
@@ -140,6 +141,9 @@ func TestEnsureNodeKubeconfigs(t *testing.T) {
140141
ObjectMeta: metav1.ObjectMeta{
141142
Namespace: "openshift-kube-apiserver",
142143
Name: "node-kubeconfigs",
144+
Annotations: map[string]string{
145+
annotations.OpenShiftComponent: "kube-apiserver",
146+
},
143147
},
144148
Data: map[string][]byte{
145149
"localhost.kubeconfig": []byte(`apiVersion: v1

0 commit comments

Comments
 (0)