CKA2025新题型--虫之教育
文章目录
- 题目 1 HPA
题目 1 HPA
设置配置环境 kubectl config use-context k8s
Task
在 autoscale namespace 中创建一个名为 apache-server 的新HorizontalPodAutoscaler(HPA)。
此 HPA 必须定位到 autoscale namespace 中名为apache-server 的现有 Deployment 。
将 HPA 设置为每个 Pod 的 CPU 使用率旨在 50% 。将其配置为至少有 1 个Pod,且不超过 4 个 Pod 。此外,将缩小稳定窗口设置为 30 秒。
官网答案:https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/
apiVersion: apps/v1
kind: Deployment
metadata:name: apache-servernamespace: autoscale
spec:selector:matchLabels:run: apache-servertemplate:metadata:labels:run: apache-serverspec:containers:- name: apache-serverimage: registry.cn-shenzhen.aliyuncs.com/cookcodeblog/hpa-exampleimagePullPolicy: IfNotPresentports:- containerPort: 80resources:limits:cpu: 500mrequests:cpu: 200m
---
apiVersion: v1
kind