You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
5. Create a file named `azure-vpa-auto.yaml`, and copy in the following manifest that describes a `VerticalPodAutoscaler`:
269
+
270
+
```yml
271
+
apiVersion: autoscaling.k8s.io/v1
272
+
kind: VerticalPodAutoscaler
273
+
metadata:
274
+
name: vpa-auto
275
+
spec:
276
+
targetRef:
277
+
apiVersion: "apps/v1"
278
+
kind: Deployment
279
+
name: vpa-auto-deployment
280
+
updatePolicy:
281
+
updateMode: "Auto"
282
+
```
283
+
284
+
The `targetRef.name` value specifies that any Pod that is controlled by a deployment named `vpa-auto-deployment` belongs to this `VerticalPodAutoscaler`. The `updateMode` value of `Auto` means that the Vertical Pod Autoscaler controller can delete a Pod, adjust the CPU and memory requests, and then start a new Pod.
285
+
286
+
6. Apply the manifest to the cluster using the [kubectl apply][kubectl-apply] command:
287
+
288
+
```bash
289
+
kubectl create -f azure-vpa-auto.yaml
290
+
```
291
+
292
+
7. Wait a few minutes, and view the running Pods again by running the following [kubectl get][kubectl-get] command:
293
+
294
+
```bash
295
+
kubectl get pods
296
+
```
297
+
298
+
The output resembles the following example showing the pod names have changed and status of the pods:
8. Get detailed information about one of your running Pods by using the [Kubectl get][kubectl-get] command. Replace `podName` with the name of one of your Pods that you retrieved in the previous step.
307
+
308
+
```bash
309
+
kubectl get pod podName --output yaml
310
+
```
311
+
312
+
The output resembles the following example, showing that the Vertical Pod Autoscaler controller has increased the memory request to 262144k and CPU request to 25 milliCPU.
313
+
314
+
```output
315
+
apiVersion: v1
316
+
kind: Pod
317
+
metadata:
318
+
annotations:
319
+
vpaObservedContainers: mycontainer
320
+
vpaUpdates: 'Pod resources updated by vpa-auto: container 0: cpu request, memory
9. To get detailed information about the Vertical Pod Autoscaler and its recommendations for CPU and memory, use the [kubectl get][kubectl-get] command:
344
+
345
+
```bash
346
+
kubectl get vpa vpa-auto --output yaml
347
+
```
348
+
349
+
The output resembles the following example:
350
+
351
+
```output
352
+
recommendation:
353
+
containerRecommendations:
354
+
- containerName: mycontainer
355
+
lowerBound:
356
+
cpu: 25m
357
+
memory: 262144k
358
+
target:
359
+
cpu: 25m
360
+
memory: 262144k
361
+
uncappedTarget:
362
+
cpu: 25m
363
+
memory: 262144k
364
+
upperBound:
365
+
cpu: 230m
366
+
memory: 262144k
367
+
```
368
+
369
+
The results shows the `target` attribute specifies that for the container to run optimally, it doesn't need to change the CPU or the memory target. Your results may vary where the target CPU and memory recommendation is higher.
370
+
371
+
The Vertical Pod Autoscaler uses the `lowerBound` and `upperBound` attributes to decide whether to delete a Pod and replace it with a new Pod. If a Pod has requests less than the lower bound or greater than the upper bound, the Vertical Pod Autoscaler deletes the Pod and replaces it with a Pod that meets the target attribute.
372
+
265
373
## Next steps
266
374
267
375
This article showed you how to automatically scale resource utilization, such as CPU and memory, of cluster nodes to match application requirements. You can also use the horizontal pod autoscaler to automatically adjust the number of pods that run your application. For steps on using the horizontal pod autoscaler, see [Scale applications in AKS][scale-applications-in-aks].
0 commit comments