Merge pull request #3118 from yuswift/feature/lightweight-membercluster-installation
Feat: support runnig ks-controller-manager without ldap option
This commit is contained in:
@@ -118,9 +118,8 @@ func run(s *options.KubeSphereControllerManagerOptions, stopCh <-chan struct{})
|
||||
}
|
||||
|
||||
var ldapClient ldapclient.Interface
|
||||
if s.LdapOptions == nil || len(s.LdapOptions.Host) == 0 {
|
||||
return fmt.Errorf("ldap service address MUST not be empty")
|
||||
} else {
|
||||
// when there is no ldapOption, we set ldapClient as nil, which means we don't need to sync user info into ldap.
|
||||
if s.LdapOptions != nil && len(s.LdapOptions.Host) != 0 {
|
||||
if s.LdapOptions.Host == ldapclient.FAKE_HOST { // for debug only
|
||||
ldapClient = ldapclient.NewSimpleLdap()
|
||||
} else {
|
||||
@@ -129,6 +128,8 @@ func run(s *options.KubeSphereControllerManagerOptions, stopCh <-chan struct{})
|
||||
return fmt.Errorf("failed to connect to ldap service, please check ldap status, error: %v", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
klog.Info("Kubesphere-controller-manager starts without ldap option, it will not sync user into ldap")
|
||||
}
|
||||
|
||||
var openpitrixClient openpitrix.Client
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"k8s.io/apiserver/pkg/authentication/authenticator"
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
"k8s.io/klog"
|
||||
|
||||
iamv1alpha2listers "kubesphere.io/kubesphere/pkg/client/listers/iam/v1alpha2"
|
||||
"kubesphere.io/kubesphere/pkg/models/iam/im"
|
||||
)
|
||||
|
||||
@@ -287,9 +287,12 @@ func (c *Controller) reconcile(key string) error {
|
||||
if sliceutil.HasString(user.ObjectMeta.Finalizers, finalizer) {
|
||||
|
||||
klog.V(4).Infof("delete user %s", key)
|
||||
if err = c.ldapClient.Delete(key); err != nil && err != ldapclient.ErrUserNotExists {
|
||||
klog.Error(err)
|
||||
return err
|
||||
// we do not need to delete the user from ldapServer when ldapClient is nil
|
||||
if c.ldapClient != nil {
|
||||
if err = c.ldapClient.Delete(key); err != nil && err != ldapclient.ErrUserNotExists {
|
||||
klog.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err = c.deleteRoleBindings(user); err != nil {
|
||||
@@ -329,9 +332,12 @@ func (c *Controller) reconcile(key string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err = c.ldapSync(user); err != nil {
|
||||
klog.Error(err)
|
||||
return err
|
||||
// we do not need to sync ldap info when ldapClient is nil
|
||||
if c.ldapClient != nil {
|
||||
if err = c.ldapSync(user); err != nil {
|
||||
klog.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if user, err = c.ensurePasswordIsEncrypted(user); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user