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

Add two feature gates : Image based deployment and additional runtimeClasses #394

Closed
wants to merge 16 commits into from

Commits on Apr 23, 2024

  1. Move featuregates to separate package

    Additionally include the following changes:
    1. Include separate logger for the package
    2. Switch to a status map to keep track of FeatureGate status.
    This enables tracking multiple feature gates in the reconcile loop
    and avoid calling the Kube API for individual feature gates
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 23, 2024
    Configuration menu
    Copy the full SHA
    27a7e94 View commit details
    Browse the repository at this point in the history

Commits on Apr 25, 2024

  1. Add method to check for feature cm

    Queries the K8s api to check if feature configmap
    is present or not
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    b6bacc1 View commit details
    Browse the repository at this point in the history

Commits on Apr 29, 2024

  1. Add support for layered image based deployment

    OpenShift supports image layering, that allows deployment of packages by
    providing a custom RHCOS image.
    You need to create a MachineConfig with the custom RHCOS image url and
    that's about it.
    
    This commit adds support for using custom RHCOS image url to deploy Kata
    components as an alternative to using the extension mechanism.
    
    This capability is behind a feature gate and you'll need to set
    LayeredImageDeployment to true in osc-feature-gates ConfigMap.
    
    Additionally you'll need to set additional config params like shown
    below for the layeredimagedeployment-config configmap:
    
    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: osc-feature-gates
    namespace: openshift-sandboxed-containers-operator
    data:
    LayeredImageDeployment: "true"
    
    ---
    
    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: layeredimagedeployment-config
    namespace: openshift-sandboxed-containers-operator
    data:
    osImageURL: "quay.io/...."
    kernelArguments: "a=b c=d ..."
    
    Logs an error and reconcile if LayeredImageDeployment
    feature is enabled and configmap is not provided
    
    Fixes: #KATA-2902
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    2559ba0 View commit details
    Browse the repository at this point in the history
  2. Add separate event handler for configmap updates

    With the previous code of predicate func, the reconcile loop was
    not receiving the KataConfig struct. Instead the reconcile loop was
    called with the OSC featuregate configmap struct.
    The new method ensures that for featuregate configMap changes,
    the reconcile loop is called with the KataConfig struct.
    
    Fixes: #KATA-2902, #KATA-2903
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    c4de12f View commit details
    Browse the repository at this point in the history
  3. Allow multiple runtimeClass creation

    Modify createRuntimeClass function to createRuntimeClasses
    This lays the foundation to support different runtimeClasses
    for CoCo like kata-cc-tdx, kata-cc-snp, kata-cc-remote etc.
    
    Fixes: #KATA-2903
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    c69ccba View commit details
    Browse the repository at this point in the history
  4. Add feature for creating additional runtimeClasses

    This is enabled via AdditionalRuntimeClasses feature gate.
    Example configuration is shown below:
    
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: osc-feature-gates
      namespace: openshift-sandboxed-containers-operator
    data:
      AdditionalRuntimeClasses: "true"
    
    ---
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: additionalruntimeclasses-config
      namespace: openshift-sandboxed-containers-operator
    data:
      runtimeClassConfig: "name1:cpuOverHead1:memOverHead1, name2:cpuOverHead2:memOverHead2"
      #runtimeClassConfig: "name1, name2"
    
    Also rearrange the code to have all the runtimeClass handling in a
    single code file for easier readability
    
    This feature typically will be used with other features.
    For example this feature can be used with the image based deployment feature as well.
    The image based deployment might have configuration for multiple
    runtimeclasses which is then exposed to users as RuntimeClass objects
    created by OSC operator when this feature gate is enabled.
    
    Logs an error if AdditionalRuntimeClasses feature is enabled
    and config is not provided
    
    Fixes: #KATA-2903
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    1fc86ae View commit details
    Browse the repository at this point in the history
  5. Update featuregate sample yaml

    Add examples for LayeredImageDeployment and
    AdditionalRuntimeClasses feature
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    36272dc View commit details
    Browse the repository at this point in the history
  6. remove unused method

    IsEnabled method is no longer needed. Hence removing it
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    d1eea4b View commit details
    Browse the repository at this point in the history
  7. Rename DefaultFeatureGates to DefaultFeatureGatesStatus

    This aligns with its usage
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    fb547fe View commit details
    Browse the repository at this point in the history
  8. Handle featuregate cm delete

    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    0e53603 View commit details
    Browse the repository at this point in the history
  9. Create featuregate status configmap at start

    Featuregate status configmap is initialised by the operator
    itself.
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    6c004fd View commit details
    Browse the repository at this point in the history
  10. Handle missing featuregate status configmap

    Check for featuregate status configmap in the beginning of the reconcile
    loop and don't proceed if it's missing
    
    This ensures we don't take any action if we cannot determine the
    FeatureGateStatus which could be due to an error in fetching the
    ConfigMap or the ConfigMap not being present
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    9e96e8d View commit details
    Browse the repository at this point in the history
  11. Remove duplicate code for reading yamls

    We had different methods to read yaml files depending on the
    kubernetes object. However this is really not needed as all the methods
    simply were reading files with the only difference being the flie
    location.
    This commit simplifies the code and uses a single readYamlFile method.
    The caller should set the full path of the yaml file to be read.
    Further any additional requirements to read different yaml files will
    no longer need a new method
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    c59f99b View commit details
    Browse the repository at this point in the history
  12. Rename FeatureGatesConfigMapName to FeatureGatesStatusConfigMapName

    This avoids confusion with the individual feature gate configmap
    and also correctly reflects the intent of the variable
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    27599db View commit details
    Browse the repository at this point in the history
  13. Revert fg status configmap to default on KataConfig deletion

    Since fg status configmap is must and created during operator
    initialisation, we need to ensure on KataConfig deletion it's reverted
    back to default values.
    
    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    9a30d74 View commit details
    Browse the repository at this point in the history
  14. Add unit tests for fg method

    Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
    bpradipt committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    5f47dc5 View commit details
    Browse the repository at this point in the history