apiVersion: apps/v1 kind: Deployment metadata: name: php-apache namespace: demo-space spec: selector: matchLabels: run: php-apache replicas: 1 template: metadata: labels: run: php-apache spec: containers: - name: php-apache image: registry.k8s.io/hpa-example ports: - containerPort: 80 resources: # 必须设置资源限制,HPA 才能计算百分比 limits: cpu: 500m requests: cpu: 200m --- apiVersion: v1 kind: Service metadata: name: php-apache namespace: demo-space spec: ports: - port: 80 selector: run: php-apache