Camel K KameletBinding Scaling
Manual Scaling
A KameletBinding can be scaled using the kubectl scale
command, e.g.:
$ kubectl scale klb <kamelet_binding_name> --replicas <number_of_replicas>
This can also be achieved by editing the KameletBinding resource directly, e.g.:
$ kubectl patch klb <kamelet_binding_name> -p '{"spec":{"replicas":<number_of_replicas>}}'
The KameletBinding also reports its number of replicas in the .status.replicas
field, e.g.:
$ kubectl get klb <kamelet_binding_name> -o jsonpath='{.status.replicas}'
Autoscaling with Knative
A KameletBinding that binds an HTTP-based source Kamelet can automatically scale based on incoming traffic when installed on a cluster with Knative enabled, including scaling to zero.
The incoming traffic measures either as:
-
The number of simultaneous requests, that are processed by each replica at any given time;
-
Or the number of requests that are processed per second, per replica.
The webhook-source
Kamelet is one of the sources that enables auto-scaling when used in a KameletBinding:
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: webhook-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: webhook-source
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: log-sink
The Knative Autoscaler can be configured using the Knative Service trait, e.g., to set the scaling upper bound (the maximum number of replicas):
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: webhook-binding
spec:
integration:
traits:
knative-service:
configuration:
maxScale: 10
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: webhook-source
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: log-sink
More information can be found in the Knative Autoscaling documentation.
When manually scaling a KameletBinding that deploys as a Knative Service, both scale bounds, i.e.,
|
Autoscaling with HPA
A KameletBinding can automatically scale based on its CPU utilization and custom metrics using horizontal pod autoscaling (HPA).
For example, executing the following command creates an autoscaler for the KameletBinding, with target CPU utilization set to 80%, and the number of replicas between 2 and 5:
$ kubectl autoscale klb <kamelet_binding_name> --min=2 --max=5 --cpu-percent=80
Refer to the Integration scaling guide for information about using custom metrics.
HPA can also be used with Knative, by installing the HPA autoscaling Serving extension. |