How to modify autoscaling after increasing CPU on Measurements Pods



Overview

By default, the vfunction-vfapi-measurements Pod is configured with 1 CPU as the Limit and 125m CPU as the Requests (starting point) for each Pod. By default, a new Pod will be created when the average CPU across all Measurements Pods exceeds 875m.

The CPU Limit for the Measurements Pods can be increased in the Configurable Settings. When the CPU Limit is increased, this Limit increase does not automatically increase the threshold at which a new Pod will be created through the autoscaling process. The average CPU across all Measurements Pods will still tsay at 875m unless modified using one of the workflows below.


Steps to modify Autoscaling before Installation

Take the following steps to modify the autoscaling settings before installing the vFunction Server in a Kubernetes Cluster:

  1. Move the vFunction Kubernetes Installation TGZ to the Linux VM with access to the Kubernetes Cluster
  2. Unpack the TGZ
### Modify PACKAGE to be the correct package type
### Modify VERSION to be the correct version used for the installation
tar -xvzf vfunction-server-installation-PACKAGE.vVERSION.tgz
  1. Modify the Configurable Settings for the vFunction Installation to change the CPU Limit
cd vfunction-server-for-kubernetes
vi config/installation.yaml

### Before
server:
  ...
  measurements:
    ...
    max_pod_cpu_capacity: "1"

### After
server:
  ...
  measurements:
    ...
    max_pod_cpu_capacity: "4"
  1. Modify the averageUtilization for the Horizontal Pod Autoscaling
cd helm
tar -xvzf server-chart.tgz
vi server-for-kubernetes/templates/horizontalpodautoscaler.yaml

### Before
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
...
spec:
  scaleTargetRef:
    kind: "Deployment"
    name: "vfunction-vfapi-measurements"
    apiVersion: "apps/v1"
  ...
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 700

### After - Note that the value should be multiplied by the factor of CPU increase
### For example, if the original Max Pod CPU was 1 CPU and the new value is 4 CPU, ...
### then multiply the averageUtilization value by 4 so that it is changed from 700 to 2800
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
...
spec:
  scaleTargetRef:
    kind: "Deployment"
    name: "vfunction-vfapi-measurements"
    apiVersion: "apps/v1"
  ...
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 2800

tar -cvzf server-chart.tgz server-for-kubernetes/
  1. Install the vFunction Server
### Modify NAMESPACE to be relevant to the environment
cd ../..
bash install.sh -i NAMESPACE

Steps to modify Autoscaling before Installation

Take the following steps to modify the autoscaling settings after installing the vFunction Server in a Kubernetes Cluster:

  1. SSH to the Linux VM with access to the Kubernetes Cluster
  2. Confirm that the Max Pod CPU value has already been increased from 1 to a higher value
### Modify NAMESPACE as required
### If multiple entries are returned, one may be for the Busybox Container controlling the Pod startup process
### The Busybox Container can be ignored 
kubectl get deployments vfunction-vfapi-measurements -n NAMESPACE -o yaml

### Sample Expected Output
        resources:
          limits:
            cpu: "4"
            ephemeral-storage: 1Gi
            memory: 8Gi
          requests:
            cpu: 125m

  1. Modify the averageUtilization in the Horizontal Pod Autoscaler by the same factor as the CPU Limit increase
### Replace NAMESPACE with the correct value
kubectl edit horizontalpodautoscaler vfapi-measurements -n NAMESPACE

### Before
spec:
  maxReplicas: 10
  metrics:
  - resource:
      name: cpu
      target:
        averageUtilization: 700
        type: Utilization

### After
### Note that the value should be multiplied by the factor of CPU increase
### For example, if the original Max Pod CPU was 1 CPU and the new value is 4 CPU, ...
### then multiply the averageUtilization value by 4 so that it is changed from 700 to 2800
spec:
  maxReplicas: 10
  metrics:
  - resource:
      name: cpu
      target:
        averageUtilization: 2800
        type: Utilization