Manifests
Autoscaling
Autoscaling is a crucial feature for managing the scalability and efficiency of applications
running in dynamic environments. For NitroEnclaveDeployments
, autoscaling is implemented
through a sophisticated controller that interacts directly with Prometheus to fetch real-time metrics.
This custom autoscaler utilises a defined set of metrics, such as request rates or computational loads,
to make informed decisions.
Horizontal NitroEnclave Scaling
A HorizontalNitroEnclaveAutoscaler
automatically updates a NitroEnclaveDeployment
to scale it to match demand.
Horizontal scaling means that the response to increased load is to add more Nitro enclaves. If the load
decreases and the number of NitroEnclaves exceeds the configured minimum, the HorizontalNitroEnclaveAutoscaler
instructs the NitroEnclaveDeployment
to scale back down.
The HorizontalNitroEnclaveAutoscaler
is implemented as a Kubernetes API resource and a controller. The definition
of the resource determines the behaviour of the controller. The HorizontalNitroEnclaveAutoscaler
, running as a
controller pod, periodically adjusts the desired scale of the NitroEnclaveDeployment
to match observed metrics
such as average CPU utilisation, average memory utilisation, or any other custom metric you specify.
The Horizontal Nitro Enclave autoscaling is implemented as an intermittent control loop. Once during each period, the controller queries the resource utilisation against the specified metrics in each HorizontalNitroEnclaveAutoscaler definition. These metrics are fetched from Prometheus, where all the enclaves are aggregated.
Example: Starting a Horizontal Nitro Enclave Autoscaler
The HorizontalNitroEnclaveAutoscaler
is a custom resource that automatically scales the number of Nitro Enclave Deployments based on observed metrics.
Here ’s an example of a HorizontalNitroEnclaveAutoscaler
for a FastAPI Nitro Enclave Deployment.
# hello-fastapi-deployment-hnea.yaml
apiVersion: autoscaling.example.com/v1
kind: HorizontalNitroEnclaveAutoscaler
metadata:
name: hello-fastapi-deployment-hnea
namespace: default
spec:
scaleTargetRef:
apiVersion: k8s.oblv.com/v1alpha1
kind: NitroEnclaveDeployment
name: hello-fastapi-deployment
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 70
Fields
To better understand the fields of the example manifest, here's a brief description:
General Information
Field | Description | Value |
---|---|---|
apiVersion | Specifies the API version for the custom autoscaler. | autoscaling.example.com/v1 |
kind | Specifies the kind of Kubernetes resource. | HorizontalNitroEnclaveAutoscaler |
Metadata
Field | Description | Value |
---|---|---|
name | Specifies the name of the HorizontalNitroEnclaveAutoscaler. | hello-fastapi-deployment-hnea |
namespace | Specifies the namespace where the autoscaler will be created. | default |
Spec Configuration
Field | Description |
---|---|
spec | Contains the detailed specification for the HorizontalNitroEnclaveAutoscaler. |
Scale Target Reference
Field | Description | Value |
---|---|---|
apiVersion | API version of the target. | k8s.oblv.com/v1alpha1 |
kind | Kind of target resource. | NitroEnclaveDeployment |
name | Name of the target resource. | hello-fastapi-deployment |
Scaling Parameters
Field | Description | Value |
---|---|---|
minReplicas | Minimum number of replicas. | 1 |
maxReplicas | Maximum number of replicas. | 10 |
Metrics for Scaling
Field | Description | Value |
---|---|---|
type | Type of metric used for scaling. | Resource |
resource | Specifies the resource to be measured. | cpu |
target type | Specifies the scaling target type. | Utilization |
averageUtilization | Target average CPU utilisation percentage. | 50 |
Usage
To create a HorizontalNitroEnclaveAutoscaler
, you can use the kubectl apply
command:
kubectl apply -f hello-fastapi-deployment-hnea.yaml
To view the current status of a HorizontalNitroEnclaveAutoscaler, you can use the kubectl get
command:
kubectl get hnea hello-fastapi-deployment-hnea
To delete a HorizontalNitroEnclaveAutoscaler, you can use the kubectl delete
command:
kubectl delete hnea hello-fastapi-deployment-hnea