pod资源需求,资源限制

Requests:需求,最低保障;

Limits: 限制,硬限制;

Limits >= request

CPU:

1颗虚拟CPU=1000 毫核心 millicores

0.5cpu=500m

内存:

E,P,T,G,M,K

Ei,Pi

资源需求计算:根据request来计算

资源定义

kubectl explain pods.spec.containers.resources

vim pod-demo.yaml

apiVersion: v1

kind: Pod

apiVersion: v1

kind: Pod

metadata:

name: pod-demo

namespace: default

labels:

app: myapp

tier: frontend

spec:

containers:

- name: myapp

image: ikubernetes/stress-ng

command: ["/usr/bin/stress-ng","-m 1","-c 1","--metrics-brief"]  -m 启动一个进程 –c 1使用一颗cpu

resources:

requests: 最小资源需求

cpu: "200m"  500millicores

memory: "128Mi"

limits: 限制使用最大资源

cpu: "500m"

memory: "200Mi"

kubectl apply -f pod-demo.yaml

kubectl exec -it pod-demo -- /bin/sh

QoS class:服务质量类别

Guranteed:  pod每个都设置了CPU,memory, 且 requests=limits  这个类别有最高优先级

Burstable:pod至少有一个容器设置了cpu或memory的requests,这个类别有中等优先级

BestEffort:没有任何容器设置了requests或limits;是最低优先级

当资源不够用时,BestEffort中的容器会被优先终止,以腾出资源确保另外两类pod正常运行

同类型的优先级,先关闭资源占用与资源最低需求比例较高的

查看pod资源使用 依赖heapster 指标数据采集工具  cAdvisor --> HeapSter     HeapSter--> InfluxDB   InflusDB-->Grafana

kubectl top pod pod-demo

pod资源监控指标:

  1. k8s系统指标
  2. 容器指标 容器级CPU,内存,存储等资源利用情况
  3. 容器内运用指标 业务

k8s的几个重要插件:kube_dns  dashboard  heapster

heapster监控组件:HeapSter,InfluxDB,Grafana

配置InfluxDB

heapster依赖influxdb

https://github.com/kubernetes-retired/heapster/tree/master/deploy/kube-config  -->raw:下载网址

mkdir heapster &&  cd heapster/

wget https://raw.githubusercontent.com/kubernetes-retired/heapster/master/deploy/kube-config/influxdb/influxdb.yaml

vim influxdb.yaml

apiVersion: apps/v1

kind: Deployment

metadata:

name: monitoring-influxdb

namespace: kube-system

spec:

replicas: 1

selector:

matchLabels:

task: monitoring

k8s-app: influxdb

template:

metadata:

labels:

task: monitoring

k8s-app: influxdb

spec:

containers:

- name: influxdb

image: registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-influxdb-amd64:v1.5.2  更换镜像地址

volumeMounts:

- mountPath: /data

name: influxdb-storage

volumes:

- name: influxdb-storage

emptyDir: {}

---

apiVersion: v1

kind: Service

metadata:

labels:

task: monitoring

# For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)

# If you are NOT using this as an addon, you should comment out this line.

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

kubectl apply -f influxdb.yaml

kubectl get svc -n kube-system

kubectl get pods -n kube-system

部署HeapSter

先配置rbac  https://raw.githubusercontent.com/kubernetes-retired/heapster/master/deploy/kube-config/rbac/heapster-rbac.yaml

kubectl apply -f heapster-rbac.yaml

下载heapster配置清单

https://raw.githubusercontent.com/kubernetes-retired/heapster/master/deploy/kube-config/influxdb/heapster.yaml

vim heapster.yaml

apiVersion: v1

kind: ServiceAccount

metadata:

name: heapster

namespace: kube-system

---

apiVersion: apps/v1

kind: Deployment

metadata:

name: heapster

namespace: kube-system

spec:

replicas: 1

selector:

matchLabels:

task: monitoring

k8s-app: heapster

template:

metadata:

labels:

task: monitoring

k8s-app: heapster

spec:

serviceAccountName: heapster

containers:

- name: heapster

image: registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-amd64:v1.5.4   更换镜像地址

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

# For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)

# If you are NOT using this as an addon, you should comment out this line.

kubernetes.io/cluster-service: 'true'

kubernetes.io/name: Heapster

name: heapster

namespace: kube-system

spec:

ports:

- port: 80

targetPort: 8082

selector:

k8s-app: heapster

kubectl apply -f heapster.yaml

kubectl get svc -n kube-system

kubectl get pods -n kube-system

配置Grafana

下载配置清单

wget https://raw.githubusercontent.com/kubernetes-retired/heapster/master/deploy/kube-config/influxdb/grafana.yaml

vim grafana.yaml

apiVersion: apps/v1

kind: Deployment

metadata:

name: monitoring-grafana

namespace: kube-system

spec:

replicas: 1

selector:

matchLabels:

task: monitoring

k8s-app: grafana

template:

metadata:

labels:

task: monitoring

k8s-app: grafana

spec:

containers:

- name: grafana

image: registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-grafana-amd64:v5.0.4   更换镜像地址

ports:

- containerPort: 3000

protocol: TCP

volumeMounts:

- mountPath: /etc/ssl/certs

name: ca-certificates

readOnly: true

- mountPath: /var

name: grafana-storage

env:

- name: INFLUXDB_HOST

value: monitoring-influxdb

- name: GF_SERVER_HTTP_PORT

value: "3000"

# The following env variables are required to make Grafana accessible via

# the kubernetes api-server proxy. On production clusters, we recommend

# removing these env variables, setup auth for grafana, and expose the grafana

# service using a LoadBalancer or a public IP.

- name: GF_AUTH_BASIC_ENABLED

value: "false"

- name: GF_AUTH_ANONYMOUS_ENABLED

value: "true"

- name: GF_AUTH_ANONYMOUS_ORG_ROLE

value: Admin

- name: GF_SERVER_ROOT_URL

# If you're only using the API Server proxy, set this value instead:

# value: /api/v1/namespaces/kube-system/services/monitoring-grafana/proxy

value: /

volumes:

- name: ca-certificates

hostPath:

path: /etc/ssl/certs

- name: grafana-storage

emptyDir: {}

---

apiVersion: v1

kind: Service

metadata:

labels:

# For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)

# If you are NOT using this as an addon, you should comment out this line.

kubernetes.io/cluster-service: 'true'

kubernetes.io/name: monitoring-grafana

name: monitoring-grafana

namespace: kube-system

spec:

# In a production setup, we recommend accessing Grafana through an external Loadbalancer

# or through a public IP.

# type: LoadBalancer

# You could also use NodePort to expose the service at a randomly-generated port

# type: NodePort

ports:

- port: 80

targetPort: 3000

nodePort: 31600

selector:

k8s-app: grafana

type: NodePort

kubectl apply -f grafana.yaml

kubectl get pods -n kube-system

kubectl get svc -n kube-system

kubectl logs -n kube-system monitoring-grafana-6b5dd6459-24hsl

HeapSter部署的更多相关文章

  1. Kubernetes集群部署--kubernetes1.10.1

    参考博客:https://mritd.me/2018/04/19/set-up-kubernetes-1.10.1-cluster-by-hyperkube/ 一.环境 (1)系统环境 IP 操作系统 ...

  2. Kubernetes Heapster

    Heapster是容器集群监控和性能分析工具,HPA.Dashborad.Kubectl top都依赖于heapster收集的数据. 但是Heapster从kubernetes 1.8以后已经被遗弃了 ...

  3. kubernetes之管理容器的计算资源

    资源类型 CPU 和 memory 都是 资源类型.资源类型具有基本单位.CPU 的单位是 core,memory 的单位是 byte.这些都统称为计算资源. CPU含义: CPU 资源的限制和请求以 ...

  4. kubernets全套笔记

    Master/node Master核心组件: API server,Scheduler,Controller-Manager  etcd(存储组件) Node核心组件:  kubelet(核心组件) ...

  5. 部署k8s集群监控Heapster

    git clone https://github.com/kubernetes/heapster.gitkubectl apply -f heapster/deploy/kube-config/inf ...

  6. kubernetes1.30集群部署+dashboard+heapster

    v2.1 1.系统配置 1.1.禁用防火墙.禁用selinux #防火墙禁用 systemctl stop firewalld systemctl disable firewalld #SELinux ...

  7. kubernetes之部署dashboard 和heapster

    部署dashboard之前,先确保traefik https方式部署成功,这样就可以通过 https 域名的方式访问dashboard,无需kube-proxy转发了.假设traefik-ingres ...

  8. 部署k8s的heapster监控

    Heapster是容器集群监控和性能分析工具,天然的支持Kubernetes和CoreOS heapster监控目前官网已经不更新,部署学习使用 heapster: 收集监控数据 influxdb:数 ...

  9. 使用 kubeadm 安装部署 kubernetes 1.9-部署heapster插件

    1.先到外网下载好镜像倒进各个节点 2.下载yaml文件和创建应用 mkdir -p ~/k8s/heapster cd ~/k8s/heapster wget https://raw.githubu ...

  10. Kubernetes监控:部署Heapster、InfluxDB和Grafana

    本节内容: Kubernetes 监控方案 Heapster.InfluxDB和Grafana介绍 安装配置Heapster.InfluxDB和Grafana 访问 grafana 访问 influx ...

随机推荐

  1. 动态编译 Java 的神器 Liquor v1.3.10 发布

    Liquor 是一个开源的轻量级 Java 动态编译器(零依赖,40KB),它可以在运行时编译 Java 字符串代码片段.类.方法等. 源码地址:https://gitee.com/noear/liq ...

  2. NET中三种主机简单理解

    在NET中有三个不同的主机: .NET WebApplication 主机,也称为最小主机. 这是.NET 6中的一个新特性,旨在提供最小的启动时间和内存消耗.最小主机只包括.NET运行时的最基本组件 ...

  3. 『Python底层原理』--Python对象系统探秘

    Python是一种非常灵活的编程语言,它的灵活性很大程度上来自于它的对象系统. 在Python中,一切都是对象,这意味着无论是数字.字符串,还是我们自己定义的类的实例,它们在底层都遵循相同的规则. 本 ...

  4. thinkphp6实现仿微信朋友圈,用户可发布图片和文字内容,用户可评论,其他用户可评论文章,也可回复用户评论,多层级评论,无限级评论

    功能:仿微信朋友圈,用户可发布图片和文字内容,用户可评论,其他用户可评论文章,也可回复用户评论,多层级评论,无限级评论数据库示例:朋友圈内容表 article表:id content image li ...

  5. 使用PySide6/PyQt6实现Python跨平台表格数据分页打印预览处理

    我曾经在前面使用WxPython开发跨平台应用程序的时候,写了一篇<WxPython跨平台开发框架之列表数据的通用打印处理>,介绍在WxPython下实现表格数据分页打印处理的过程,在Wi ...

  6. css3 渐变边框如何实现圆角效果

    常规的 border-image 属性如果直接使用 border-radius 会无效,关于如何实现渐变边框圆角,网上流传着大概这么几种办法: 渐变背景方式(仅适用于纯底色背景) 借助 after 伪 ...

  7. idea 导入普通的项目后,无法发布

    之前一直都是在eclipse开发,现在改idea,但是很多隐藏的功能,都不晓得在哪里找到. 问题: 新导入一个spring 项目(没有maven),在界面上看是没有问题,但是使用tomcat部署项目的 ...

  8. Git Pull Failed:You have not concluded your merge.Exiting because of unfinished merge

    前言 在拉取远程代码时,出现 Git Pull Failed:You have not concluded your merge.Exiting because of unfinished merge ...

  9. OpnenHarmony 开源鸿蒙北向开发——2.第一个工程HelloWorld

    ​ 一.新建项目 我们打开IDE后,选择新建项目 选择这一个 设置参数 设置完成后选择Finish 项目创建后会自动下载一些东西,不用担心 二.运行 我们先什么都不用管,直接运行 先设置设备,我们这里 ...

  10. [Winform]在Form里显示模态对话框ModalDialog

    问题 如何在WinForm的一个Form里面弹出一个模态Dialog? 背景 程序的框架是Winform,只有一个窗口MainForm.MainForm里面是一个TabControl,每个TabPag ...