91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

用heapster實現HPA

發布時間:2020-05-28 14:18:16 來源:網絡 閱讀:383 作者:dongyali521521 欄目:云計算

Horizontal Pod Autoscaling(Pod水平自動伸縮),簡稱HPA。HAP通過監控分析RC或者Deployment控制的所有Pod的負載變化情況來確定是否需要調整Pod的副本數量,這是HPA最基本的原理。
HPA在kubernetes集群中被設計成一個controller,HPA Controller默認30s輪詢一次(可通過kube-controller-manager的標志--horizontal-pod-autoscaler-sync-period進行設置),查詢指定的資源(RC或者Deployment)中Pod的資源使用率,并且與創建時設定的值和指標做對比,從而實現自動伸縮的功能。
HPA可以從兩個地方獲取數據:
1、Heapster:僅支持CPU使用率
2、自定義監控

安裝配置heapster
https://github.com/kubernetes-retired/heapster/tree/v1.4.2/deploy/kube-config/influxdb
$ docker pull docker.io/zhaoqing/heapster-amd64:1.4.2
$ docker pull docker.io/pupudaye/heapster-influxdb-amd64:v1.3.3
1、安裝heapster數據庫influxdb

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: monitoring-influxdb
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: influxdb
    spec:
      containers:
      - name: influxdb
        image: docker.io/pupudaye/heapster-influxdb-amd64:v1.3.3
        volumeMounts:
        - mountPath: /data
          name: influxdb-storage
      volumes:
      - name: influxdb-storage
        emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  labels:
    task: monitoring
    kubernetes.io/cluster-service: 'true'
    kubernetes.io/name: monitoring-influxdb
  name: monitoring-influxdb
  namespace: kube-system
spec:
  ports:
  - port: 8086
    targetPort: 8086
  selector:
    k8s-app: influxdb

2、安裝heapster

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: heapster
  namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: dongyali-sa2-clusterrolebinding
subjects:
- kind: ServiceAccount
  name: heapster
  namespace: kube-system
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: heapster
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: heapster
    spec:
      serviceAccountName: heapster
      containers:
      - name: heapster
        image: docker.io/zhaoqing/heapster-amd64:1.4.2
        imagePullPolicy: IfNotPresent
        command:
        - /heapster
        - --source=kubernetes:https://kubernetes.default
        - --sink=influxdb:http://monitoring-influxdb.kube-system.svc:8086
---
apiVersion: v1
kind: Service
metadata:
  labels:
    task: monitoring
    kubernetes.io/cluster-service: 'true'
    kubernetes.io/name: Heapster
  name: heapster
  namespace: kube-system
spec:
  ports:
  - port: 80
    targetPort: 8082
  selector:
    k8s-app: heapster

3、修改kube-controller-manager.yaml
$ cd /etc/kubernetes/manifests/
$ vim kube-controller-manager.yaml

spec:
  containers:
  - command:
    - kube-controller-manager
    - --horizontal-pod-autoscaler-use-rest-clients=false         #增加

修改后自動生效
4、創建應用pod用戶測試hpa

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: hpa-nginx-deploy
  labels:
    app: nginx-demo
spec:
  revisionHistoryLimit: 15
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        resources:
          requests:
            cpu: 100m
        ports:
        - containerPort: 80

5、針對上述pod創建hpa
$ kubectl autoscale deployment hpa-nginx-deploy --cpu-percent=10 --min=1 --max=10
設置最小的 pod 副本數為1,最大為10。HPA會根據設定的 cpu使用率(10%)動態的增加或者減少pod數量。
$ kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS
hpa-nginx-deploy Deployment/hpa-nginx-deploy 0%/10% 1 10 1
$ kubectl get hpa hpa-nginx-deploy -o yaml
$ kubectl describe hpa hpa-nginx-deploy
6、用壓力測試查看hpa變化情況
$ kubectl get pod -o wide|grep hpa
hpa-nginx-deploy-7db6976d9b-p7llf 1/1 Running 0 155m 10.244.2.250 server242.example.com
$ kubectl run -i --tty load-generator --image=busybox /bin/sh
/ # while true; do wget -q -O- http://10.244.2.250; done
在另一個終端查看
$ kubectl get hpa
$ kubectl get deployment hpa-nginx-deploy
$ kubectl delete deployments.apps load-generator

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

新河县| 鹿邑县| 阳曲县| 鹤庆县| 浙江省| 德安县| 山东| 大同县| 巩留县| 那曲县| 井冈山市| 珲春市| 扎兰屯市| 华阴市| 宁化县| 北川| 桑植县| 合作市| 晋江市| 福泉市| 于田县| 余姚市| 桐乡市| 随州市| 盐津县| 合阳县| 凤冈县| 西安市| 峨边| 昭苏县| 内江市| 赤壁市| 老河口市| 瑞安市| 乌兰察布市| 洛浦县| 台湾省| 南丰县| 安平县| 马尔康县| 乡城县|