Skip to content

Commit b86fbb2

Browse files
committed
completed article
1 parent bb52a03 commit b86fbb2

File tree

1 file changed

+112
-4
lines changed

1 file changed

+112
-4
lines changed

articles/aks/vertical-pod-autoscaler.md

Lines changed: 112 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Vertical Pod Autoscaling (preview) in Azure Kubernetes Service (AKS)
33
description: Learn how to vertically autoscale your pod on an Azure Kubernetes Service (AKS) cluster.
44
services: container-service
55
ms.topic: article
6-
ms.date: 09/27/2022
6+
ms.date: 09/29/2022
77
---
88

99
# Vertical Pod Autoscaling (preview) in Azure Kubernetes Service (AKS)
@@ -219,16 +219,16 @@ Vertical Pod autoscaling uses the `VerticalPodAutoscaler` object to automaticall
219219
apiVersion: apps/v1
220220
kind: Deployment
221221
metadata:
222-
name: azure-autodeploy
222+
name: vpa-auto-deployment
223223
spec:
224224
replicas: 2
225225
selector:
226226
matchLabels:
227-
app: azure-autodeploy
227+
app: vpa-auto-deployment
228228
template:
229229
metadata:
230230
labels:
231-
app: azure-autodeploy
231+
app: vpa-auto-deployment
232232
spec:
233233
containers:
234234
- name: mycontainer
@@ -260,8 +260,116 @@ Vertical Pod autoscaling uses the `VerticalPodAutoscaler` object to automaticall
260260
The output resembles the following example showing the name and status of the pods:
261261

262262
```output
263+
NAME READY STATUS RESTARTS AGE
264+
vpa-auto-deployment-54465fb978-kchc5 1/1 Running 0 52s
265+
vpa-auto-deployment-54465fb978-nhtmj 1/1 Running 0 52s
263266
```
264267

268+
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:
299+
300+
```output
301+
NAME READY STATUS RESTARTS AGE
302+
vpa-auto-deployment-54465fb978-qbhc4 1/1 Running 0 2m49s
303+
vpa-auto-deployment-54465fb978-vbj68 1/1 Running 0 109s
304+
```:
305+
306+
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
321+
request'
322+
creationTimestamp: "2022-09-29T16:44:37Z"
323+
generateName: vpa-auto-deployment-54465fb978-
324+
labels:
325+
app: vpa-auto-deployment
326+
327+
spec:
328+
containers:
329+
- args:
330+
- -c
331+
- while true; do timeout 0.5s yes >/dev/null; sleep 0.5s; done
332+
command:
333+
- /bin/sh
334+
image: mcr.microsoft.com/oss/nginx/nginx:1.15.5-alpine
335+
imagePullPolicy: IfNotPresent
336+
name: mycontainer
337+
resources:
338+
requests:
339+
cpu: 25m
340+
memory: 262144k
341+
```
342+
343+
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+
265373
## Next steps
266374
267375
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

Comments
 (0)