Skip to content

Commit

Permalink
bugfix: set labels to kubeconfig and cert secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshbaliga committed Dec 11, 2024
1 parent fa41bde commit bdf3abb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/certs/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ import (
"k8s.io/klog/v2"
)

const (
CertSecretLabelAppKey = "app"
CertSecretLabelAppValue = "vcluster"
CertSecretLabelReleaseKey = "release"
)

func EnsureCerts(
ctx context.Context,
serviceCIDR string,
Expand Down Expand Up @@ -131,6 +137,10 @@ func EnsureCerts(
Name: secretName,
Namespace: currentNamespace,
OwnerReferences: ownerRef,
Labels: map[string]string{
CertSecretLabelAppKey: CertSecretLabelAppValue,
CertSecretLabelReleaseKey: currentNamespace,
},
},
Data: map[string][]byte{},
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/util/kubeconfig/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const (
CertificateSecretKey = "client-certificate"
CertificateKeySecretKey = "client-key"
TokenSecretKey = "token"
KubeConfigSecretLabelAppKey = "app"
KubeConfigSecretLabelAppValue = "vcluster"
KubeConfigSecretLabelReleaseKey = "release"
)

func WriteKubeConfig(ctx context.Context, currentNamespaceClient client.Client, secretName, secretNamespace string, config *clientcmdapi.Config, isRemote bool) error {
Expand Down Expand Up @@ -70,6 +73,10 @@ func WriteKubeConfig(ctx context.Context, currentNamespaceClient client.Client,
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Namespace: secretNamespace,
Labels: map[string]string{
KubeConfigSecretLabelAppKey: KubeConfigSecretLabelAppValue,
KubeConfigSecretLabelReleaseKey: secretNamespace,
},
},
}
result, err := controllerutil.CreateOrPatch(ctx, currentNamespaceClient, kubeConfigSecret, func() error {
Expand Down

0 comments on commit bdf3abb

Please sign in to comment.