Define the Application using YAML
This topic describes the application configuration using the In-Cluster approach. You will configure the application create an event using YAML.
Starting with Smart Scaler version 2.13.0, we have introduced a new default application definition
to simplify the process of onboarding applications to Smart Scaler. You only need to
identify the namespaces that contain the applications you want Smart Scaler to manage. To
do this, open the ss-agent-values.yaml
file downloaded from the management console's Agents page, and
add the list of namespaces to the namespaceAnnotationKey
label.
After the namespaces are defined, the Inference Agent assumes that all deployments in each specified namespace should be managed as a unit by Smart Scaler.
If this setup matches your deployment pattern, this is all you need to do to onboard your applications.
If this pattern does not match your cluster and you want to specifically identify the deployments that you would want Smart Scaler to manage, then you can define your applications as follows.
Delete the Default ConfigMap
Installing a Smart Scaler Agent defines the ConfigMap. To gain more flexibility, you can remove the default ConfigMap and create a new ConfigMap.
Use this command to remove the default ConfigMap that comes with the Smart Scaler Agent installation:
kubectl delete configmap <configmap-name> -n <namespace>
Example
kubectl delete configmap smart-scaler-config -n smart-scaler
Configure an Application
The following is the template to configure the application.
apiVersion: # The Smart Scaler API version. A set of resources that are exposed together, along with the version.
kind: # The name of a particular object schema.
metadata: # The metadata describes parameters (names and types) and attributes that have been applied.
labels:
app_name: The name of the application.
app_version: The version of the application.
name: # The name of the application. This name and the `labels.app_name` must be same.
namespace: # The name of the namespace.
spec: # The specification of the desired state of an object.
applicationDetails: # This object contains the application details.
scalingPolicy: # The even-scaling policy. The default value is `in-cluster`.
services: # The list of the services to be scaled.
- destinationContext: # The context for service destination
scaledObjectConfig: # This object contains configuration for scaled objects, includes deployment references.
deploymentRef: # This object contains reference to the deployment in the `scaledObjectConfig`.
name: # The name of the deployment in the scaled object config.
namespace: # The namespace of the deployment in the scaled object.
kind: # The name of a particular object schema.
name: # The name of the service.
namespace: # The name of the namespace.
Create the Application Configuration
Create the application configuration by following the details in the following example.
apiVersion: agent.smart-scaler.io/v1alpha1
kind: ApplicationConfig
metadata:
labels:
app_name: my-app
app_version: v1.0
name: my-app
namespace: smart-scaler
spec:
applicationDetails:
scalingPolicy: in-cluster
services:
- destinationContext: in-cluster
scaledObjectConfig:
deploymentRef:
name: nginx
namespace: my-ns
kind: HorizontalPodAutoscaler
name: nginx-scaler
namespace: my-ns
Apply the Configuration
After creating (or editing) the configuration, apply the latest settings using the following command:
kubectl apply -f app-config.yaml -n smart-scaler
Configure an Event
The following is the template to configure an event.
apiVersion: # The Smart Scaler API version. A set of resources that are exposed together, along with the version.
kind: # The name of a particular object schema.
metadata: # The metadata describes parameters (names and types) and attributes that have been applied.
name: # The name of the event.
spec: # EventConfigSpec defines the desired state of EventConfig.
eventStartTimestamp: # The start time of the event.
eventEndTimestamp: # The end time of the event.
applicationConfigName: # The the name of ApplicationConfig.
scalingConfiguration: # This object defines the scaling parameters for the event.
minScalingFactor: # The highest scaling factor for the event, supporting decimal values.
maxScalingFactor: # The smallest scaling factor for the event, supporting decimal values.
cooldownDuration: # The cooldown duration for the event.
destinationContexts: # The list of destination contexts for the event, defaults to in-cluster.
- in-cluster
Create an Event Configuration
Create the event configuration by following the details in the following example.
apiVersion: agent.smart-scaler.io/v1alpha1
kind: EventConfig
metadata:
name: thursday-sale
spec:
displayName: ThursdaySale
eventStartTimestamp: "2024-11-14T00:00:00Z"
eventEndTimestamp: "2024-11-15T00:00:30Z"
applicationConfigName: my-app ## references applicationConfig CR
scalingConfiguration:
minScalingFactor: "10"
maxScalingFactor: "10"
cooldownDuration: 30s # eg. 120s, 1h, 1d
destinationContexts:
- in-cluster
Apply the Configuration
After creating (or editing) the configuration, apply the latest settings using the following command:
kubectl apply -f app-config.yaml -n smart-scaler