Skip to content
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

Should create operator CRs be done in operators #2304

Closed
clyang82 opened this issue Dec 9, 2019 · 9 comments
Closed

Should create operator CRs be done in operators #2304

clyang82 opened this issue Dec 9, 2019 · 9 comments
Assignees
Labels
triage/support Indicates an issue that is a support question.

Comments

@clyang82
Copy link
Contributor

clyang82 commented Dec 9, 2019

Bug Report

What did you do?

I saw there are some operators are creating CR in operator while others do not create CR.

Create CR in operator

Not create CR in operator

What did you expect to see?
My Question is what is best practice to develop a new operator - create CR in operator or do not create CR in operator? benefit? Thanks.

@clyang82
Copy link
Contributor Author

clyang82 commented Dec 9, 2019

FYI @gyliu513

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Dec 9, 2019

Hi @clyang82,

I'd recommend follow up the Getting Started and check the blog post.

IHMO keep the CR's in the project make easier understand what is expected and as provide features to install/uninstall the operator as standalone via makefile targets. You can see it in the Memcached example. See here the example.

Note that its default values are also used to generate the alm-example CSV annotation when the command operator-sdk olm-catalog gen-csv is executed. See here an example.

Hi @joelanford @shawn-hurley, would like to provide any additional information here?

@camilamacedo86 camilamacedo86 added the triage/support Indicates an issue that is a support question. label Dec 9, 2019
@camilamacedo86 camilamacedo86 self-assigned this Dec 9, 2019
@clyang82
Copy link
Contributor Author

clyang82 commented Dec 10, 2019

@camilamacedo86 Thanks for your strongly support always. I will use OLM to manage the operators. Just want to know what is best practice for operator developing. What should be done in operator? Thanks for sharing your points. Should the operator create the corresponding CR in reconcile method or leave it to the end user ?

@joelanford
Copy link
Member

@clyang82 There are a few scenarios to consider.

  1. An operator creates a CR for a CRD that it does not own.

    This scenario is fairly common. For example, operators created with Operator SDK will create a prometheus ServiceMonitor CR when deployed in a cluster with the prometheus operator.

  2. An operator creates a CR for a CRD that it does own.

    This scenario is less common. There are a couple of uses cases here:

    • When the operator is managing a singleton instance of an operand, it will create the CR for that singleton
    • If the operator or its operands need some CR-based configuration that is not already present, the operator might create the config CR with some default values.

The majority of operators do not need to create a CR for a CRD that they own. If you are able to expand on your use case, we might be able to give you more specific guidance.

@clyang82
Copy link
Contributor Author

@joelanford Thanks for your great sharing. My case is that I want to create a meta operator to manage some operators. My current think is meta operator creates each CR for each managed operator. That is align with your first point. How to create each CR for each managed operator? It needs some inputs from the user. That is CR-based configuration from the user's input. Any comments?

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Dec 11, 2019

So @clyang82,

It shows related to the "umbrella operator" ML.

Have you been to discuss this topic there or this idea came up when you saw this discussion? Why you need a "meta operator"? Why the umbrella operator needs creates the CR for the others? Why you cannot have an Operator A, B and C where for example B and C are independent and work as standalone but they are required for Operator A works? Could not B and C lookup for the CR/CRDs of A in order to gather the information to create its resources and if not found then use the data in its own?

@clyang82
Copy link
Contributor Author

Thanks @camilamacedo86 for your comments.

I need to have an operator for operators. it can be called umbrella opertor or meta operator. the operator is used to manage other operators. You should know the uber operator. I think I have the same case likes the uber has. I do not want to ask the client to create all dependent operators one by one. that is not user friendly. That is why I want to have a meta operator to help create all dependent operators based on the configuration.

The question is still under discussion about Why the umbrella operator needs creates the CR for the others? One of the case in my mind is if my meta operator depends on the third-party operator which do not have ability to create CR by itself (That is less common). How and when to create the CR for this operator.

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Dec 12, 2019

Hi @clyang82,

I do not want to ask the client to create all dependent operators one by one

You can use OLM Dependency Resolution and also you can indeed create another Operator which will manage all without OLM as well and can be distributed with too.

The question is still under discussion about Why the umbrella operator needs creates the CR for the others? One of the case in my mind is if my meta operator depends on the third-party operator which do not have ability to create CR by itself (That is less common). How and when to create the CR for this operator.

Are you asking about some specific project/operator? If yes, in this case, we are not able to speak and/or discuss the reasons and motivations which lead them to do their implementations. In this scenario, I'd suggest you contact who is responsible for them.

Regards the framework possibilities

Note that when we create an Operator and it's CR/CRD's via the command operator-sdk add api, as described in the blog post, we are creating our own Resources API.

In this way, you are able to use this API in any other project as any third-party resource. So, you can manage resources, for example, from Operator A in Operator B or C. See here in the user guide how to use third-party API's.

NOTES

  • You can have all CR's with the default expected values/attributes of the Resources/Objects defined in each one of them in the projects
  • You can make, for example, the Operator B and C check if the A's CRD's are in the cluster and have its CR's applied and then, use specific values from it(0 to Many) or use their own CR's to create the secondary resources.

Important: If you use any third-party API then, before adding the schema and use them is recommended to use the DiscoveryClient to check if the Resource exists in the cluster

So, all will be up to the business requirements and how you would like to make it work.

My personal POV

I as dev personally, I'd choose to you follow up the Getting Started and solve all programmatically and dynamically instead of using the templates approach, and I'd prefer to keep the CR's in each project as well in order to make easier provide as Makefile targets to do a default install/uninstall and run them as standalone and to understand what is required/expected as etc.

I think that have one operator which will manage others may make easier work with them locally since is not required have the OLM installed to check all integrated, however, if the go/need is just and only to install many operators locally and not manage them programmatically then it could be solved by using makefile targets, shell scripts to apply all operator's resources and etc. I'd just create an Operator X which will manage others if it could attend business requirements where has its own API and logic to manage the resources would make sense and bring advantages.

However, if your motivation to have the "umbrella operator" is just to install them and not to manage them, so it could be solved by using a shell script, makefile, etc, and/or by using OLM Dependency Resolution as described above. But, I also I'd suggest before you take the decision check with the OLM maintainers and/or by doing a POC how its UI and workflow will be deeply in this scenario by using OLM Dependency Resolution and if it will attend your expectations as well.

I think that we quite covered the question raised in this issue and indeed get out of its scope :-). So, please, let me know if we could close this one and then, if you have other questions, I'd recommend we keep one subject/closed questions per issue to allow us to address better your concerns.

@clyang82
Copy link
Contributor Author

Hi @camilamacedo86, thanks for your elaboration and sharing your ideas and suggestions. That is enough for me to build an operator. Let me close this issue. Again, thanks for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/support Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests

3 participants