Skip to content

Create k8s resources by OperandConfig #746

@horis233

Description

@horis233

/kind feature

Describe the solution you'd like
[A clear and concise description of what you want to happen.]

In some cases, a single operator may not be runnable with some additional k8s objects as a prerequisite. For example, image pull secrets or licensing keys.

This feature is for creating some k8s objects by OperandConfig.

1. When the Operator is requested, and resources is configured in the OperandConfig, then ODLM will create these resources for the Operator.

apiVersion: operator.ibm.com/v1alpha1
kind: OperandConfig
metadata:
  name: operandconfig
  namespace: default
spec:
  services:
  - name: example-operator
     spec:
      example-operand:
        some-spec-field: myvalue
     resources:
     -   kind: Job
         name:  registry-key-generater
         apiVersion: batch/v1
         spec:
           template:
             metadata:
               ..         

resources is a list of k8s resources.

Required fields in the individual resource

  • kind indicates the kind of the resource.
  • apiVersion indicates the API group and version of the resource.
  • name indicates the name of the k8s resource.

Optional fields in the individual resource

  • spec: is the spec field of the k8s resource.
  • labels, annotations: Users can use these fields to set up resource labels and annotations.
  • namespace: Users can customize the namespace of the resource. By default, the namespace is the operator namespace.
  • force: Users can use it to decide if ODLM should override the existing resource. By default, the value is true, ODLM will always override existing resource

2. ODLM will generate the resource in the cluster with other requested CRs

3. ODLM will update the status of OperandConfig

status:
  phase: Running
  serviceStatus:
    example-operator:
      customResourceStatus:
        example-operand: Running
      resourceStatus:
         job.v1.batch:
            default/registry-key-generater: deployed

Then we users delete the field from OperandConfig, ODLM could clean it up according to the status.

4. When the operator is deleted, k8s resources created by ODLM should be clean up as well.

Note: If the resource isn't created by ODLM, ODLM won't update or delete it.

Limitations

  • Since ODLM only has namespace admin permission, it can't create cluster scope resources without manually grant it enough cluster roles.

cc @ZhuoxiLi @Daniel-Fan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions