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

Update mechanism for objects #537

Closed
ghost opened this issue Sep 26, 2018 · 4 comments
Closed

Update mechanism for objects #537

ghost opened this issue Sep 26, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Sep 26, 2018

My operator creates over a dozen of objects of all possible kinds: services, routes, pvcs, deployments, role bindings, service accounts.

If a new version of an operator brings new image tags, envs to deployments or any other changes in objects I expect existing objects to be updated.

Currently, I need to run sdk.Update() on all of them to make sure that if the version of my operator introduces changes to the objects they will be applied.

Is there perhaps a better way?

@shawn-hurley
Copy link
Member

I am sorry @eivantsov I might not be following. Let me re-state what I am hearing and then answer in case I don't understand.

I think you're asking that if an operator image has differences than the previous version that you currently need to update the CR during the reconciliation loop and your wondering if there is a better way?

I don't see any mechanism besides your operator to make decisions on what has changed and what should be updated. @hasbro17 can you double check this statement?

If instead we are discussing versioning the CRD, I think that this is the issue that you may be interested in following.
kubernetes/enhancements#598

@ghost
Copy link
Author

ghost commented Oct 4, 2018

@shawn-hurley yes, you got it right. In fact, in my case, the operator should always check for updates, without any checks, like if the image changed or anything in pod spec.

So, using sdk.Update() is the right way to go in the reconcile process? I create objects unless they exist and then update them. If they are identical, nothing happens, if there are changes objects are recreated.

@shawn-hurley
Copy link
Member

I believe that it might be worth checking only the fields that you want to check to determine if they are the same and allow Kube to manage the other stuff. For example, there are some defaults that you probably want but don't want to add to your pod definition in the code. You might also be able to use patch instead of update, but what your doing at the moment seems to be correct to me.

Another thing that you could do, is using this function from the controller runtime. Of course, this is after the refactor to use controller runtime.

I am going to close this, please feel free to re-open if I didn't answer the question completely.

@ghost
Copy link
Author

ghost commented Oct 8, 2018

@shawn-hurley thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant