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应用程序


相关文章
|
Kubernetes 测试技术 Perl
16-Kubernetes-Pod控制器详解-Horizontal Pod Autoscaler(HPA)
16-Kubernetes-Pod控制器详解-Horizontal Pod Autoscaler(HPA)
|
Kubernetes 算法 调度
13-Kubernetes-Pod详解-调度
13-Kubernetes-Pod详解-调度
|
4月前
|
弹性计算 Kubernetes Perl
Kubernetes Horizontal Pod Autoscaler 和 Vertical Pod Autoscaler 介绍
Kubernetes Horizontal Pod Autoscaler 和 Vertical Pod Autoscaler 介绍
|
弹性计算 运维 Kubernetes
Kubernetes Autoscaler解析
随着Kubernetes生态的不断壮大,一度被誉为新一代数据中心操作系统(DCOS),从资源角度来讲,K8S其核心工作也是管理整个集群的计算资源,并按需合理分配给系统里的程序(以Pod为基础的各种WorkLoad)。本质也是解决资源与业务负载之间供需平衡的问题。因此,了解Kubernetes自动扩展功能的相关原理,可以帮助我们在资源管理层面获得更多的价值,有利于提升运维效能。
228 0
|
资源调度 Kubernetes 监控
Kubernetes 资源水平自动伸缩(Horizontal Pod Autoscaler[HPA])与纵向自动扩缩(VerticalPodAutoscaler[VPA])
Kubernetes 资源水平自动伸缩(Horizontal Pod Autoscaler[HPA])与纵向自动扩缩(VerticalPodAutoscaler[VPA])
|
消息中间件 Kubernetes 监控
Kubernetes-Pod介绍(三)-Pod调度
不同的Pod之间的亲和性问题,例如主从MySQL数据库不能够分配到同一个节点上或者两种Pod必须调度到同一个节点上,实现本地网路、文件共享等等; 有状态的集群,例如Zookeeper、Kafka等有状态的集群,每个节点看起来都是差不多,但是每个节点都必须明确主节点,而且节点启动有严格的顺序要求,此外集群中的数据也需要持久化存储,每个工作节点挂点的时候,如何按照持计划的信息进行恢复等等问题; 每个Node上调度仅仅创建一个Pod,例如对Node节点的监控,主机节点日志、性能采集节点只能部署一个节点; 批量调度的任务以及定时调度的任务,调用完成的时候要求Pod就销毁;
|
Kubernetes 调度 Perl
Kubernetes----Pod配置污点和容忍
Kubernetes----Pod配置污点和容忍
448 0
Kubernetes----Pod配置污点和容忍
|
调度 Perl
Kubernetes----Pod亲和性调度
Kubernetes----Pod亲和性调度
1022 0
|
域名解析 存储 Kubernetes
Kubernetes 无状态应用扩缩容
之前,我们已经学习了如何通过命令行部署应用,本文我们学习如果通过yaml配置文件进行应用部署,并进行应用的扩缩容。
660 0
Kubernetes 无状态应用扩缩容
|
Kubernetes Cloud Native 算法
自动扩缩容 - Autoscaler
Knative Serving 默认情况下,提供了开箱即用的快速、基于请求的自动扩缩容功能 - Knative Pod Autoscaler(KPA)。下面带你体验如何在 Knative 中配置 Autoscaler。
自动扩缩容 - Autoscaler