OLM
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- --- # De-coupling APIs and controllers ## What really _is_ an API? In Kubernetes, operators are controller implementations of custom APIs (as opposed to a non-operator controller, which primarily operates on APIs that already exist in the cluster, either built-in or provided by other operators). The custom APIs are defined in one of two ways: - [Custom resource definitions](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/) - [Aggregated API servers](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/) Note that for a given resource, it is not possible for a single control plane to serve an API via both a CRD and an aggregated API server because they both require a URL path reservation for the apiserver to use. ### CustomResourceDefinition A CustomResourceDefinition declaratively describes an API and its versions. It defines the API's schema as well as configurations for admission and conversion webhooks. Thus the collection of resources that are typically found associated with a CustomResourceDefinition are: - `CustomResourceDefinition` - defines the API - `Namespace` - location to run any provided webhooks - `Deployment` - definitions of webhook servers - `Service` - mechanism for apiserver to reach webhook servers - RBAC (`ClusterRole`, `ClusterRoleBinding`, `Role`, `RoleBinding`, `ServiceAccount`) - permissions required by webhook servers to function - `ValidatingWebhookConfiguration` - informs API server about how to connect to validating webhook - `MutatingWebhookConfiguration` - informs API server about how to connect to mutating webhook - cert-manager `Certificate` or similar - often used to automatically provision/roll client/server certs and CAs for authentication between apiserver and webhook server ### APIService Typically, an API service is a pod that serves an API to a control plane and a configuration object that tells the control plane how to reach the pod. This pod is responsible for handling CRUD/REST-style requests proxied to it by the apiserver on behalf of requests made by clients of the apiserver. Thus the collection of resources that are typically found associated with an APIService are: - `APIService` - informs the apiserver about where to proxy requests for the API. - `Namespace` - location to run the aggregated API service - `Deployment` - specification for running the aggregated API service - RBAC (`ClusterRole`, `ClusterRoleBinding`, `Role`, `RoleBinding`, `ServiceAccount`) - permissions required by aggregated API server to function - cert-manager `Certificate` or similar - often used to automatically provision/roll client/server certs and CAs for authentication between apiserver and aggregated API server ## Use cases 1. CRD conversion webhooks must be lifecycled with CRDs. - Conversion webhooks configured on the CRD must be available for the entire lifetime of the CRD's existence. Otherwise the core GC controller fails (i.e. stops garbage collecting across the cluster). 1. Admission webhooks - Admission webhooks that apply to all objects of a CRD should be lifecycled with CRDs. Controller variants may require running their own admission webhooks, scoped to the namespaces that the controller is watching. Admission webhook configurations are cluster-scoped objects, so care must be taken to ensure that bundles for controller variants do not conflict on the name of the admission webhook configs. (Perhaps this situation calls for 3 bundles: CRD, AdmissionWebhookConfigs, Controller+Webhook servers?) 1. Finalizers - When an object that has a finalizer is deleted, Kubernetes marks it with a deletion timestamp, but waits for something to process the deletion and remove the finalizer. If a finalizer is applicable to all objects of that API, a finalizer controller should be packaged with the API bundle. If a finalizer implementation is specific to a particular controller variant, things become somewhat complicated. Often the finalizer logic exists in the reconciling controller itself. In that case, it means the controller must exist and be running in the cluster until all of the CRs with finalizers are removed. If nothing exists to process the finalizer, the deletion of the CR will be blocked forever (or until someone manually removes the finalizer). And a blocked CR deletion cascades and causes a CRD deletion to be blocked as well. 1. Upgrade lifecycling - If decoupled from their controllers, API upgrades can focus purely on the validity of _just_ APIs being upgraded. Concerns related to schema changes, stored version migration, webhook deployment strategy, etc. can all be handled without concern for controller-related lifecycling. OLM's dependency resolution would ensure that APIs cannot be upgraded unless all installed controllers allow it (via their declared dependency on the API package). - If decoupled from their APIs, upgrading and downgrading controllers becomes much easier. Rollbacks are no longer necessarily contigent on the ability to _also_ rollback an API. 1. Uninstall - Moving to a declarative model for operator lifecycling, we will likely need to treat bundles as a unit for install/uninstall. If a bundle contains CRDs, deleting that bundle from the cluster will delete the CRDs. Deleting CRDs cascades to deletion of CRs and user workloads. If CRDs and controllers are split into separate bundles, a controller can be atomically deleted without affecting CRDs and CRs. 1. De-scoping - If we separate APIs from controllers, our de-scoping story is likely simplified down to API de-scoping. There are already several very visible examples of multiple controllers for the same API being installed together in a cluster. The most obvious example is the Ingress API and all of the ingress controllers. - Kubernetes has already stated for us "only one definition of a given group/kind" per cluster. - We can potentially back off on the verbiage around "only one operator per owned API per cluster". Ingress controllers prove this is an unnecessary constraint. OLM would delegate to controller implementations to determine how to shard ownership of custom resources. Options include namespace-based sharding, label selectors, and implementation-specific class names (e.g. IngressClass, StorageClass) 1. KCP - In KCP every application stack will get its own workspace (i.e. virtual cluster, separate control plane). This means different applications (in different workspaces) can use different versions of the same API because APIs are installed at the workspace level. However controllers may be installed in physical clusters or in such a way that their view of the cluster spans multiple workspaces. In this model, any operator targeting KCP will very likely need to de-couple the APIs it provides from the controllers it runs. 1. Canary rollouts - If I want to be able to run multiple versions of the same operator for the purposes of a canary rollout, both of those operators must rely on the same CRD. That means CRDs cannot be changed during a canary rollout. To ensure that invariant, the only way to enable canary rollouts for every release of an operator is to manage the CRD separately from the operator. - Related to item (1), CRD conversion webhooks are the domain of the CRD, not the controller. You can't canary conversion webhooks because there can be only one active conversion webhook per CRD. Therefore, any bundle that contains a conversion webhook cannot be canaried. Therefore, bundles with conversion webhooks and combined APIs and controllers cannot be canaried. - Admission webhooks _do_ have configurable selectors such that they could theoretically be configured to align with canary rollout selectors. More thought and experimentation is necessary to understand if admission webhooks can be lifecycled with controllers instead of CRDs.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully