Customizing Resource Interpreter
Resource Interpreter Frameworkโ
In the progress of propagating a resource from karmada-apiserver to member clusters, Karmada needs to know the
resource definition. Take Propagating Deployment as an example, at the phase of building ResourceBinding, the
karmada-controller-manager will parse the replicas from the deployment object.
For Kubernetes native resources, Karmada knows how to parse them, but for custom resources defined by CRD(or extended
by something like aggregated-apiserver), as lack of the knowledge of the resource structure, they can only be treated
as normal resources. Therefore, the advanced scheduling algorithms cannot be used for them.
The Resource Interpreter Framework is designed for interpreting resource structure. It consists of built-in and
customized interpreters:
built-ininterpreter: used for common Kubernetes native or well-known extended resources.customizedinterpreter: interprets custom resources or overrides the built-in interpreters.
Note: The major difference between
built-inandcustomizedinterpreters is that thebuilt-ininterpreter is implemented and maintained by Karmada community and will be built into Karmada components, such askarmada-controller-manager. On the contrary, thecustomizedinterpreter is implemented and maintained by users. It should be registered to Karmada as anInterpreter Webhookordeclarative configuration(see Customized Interpreter for more details).
Interpreter Operationsโ
When interpreting resources, we often get multiple pieces of information extracted. The Interpreter Operations
defines the interpreter request type, and the Resource Interpreter Framework provides services for each operation
type.
For all operations designed by Resource Interpreter Framework, please refer to Interpreter Operations.
Note: Not all the designed operations are supported (see below for supported operations).
Note: At most one interpreter will be consulted to when interpreting a resource with specific
interpreter operationand thecustomizedinterpreter has higher priority thanbuilt-ininterpreter if they are both interpreting the same resource. For example, thebuilt-ininterpreter servesInterpretReplicaforDeploymentwith versionapps/v1. If there is a customized interpreter registered to Karmada for interpreting the same resource, thecustomizedinterpreter wins and thebuilt-ininterpreter will be ignored.
Built-in Interpreterโ
For the common Kubernetes native or well-known extended resources, the interpreter operations are built-in, which means the users usually don't need to implement customized interpreters. If you want more resources to be built-in, please feel free to file an issue to let us know your user case.
The built-in interpreter now supports following interpreter operations:
InterpretReplicaโ
Supported resources:
- Deployment(apps/v1)
- StatefulSet(apps/v1)
- Job(batch/v1)
- Pod(v1)
ReviseReplicaโ
Supported resources:
- Deployment(apps/v1)
- StatefulSet(apps/v1)
- Job(batch/v1)
Retainโ
Supported resources:
- Pod(v1)
- Service(v1)
- ServiceAccount(v1)
- PersistentVolumeClaim(v1)
- PersistentVolume(V1)
- Job(batch/v1)
AggregateStatusโ
Supported resources:
- Deployment(apps/v1)
- Service(v1)
- Ingress(networking.k8s.io/v1)
- Job(batch/v1)
- CronJob(batch/v1)
- DaemonSet(apps/v1)
- StatefulSet(apps/v1)
- Pod(v1)
- PersistentVolume(V1)
- PersistentVolumeClaim(v1)
- PodDisruptionBudget(policy/v1)
InterpretStatusโ
Supported resources:
- Deployment(apps/v1)
- Service(v1)
- Ingress(networking.k8s.io/v1)
- Job(batch/v1)
- DaemonSet(apps/v1)
- StatefulSet(apps/v1)
- PodDisruptionBudget(policy/v1)
InterpretDependencyโ
Supported resources:
- Deployment(apps/v1)
- Job(batch/v1)
- CronJob(batch/v1)
- Pod(v1)
- DaemonSet(apps/v1)
- StatefulSet(apps/v1)
- Ingress(networking.k8s.io/v1)
InterpretHealthโ
Supported resources:
- Deployment(apps/v1)
- StatefulSet(apps/v1)
- ReplicaSet(apps/v1)
- DaemonSet(apps/v1)
- Service(v1)
- Ingress(networking.k8s.io/v1)
- PersistentVolumeClaim(v1)
- PodDisruptionBudget(policy/v1)
- Pod(v1)
Customized Interpreterโ
The customized interpreter is implemented and maintained by users, it can be extended in two ways, either by defining declarative configuration files or by running as webhook at runtime.
Note: Decalrative configuration has a higher priority than webhook.
Built-in Resource Declarative Configurationโ
Karmada bundles some popular and open-sourced resources so that users can save the effort to customize them. The configurable interpreter now supports following interpreter operations:
InterpretReplicaโ
Supported resources:
- BroadcastJob(apps.kruise.io/v1alpha1)
- CloneSet(apps.kruise.io/v1alpha1)
- AdvancedStatefulSet(apps.kruise.io/v1beta1)
- Workflow(argoproj.io/v1alpha1)