Closed varshaprasad96 closed 3 years ago
Should this doc be in openshift/enhancements instead?
@anik120 Since this is going to be a part of operator-framework/operator-lib
, I had created a PR here. I'm fine either way though.
Is HA vs. non-HA relevant to operators running on vanilla k8s, and in general any k8s distribution?
* No: this proposal should be moved to https://github.com/openshift/enhancements and the proposed library should live in https://github.com/openshift/library-go * Yes: the proposed library can go in operator-lib but needs to expose a generic API that returns 1. If the cluster type supports detecting HA vs. non-HA 2. If the operator can run in HA mode.
To me, it makes sense to start small and contribute to library-go first with OpenShift-specific HA detection. If requests are made for a generic solution, then revisit an operator-lib library.
So after some investigation I've come to agree with @estroz on this matter. I don't think this needs to go into operator-lib at the moment. In order to get access to the HA information it is actually trivial and I don't see the need for a wrapper library at the moment. It's just a matter of registering the scheme then going a crClient.Get(context.Background(), nn, infraConfig)
Here is an example:
func GetInfraViaControllerRuntime(cc *restclient.Config) error {
rm, err := apiutil.NewDynamicRESTMapper(cc)
if err != nil {
return err
}
crClient, err := crclient.New(cc, crclient.Options{
Scheme: scheme,
Mapper: rm,
})
if err != nil {
return err
}
// Simple query
nn := types.NamespacedName{
Name: "cluster",
}
infraConfig := &configv1.Infrastructure{}
err = crClient.Get(context.Background(), nn, infraConfig)
if err != nil {
return err
}
fmt.Printf("using crclient: %v\n", infraConfig.Status.ControlPlaneTopology)
fmt.Printf("using crclient: %v\n", infraConfig.Status.InfrastructureTopology)
return nil
}
Closing this enhancement for operator-lib.
Enhancement on adding library to provide high availability expectations of openshift clusters to users.
Signed-off-by: varshaprasad96 varshaprasad96@gmail.com