环境说明

Centos7.4
kubernetes1.9.2
docker17.12.1-ce


修改controller-manager启动参数

1.将静态pod目录下的kube-controller-manager.yaml移到到其它目录下更改,在manifests目录下直接更改文件,会产生临时文件,从而导致controller-manager无法正常启动

mv /etc/kubernetes/manifests/kube-controller-manager.yaml /tmp/kube-controller-manager.yaml

2.加入启动参数

--horizontal-pod-autoscaler-use-rest-clients=false


deployment样本

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello-world
  labels:
    app: hello-world
spec:
  replicas: 2
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:
    metadata:
      labels:
        app: hello-world 
    spec:
      terminationGracePeriodSeconds: 60
      nodeName: server246
      containers:
      - name: hello-world 
        image: registry.gag.cn/siri/hello-world:v1
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            cpu: "1"
            memory: 512Mi
          requests:
            cpu: "0.5"
            memory: 256Mi

hpa样本

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: hello-world 
  labels:
    app: hello-world
spec:
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: hello-world
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: memory
      targetAverageUtilization: 50
  - type: Resource
    resource:
      name: cpu
      targetAverageUtilization: 20