openshift-telco / telco-gitops

18 stars 15 forks source link

Include preSync hooks checking if the operator is deployed before configuring it #20

Open alosadagrande opened 3 years ago

alosadagrande commented 3 years ago

Hi folks,

This is another change that we think might be good to be included in the official repo. The point here is that before applying PAO or SR-IOV or any other operator configuration we want to check that the operator is actually deployed.

In order to do that we included a preSync hook in each operator config folder. An example of PAO configuration (profile + presync) can be found here. See that first we are just checking that the operator is Running and when it is running the Sync phase can start, basically applying the performance profile. The same has been configured for SRIOV here

In order to do that we need to configure a couple of things in the remote cluster so we can execute "oc commands" locally. Basically, we need to apply the clusterRole and clusterRolebindings that you already created in the management cluster. We included these permissions in the base configuration of the remote clusters, see a working example here . In that case, we are just calling the same ClusterRoles and ClusterRoleBindings used for the management cluster (notice that oc client must be in 4.8.x version otherwise HTTPS files won't be applied). Another approach is just to leave both files in the base remote cluster folder as shown here

So the point is that these permissions will allow us to run pre and post-sync hooks in remote clusters as well. Also, it will introduce some logic when it comes to applying configuration since it won't apply if the operator is still installing. I think this should be included with all the operators that require post configuration.

Let me know your thoughts and how I can contribute.

williamcaban commented 3 years ago

Since it will be tricky to maintain a hook per operator, helm, manifests, etc, what do you think about a collection of hooks that can be invoked with parameters from git generator files so it an inject the sync wave and hook on invocation of each one?

williamcaban commented 3 years ago

@nsatsia to bring the hooks he created for this purpose for various operators