use ownerReference control the lifecycle of user's kubeconfig and kubectl pod

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2020-05-23 21:26:28 +08:00
parent 8f93266ec0
commit 57acaeba41
7 changed files with 51 additions and 57 deletions

View File

@@ -221,7 +221,7 @@ func (c *Controller) reconcile(key string) error {
}
// csr create by kubesphere auto approve
if username := csr.Annotations[constants.UsernameAnnotationKey]; username != "" {
if username := csr.Labels[constants.UsernameLabelKey]; username != "" {
err = c.Approve(csr)
if err != nil {
klog.Error(err)
@@ -280,7 +280,7 @@ func (c *Controller) Approve(csr *certificatesv1beta1.CertificateSigningRequest)
}
func (c *Controller) UpdateKubeconfig(csr *certificatesv1beta1.CertificateSigningRequest) error {
username := csr.Annotations[constants.UsernameAnnotationKey]
username := csr.Labels[constants.UsernameLabelKey]
err := c.kubeconfigOperator.UpdateKubeconfig(username, csr.Status.Certificate)