How to synchronize Custom resource when its specification is updated

3/19/2021

In a Kubernetes operator based on operator-sdk, do you know how to write code to synchronize CR resource when CR specification is updated with kubectl apply? Could you please provide some code samples?

-- Fabrice Jammes
kubernetes
kubernetes-operator
operator-sdk

2 Answers

3/22/2021

Implementing it a go-lang based operator is pretty complex, and I would recommand studying the kubebuilder documentation and example in order to achieve that: https://book.kubebuilder.io/cronjob-tutorial/controller-implementation.html#implementing-a-controller

-- Fabrice Jammes
Source: StackOverflow

3/19/2021

It is mostly up to how you deploy things. The default skeleton gives you a Kustomize-based deployment structure so kustomize build config/default | kubectl apply -f. This is also wrapped up for you behind make deploy. There is also make install for just installing the generated CRD files.

-- coderanger
Source: StackOverflow