Common recommendations and suggestions

    Any recommendations or best practices suggested by the Kubernetes community, such as how to develop Operator pattern solutions or how to are good recommendations for those who are looking to build operator projects with operator-sdk. Also, see Operator Best Practices. However, here are some common recommendations.

    Common Recommendations

    When developing operators, it is essential for the controller’s reconciliation loop to be idempotent. By following the Operator pattern you will create which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster. Breaking this recommendation goes against the design principles of controller-runtime and may lead to unforeseen consequences such as resources becoming stuck and requiring manual intervention.

    Having many Kinds (such as CRDs) which are all managed by the same controller usually goes against the design proposed by . Furthermore this might hurt concepts such as encapsulation, the Single Responsibility Principle, and Cohesion. Damaging these concepts may cause unexpected side effects, and increase the difficulty of extending, reusing, or maintaining the operator.

    From best practices:

    • “An Operator shouldn’t deploy or manage other operators (such patterns are known as meta or super operators or include CRDs in its Operands). It’s the Operator Lifecycle Manager’s job to manage the deployment and lifecycle of operators. For further information check .”

    What does it mainly mean:

    • If you want to define that your Operator depends on APIs which are owned by another Operator or on another whole Operator itself you should use Operator Lifecycle Manager’s
    • If you want to reconcile core APIs (defined by Kubernetes) or External APIs (defined from other operators) you should not re-define the API as owned by your project. Therefore, you can create the controller in this cases by using the flag . (i.e. ). Attention: If you are using Golang-based language Operator then, you will need to update the markers and imports manually until it become officially supported by the tool. For further information check the issue #1999.

    WARNING: if you create CRD’s via the reconciliations or via the Operands then, OLM cannot handle CRDs migration and update, validation.

    • Provide the images and tags used by the operator solution via environment variables in the :
    • Manage your solutions using
    • Use finalizers when/if required
    • Ensure that you checked the and understand the Project Layout before starting to do your customizations as please you on top.
    • Optimize manager resource values in according to project requirements. It is recommended to define resources limits in order to follow good practices and for security reasons. More info: and Docker Security Cheat Sheet.
    • Look for in the source code generated by the CLI to ensure that you follow all suggested customizations.