mayadata-io / d-operators

Declarative patterns to write kubernetes controllers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: proposal to implement a declarative kubernetes controller

AmitKumarDas opened this issue · comments

ProblemStatement: As a K8s engineer

  • I want to watch a resource & update its status
  • I want to watch more than one resources & update their status
  • I want to watch multiple resources & update their labels
  • I want to watch multiple resources & update their annotations
  • I want to watch a resource & create one or more Kubernetes resources as the watch's desired state
  • I want to watch a resource & update one or more Kubernetes resources as the watch's desired state
  • I want to watch a resource & delete one or more Kubernetes resources when the watch gets deleted
  • I want to invoke a series of HTTP APIs via kind: HTTP custom resource. Each of these APIs will need data from previous API call(s).
  • Solve requirements like this
  • I want specific controller pods to handle resources from specific namespaces. For example: controller pod running in team-a should handle resources from namespaces x, y, & z only
    • --include-namespaces, default=all
    • --exclude-namespaces, default=none
  • I want to associate specific worker goroutine count to specific controller
  • I want to enable & disable reconciliation of my custom resource based on some annotation

High Level Design Draft 0

NOTE: kind: UberLoop will be the name of this new resource
NOTE: UberLoop will depend on existing Kubernetes custom & native resources to implement new use cases
NOTE: Jsonnet will be used to achieve the desired state
NOTE: Jsonnet will be used since the main assumption is to manipulate one or more Kubernetes resources that adhere to json schema
NOTE: Jsonnet will be used since Golang can make use of this lib
NOTE: UberLoop will use metac as a library
NOTE: UberLoop may not use any of the metac's meta controllers
NOTE: UberLoop might design its own meta controllers that is tightly coupled with Jsonnet
NOTE: UberLoop might need to adopt CRDs that are not yet in the system yet but will be eventually

Specifications Draft 0

Minimal specs

kind: UberLoop
spec:
  parent:
  children:
  attachments:
  sync:

Detailed specs

kind: UberLoop
spec:
  parent: # resource under watch; [optional]
    apiVersion:
    resource:
    selector:
  children: # resources related to parent; [optional]
  - apiVersion:
    resource:
    selector:
  attachments: # resources that may or may not be related to parent; [optional]
  - apiVersion:
    resource:
    selector:
  sync:
    jsonnet: 
      labelSelector: # use 'kind: ConfigMap' resources
      inline:
      - # inline jsonnet doc
      - # can be used if jsonnet doc is very small
    command: 
      labelSelector: # use 'kind: Command' resources