k8s弹性伸缩

cornHPA兼容HPA yaml配置
apiVersion: apps/v1 kind: Deployment metadata: name: python-django labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - command: - sh - start.sh image: 'registry-vpc.cn-beijing.aliyuncs.com/aixuexi-jituan/cunchu:latest' imagePullPolicy: Always name: python-django ports: - containerPort: 80 name: http protocol: TCP resources: limits: cpu: 500m memory: 512Mi requests: cpu: 200m memory: 512Mi --- apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: annotations: autoscaling.alpha.kubernetes.io/metrics: >- [{"type":"Resource","resource":{"name":"memory","targetAverageUtilization":60}}] name: hpa-sample-test namespace: slide spec: maxReplicas: 12 minReplicas: 2 scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: python-django targetCPUUtilizationPercentage: 50
---
apiVersion: autoscaling.alibabacloud.com/v1beta1
kind: CronHorizontalPodAutoscaler
metadata:
  labels:
    controller-tools.k8s.io: "1.0"
  namespace: slide
  name: cronhpa-sample-test
spec:
   scaleTargetRef:
      apiVersion: autoscaling/v1
      kind: HorizontalPodAutoscaler
      name:  hpa-sample-test
   jobs:
   - name: "scale-start"
     schedule: "0 55 15 * * *"
     targetSize: 4
   - name: "scale-end"
     schedule: "0 0 16 * * *"
     targetSize: 2
原文地址:https://www.cnblogs.com/liruixin/p/14837355.html