zoukankan      html  css  js  c++  java
  • 21.Pod的limit和request和资源监控收集服务Heapster

    容器的资源需求,资源限制 
         
        requests:需求,最低保障; 
        limits:限制,硬限制; 
         
        CPU:  
            1颗逻辑CPU 
            1=1000,millicores 
                500m=0.5CPU 
                 
        内存: 
            E、P、T、G、M、K 
            Ei、Pi 
             
        QoS: 
            Guranteed:每个容器 
                同时设置CPU和内存的requests和limits. 
                    cpu.limits=cpu.requests 
                    memory.limits=memory.request 
            Burstable: 
                至少有一个容器设置CPU或内存资源的requests属性 
            BestEffort:没有任何一个容器设置了requests或limits属性;最低优先级别; 

    官方文档对需求和限制的解释

    spec.containers[].resources.limits.cpu
    spec.containers[].resources.limits.memory
    spec.containers[].resources.requests.cpu
    spec.containers[].resources.requests.memory
    apiVersion: v1
    kind: Pod
    metadata:
      name: frontend
    spec:
      containers:
      - name: db
        image: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "password"
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "128Mi"
            cpu: "500m"
      - name: wp
        image: wordpress
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "128Mi"
            cpu: "500m"

    进行一个简单的压测

    [root@master limit]# cat pod-demo.yml 
    apiVersion: v1
    kind: Pod
    metadata: 
      name: pod-limit
      namespace: default
      labels:
        app: myapp
        2sdlfj: dashazi
    spec:
      containers:
      - name: stress-ng
        image: ikubernetes/stress-ng
        command: ["/usr/bin/stress-ng","-m 1","-c 1","--metrics-brief"]
        resources:
          requests:
            cpu: "500m"
            memory: "256Mi"
          limit:
            cpu: "500m"
            memory: "256Mi"
      nodeSelector:
        location: slave1

    kubectl exec pod-limit -- top

    Mem: 1994208K used, 52860K free, 113228K shrd, 328K buff, 194776K cached
    CPU: 18% usr 28% sys 0% nic 30% idle 11% io 0% irq 11% sirq
    Load average: 8.07 6.10 3.87 6/740 123
    PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND
    6 1 root R 6892 0% 0 11% {stress-ng-cpu} /usr/bin/stress-ng
    84 0 root R 1500 0% 0 0% top
    123 7 root R 262m 13% 1 0% {stress-ng-vm} /usr/bin/stress-ng
    7 1 root S 6244 0% 1 0% {stress-ng-vm} /usr/bin/stress-ng
    1 0 root S 6244 0% 1 0% /usr/bin/stress-ng -m 1 -c 1 --met
    21 0 root S 1504 0% 0 0% top

    资源监控收集服务Heapster(已弃用)

    [root@master limit]# kubectl top node
    Error from server (NotFound): the server could not find the requested resource (get services http:heapster:)
  • 相关阅读:
    Sliverlight常见错误集锦
    Excel公式使用
    Slider绑定事件,初始化NullPointerException错误
    修改VS 2012调试默认浏览器
    Silverlight界面设计
    you can't add a reference to Newtonsoft.Json.dll as it was not built against the silverlight runtime
    安装 ArcGISAPI31forSilverlight an i/o error occured while installing a file错误解决
    关于无法进入电子科大信息门户的相关问题研究
    HDU 1878 欧拉回路
    POJ 2492 A Bug's Life
  • 原文地址:https://www.cnblogs.com/leleyao/p/10592032.html
Copyright © 2011-2022 走看看