openshfit Vertical Pod Autoscaler 实践

简介: openshfit Vertical Pod Autoscaler 实践

文章目录

1. 介绍

1.1 验证并安装 Vertical Pod Autoscaler Operator

1.1 Vertical Pod Autoscaler 使用方法

2. 扩容 Coffee Shop 应用程序

2.1. 检查 Current Resource Definitions(crd)

3. 创建 VPA for Coffee Shop

3.1 创建 Custom Resource(cr)

3.2 验证重新部署的pod资源设置

4. 删除 VPA for Coffee Shop Application

Red Hat OpenShift 4.8 环境集群搭建

openshift 如何输出json日志

openshfit Vertical Pod Autoscaler 实践

openshift Certified Helm Charts 实践

openshift 创建一个Serverless应用程序

openshift gitops 实践

openshift Tekton pipeline 实践

1. 介绍

在本实验室中,您将了解垂直吊舱自动伸缩器(VPA)。

VPA学习并为与该工作负载对象关联的pod应用优化的CPU和内存资源。

要使用VPA Operator,您需要为集群中的工作负载对象创建VPA自定义资源(CR)。

您可以将VPA与deployment, stateful set, job, daemon set, replica set, or replication controller workload object.


You can find the documentation for the VPA here:

https://docs.openshift.com/container-platform/4.8/nodes/pods/nodes-pods-vertical-autoscaler.html


目标:


Describe the function and features of the VPA.

Set up a Vertical Pod Autoscaler for your Coffee Shop application.

Use the VPA and load generation to scale up a Pod.

Observe the JSON logs.

1.1 验证并安装 Vertical Pod Autoscaler Operator

Browse to your Red Hat® OpenShift® Container Platform web console, and log in as admin.


Instructions and credentials for this are in the provisioning email you received.


Use the perspective switcher to switch to the Administrator perspective.


In the navigation menu, navigate to Workloads → Pods


Click the Project drop-down list and select openshift-vertical-pod-autoscaler.


Expect to see that the four Pods running the VPA’s systems are running OK.

1.1 Vertical Pod Autoscaler 使用方法

The VPA CR must be in the same project as the Pods you want to monitor.


You use the VPA CR to associate a workload object and specify which mode the VPA operates in.


The VPA has several modes:


Auto

Recreate

Initial

Off

The Auto and Recreate modes automatically apply the VPA CPU and memory recommendations throughout the Pod lifetime. The VPA deletes any Pods in the project that are out of alignment with its recommendations. When redeployed by the workload object, the VPA updates the new Pods with its recommendations.


The Initial mode automatically applies VPA recommendations only at Pod creation.


The Off mode only provides recommended resource limits and requests, allowing you to manually apply the recommendations. The Off mode does not update Pods.


You can also use the CR to opt-out certain containers from VPA evaluation and updates.


You must scale up your application to at least two replicas for the VPA to work in Auto or Recreate mode. This helps to reduce application downtime.

2. 扩容 Coffee Shop 应用程序

In this exercise, you use the OpenShift Container Platform web console to scale the Coffee Shop application to three Pods.


Browse to the web console.

From the Administrator perspective, select Project: dev-coffeeshop.

From the navigation menu, select Workloads → Deployments.

Locate the coffee-shop deployment, click options_menu_icon (Options) and select Edit Pod count.

Click ⊕ (Plus) twice to scale up the deployment to three Pods.

Your development Coffee Shop application is now scaled up and ready for the VPA.

2.1. 检查 Current Resource Definitions(crd)

The Coffee Shop application was deployed without specific resource definitions. The VPA adds resource definitions once the VPA CR is created. In this exercise, you verify that there are no resource definitions.


Select Project: dev-coffeeshop from the project drop-down list.

On the navigation menu, select Workloads → Deployments.

Click D coffee-shop.

From the Actions drop-down list, select Edit resource limits.

Observe that no values are filled in.

Click Cancel.

Examine the Pods that are deployed by clicking the Pods tab, and clicking one of the coffee-shop Pods.

On the Pod details page, scroll down until you see Containers and select the coffee-shop container.

On the Container details page, expect to see a section named Resource requests with no values:

Sample Output

Resource requests
-

This confirms that the application has been deployed without resource requests or limits.

3. 创建 VPA for Coffee Shop

In this exercise, you create a Vertical Pod Autoscaler and observe how the Pod is redeployed with recommended resource requests and limits. The VPA operator/controller is already installed. To use it for the Coffee Shop application, you must create a VerticalPodAutoscaler custom resource in the Coffee Shop project.


:vpa没有自定义的web界面。

3.1 创建 Custom Resource(cr)

In this section, you create a VerticalPodAutoscaler custom resource in the Coffee Shop project.


From the toolbar at the top of your web console, click ocp_web_console_add_icon (Add).

Click the Project drop-down list and make sure that dev-coffeeshop is selected.

Copy and paste the following YAML content into the text area:

apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: coffee-shop-vpa-recommender
  namespace: dev-coffeeshop
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind:       Deployment
    name:       coffee-shop
  updatePolicy:
    updateMode: "Auto"

4…Click Create.

3.2 验证重新部署的pod资源设置

In this section, you confirm that the Pod is redeployed with recommended resource requests and limits.


1.On the navigation menu, select Workloads → Pods.


If you are quick, you can watch the Pods be redeployed.


2.Click one of the new Pods.

They have a timestamp of Just Now.


3.On the Pod details page, scroll down to the Containers section and select the coffee-shop container.


On the Container details page, expect to see a section called Resource requests with some values:


Sample Output

Resource requests
cpu: 25m, memory: 297164212

The VPA has filled in its recommended Resource requests for your application. As utilization of your application changes, so too do these resource requests.

4. 删除 VPA for Coffee Shop Application

It is not strictly necessary to remove the VPA from the dev-coffeeshop project. It does not interfere with anything except a HorizontalPodAutoscaler and that is not part of this class.


On the Navigation menu, select Administration →CustomResourceDefinitions.

Scroll all the way to the bottom and click VerticalPodAutoscalers.

In the CustomResourceDefinition details page for the VerticalPodAutoscalers, select the Instances tab.

Locate the VPA coffee-shop-vpa-recommender, click options_menu_icon (Options) and select Delete Vertical Pod Autoscaler.

Click Delete.

你已经完成了垂直吊舱自动缩放实验。您可能希望尝试其他VPA模式,如重新创建(recreates),它只在部署被扩展时应用建议。

当您完成之后,继续到openshift 创建一个Serverless应用程序


相关文章
|
26天前
|
弹性计算
阿里云免费服务器在哪申请?有什么条件吗?免费使用多长时间?
阿里云免费服务器通过“免费试用中心”申请:https://t.aliyun.com/U/88JkrU 仅限新用户:需实名认证、无欠费、未购/试用过ECS。个人享300元/3个月,企业660元/3个月,含20–200GB免费流量,支持多地域与多种实例规格。到期不自动释放,须手动处理避免计费。
|
3月前
|
人工智能 缓存 自然语言处理
大模型AI对话前端应用实践:深度详解流式响应、工具调用状态与长会话同步落地方案24.1
本文深入解析AI对话式前端交互三大核心技术:流式响应(基于SSE逐字渲染)、工具调用状态展示(识别/执行/结果四阶段精细化UI)及长会话同步(虚拟列表+分段加载+前后端双向同步),覆盖实现原理、代码示例与异常兜底,助力构建高性能、高体验的AI应用。
338 2
|
9月前
|
Kubernetes Cloud Native 安全
深度解析:2026年云原生技术发展趋势与企业数字化转型实践
本文深度解析2026年云原生五大趋势:K8s向云原生OS演进,Wasm容器崛起;服务网格成熟落地,“适度微服务”成主流;Serverless加速商业化,开源框架破锁定;DevSecOps深度融合,安全左移常态化;整体呈现平台化、智能化、安全化发展态势。(239字)
|
3月前
|
人工智能 API 开发工具
阿里云百炼计费CodingPlan按调用次数、TokenPlan按Credits、按量计费计费方式解析
阿里云百炼是AI大模型服务平台,新用户免费获千万Tokens。支持三种计费方式:按量付费(单价×Token量)、Token Plan(按Credits订阅)、Coding Plan(按调用次数)。兼容Claude Code、Cursor、Qwen Code等主流AI工具,一站式接入便捷高效。在阿里云百炼官网:https://t.aliyun.com/U/fPVHqY 免费领取千万Tokens
421 7
|
9月前
|
人工智能 测试技术 Linux
OpenClaw到底能用来做什么?阿里云/Win11/Mac/Linux部署配置免费API+36个真实用例解析+FAQ
“OpenClaw到底能用来做什么?”——这是新手入门时最常问的问题。作为19K+ Star的开源AI代理框架,OpenClaw的核心价值不在于单一功能,而在于“场景化自动化”——通过技能组合与多Agent协作,覆盖内容创作、生产力提升、知识管理、基础设施维护等全场景需求。
1354 14
|
9月前
|
JSON 算法 API
如何通过Shopee API根据商品ID获取商品详情
本文详解如何调用Shopee开放API获取商品详情:涵盖开发者注册、凭证获取、签名生成(HMAC-SHA256)、请求构建及Python完整示例代码,并提供错误处理、调试技巧与安全注意事项,助你快速稳定接入。(239字)
1103 1
|
10月前
|
边缘计算 人工智能 算法
一线民警的“最强大脑”:AR眼镜如何破解四大实战难题
在复杂治安环境下,AR+AI智慧警务系统赋能一线民警:AR眼镜实现人脸/车牌毫秒识别、无感核验、违禁品AI识别、3D现场重建;边缘计算+5G回传,低延时、高安全、强兼容,打通信息孤岛,推动警务向智能化、数字化全面跃升。(239字)
|
Prometheus 运维 监控
基于 Prometheus + Grafana 实现 Nexus 监控观测
前言 Nexus 是开源的 Maven 私服仓库,同时 Nexus 还支持 Npm 、 .Net、Golang 、Python 等开发语言的包管理。Nexus 也是我们重度使用的一个应用,Nexus 保存着 Tap 各开发组的代码构建产物。Nexus 出现问题会导致项目 CI 、CD 流程阻断。本文旨在通过 Prometheus + Grafana 实现 Nexus 运行时监控观测,帮助运维人员更加了解 Nexus ,轻松从容应对线上各种疑难杂症。
|
12月前
|
传感器 JSON 物联网
基于 STM32 的无人停车场项目系统【开源项目】
基于 STM32 + ESP8266 的无人停车场系统,是一个集成 嵌入式控制、无线通信、云端计算、物联网整体架构 的典型工程案例。系统具备成本低、易部署、功能丰富、适合扩展的特点,是智慧停车领域一个非常成熟的实现方案。
基于 STM32 的无人停车场项目系统【开源项目】

热门文章

最新文章