Skip to content

[DNM]consume ldap bindpwd and external edb certs SPCs #1051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bundle/manifests/ibm-iam-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,14 @@ spec:
- patch
- update
- watch
- apiGroups:
- secrets-store.csi.x-k8s.io
resources:
- secretproviderclasses
verbs:
- get
- list
- watch
serviceAccountName: ibm-iam-operator
strategy: deployment
installModes:
Expand Down
3 changes: 3 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
sscsidriverv1 "sigs.k8s.io/secrets-store-csi-driver/apis/v1"

oidcsecurityv1 "github.com/IBM/ibm-iam-operator/api/oidc.security/v1"
operatorv1alpha1 "github.com/IBM/ibm-iam-operator/api/operator/v1alpha1"
Expand All @@ -60,6 +61,8 @@ func init() {
utilruntime.Must(oidcsecurityv1.AddToScheme(scheme))
utilruntime.Must(certmgrv1.AddToScheme(scheme))
utilruntime.Must(zenv1.AddToScheme(scheme))
utilruntime.Must(sscsidriverv1.AddToScheme(scheme))

// Add the Route scheme if found on the cluster
cfg, err := config.GetConfig()
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ rules:
- patch
- update
- watch
- apiGroups:
- secrets-store.csi.x-k8s.io
resources:
- secretproviderclasses
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
k8s.io/client-go v0.28.1
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
sigs.k8s.io/controller-runtime v0.16.1
sigs.k8s.io/secrets-store-csi-driver v1.5.1
)

require (
Expand All @@ -34,7 +35,7 @@ require (
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand Down Expand Up @@ -269,6 +268,8 @@ sigs.k8s.io/controller-runtime v0.16.1 h1:+15lzrmHsE0s2kNl0Dl8cTchI5Cs8qofo5PGcP
sigs.k8s.io/controller-runtime v0.16.1/go.mod h1:vpMu3LpI5sYWtujJOa2uPK61nB5rbwlN7BAB8aSLvGU=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/secrets-store-csi-driver v1.5.1 h1:agXZcHDgteybHKtnmwH9uR0bBwrULfNsl4q6XCQx3YI=
sigs.k8s.io/secrets-store-csi-driver v1.5.1/go.mod h1:drcHdJiveR7a20tuOJwGylJxkwaK4GhVibpT4llZN7A=
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk=
sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
Expand Down
8 changes: 8 additions & 0 deletions helm/templates/00-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ rules:
- patch
- update
- watch
- apiGroups:
- secrets-store.csi.x-k8s.io
resources:
- secretproviderclasses
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down
9 changes: 9 additions & 0 deletions internal/controller/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ const MongoStatefulsetName string = "icp-mongodb"
// Name of CommonService created by IM Operator to provision EDB share
const DatastoreEDBCSName string = "im-common-service"

// Name of SecretProvoderClass created by Paks that contains ldap bindpassword
const IMLdapBindCredSpc string = "im-ldap-bind-creds-spc"

// Name of SecretProvoderClass created by Paks that contains external edb certs
const IMExtEDBSecretSpc string = "im-external-edb-creds-spc"

// Name of volume that holds ldap bindpassword spc
const IMLdapBindPwdVolume string = "ldap-bind-cred-vol"

type DeploymentName string

// The current names of Deployments managed by this Operator
Expand Down
6 changes: 6 additions & 0 deletions internal/controller/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
sscsidriverv1 "sigs.k8s.io/secrets-store-csi-driver/apis/v1"

operatorv1alpha1 "github.com/IBM/ibm-iam-operator/api/operator/v1alpha1"
zenv1 "github.com/IBM/ibm-iam-operator/internal/api/zen.cpd.ibm.com/v1"
Expand Down Expand Up @@ -190,6 +191,11 @@ func ClusterHasZenExtensionGroupVersion(dc *discovery.DiscoveryClient) (found bo
return
}

func ClusterHasCSIGroupVersion(dc *discovery.DiscoveryClient) (found bool) {
found, _ = clusterHasGroupVersion(dc, sscsidriverv1.SchemeGroupVersion)
return
}

func ClusterHasOperandRequestAPIResource(dc *discovery.DiscoveryClient) (found bool) {
found, _ = clusterHasAPIResource(dc, operatorv1alpha1.GroupVersion, "operandrequests")
return
Expand Down
25 changes: 24 additions & 1 deletion internal/controller/operator/authentication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
handler "sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
sscsidriverv1 "sigs.k8s.io/secrets-store-csi-driver/apis/v1"

operatorv1alpha1 "github.com/IBM/ibm-iam-operator/api/operator/v1alpha1"
"github.com/opdev/subreconciler"
Expand Down Expand Up @@ -385,7 +386,8 @@ func (r *AuthenticationReconciler) SetupWithManager(mgr ctrl.Manager) error {
Watches(&corev1.Service{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &operatorv1alpha1.Authentication{}, handler.OnlyControllerOwner())).
Watches(&netv1.Ingress{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &operatorv1alpha1.Authentication{}, handler.OnlyControllerOwner())).
Watches(&appsv1.Deployment{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &operatorv1alpha1.Authentication{}, handler.OnlyControllerOwner())).
Watches(&autoscalingv2.HorizontalPodAutoscaler{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &operatorv1alpha1.Authentication{}, handler.OnlyControllerOwner()))
Watches(&autoscalingv2.HorizontalPodAutoscaler{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &operatorv1alpha1.Authentication{}, handler.OnlyControllerOwner())).
Watches(&sscsidriverv1.SecretProviderClass{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &operatorv1alpha1.Authentication{}, handler.OnlyControllerOwner()))

//Add routes
if ctrlcommon.ClusterHasOpenShiftConfigGroupVerison(&r.DiscoveryClient) {
Expand Down Expand Up @@ -443,6 +445,27 @@ func (r *AuthenticationReconciler) SetupWithManager(mgr ctrl.Manager) error {
}
}), builder.WithPredicates(predicate.Or(globalCMPred, productCMPred)),
)
ldapSPCPred := predicate.NewPredicateFuncs(func(o client.Object) bool {
return o.GetName() == ctrlcommon.IMLdapBindCredSpc
})
edbSPCPred := predicate.NewPredicateFuncs(func(o client.Object) bool {
return o.GetName() == ctrlcommon.IMExtEDBSecretSpc
})

authCtrl.Watches(&sscsidriverv1.SecretProviderClass{},
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) (requests []reconcile.Request) {
authCR, _ := ctrlcommon.GetAuthentication(ctx, r.Client)
if authCR == nil {
return
}
return []reconcile.Request{
{NamespacedName: types.NamespacedName{
Name: authCR.Name,
Namespace: authCR.Namespace,
}},
}
}), builder.WithPredicates(predicate.Or(ldapSPCPred, edbSPCPred)),
)
bootstrappedPred := predicate.NewPredicateFuncs(func(o client.Object) bool {
return o.GetLabels()[ctrlcommon.ManagerVersionLabel] == version.Version
})
Expand Down
Loading