内容简介:任何的Kubernetes运行容器都应该设置资源的申请。限制的设定需要根据业务情况决定,防止容器无限制地消耗资源影响同一节点上的其他容器。资源申请及限制示例:不同的应用对于资源的要求会不一样,可以通过
任何的Kubernetes运行容器都应该设置资源的申请。限制的设定需要根据业务情况决定,防止容器无限制地消耗资源影响同一节点上的其他容器。资源申请及限制示例:
apiVersion: v1 kind: Service metadata: name : kafka namespace: infra labels: app: "kafka" annotations: service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" spec: ports: - name: broker port: 9092 clusterIP: None selector: app: "kafka" --- apiVersion: apps/v1beta1 kind: StatefulSet metadata: name : kafka namespace: infra labels: app: "kafka" spec: serviceName: kafka replicas: 3 template: metadata: labels: app: "kafka" spec: nodeSelector: nodezone: b imagePullSecrets: - name: regsecret containers: - name : kafka-broker image: "loads/kafka:2.1.0" imagePullPolicy: "Always" livenessProbe: exec: command: - bin/kafka-topics.sh - --zookeeper - "zookeeper:2181" - --list initialDelaySeconds: 20 timeoutSeconds: 5 readinessProbe: exec: command: - bin/kafka-topics.sh - --zookeeper - "zookeeper:2181" - --list initialDelaySeconds: 10 timeoutSeconds: 5 ports: - containerPort: 9092 name: kafka resources: requests: cpu : 5000m memory: 8000Mi requests: cpu : 1000m memory: 2000Mi
不同的应用对于资源的要求会不一样,可以通过 kubectltop 指令查看运行的pod资源使用信息,并根据真实的资源使用情况逐步调整完善配置文件的资源申请信息。例如:
ijohn:~ john$ kubectl top pod -n log NAME CPU(cores) MEMORY(bytes) log-agent-2rfkw 148m 508Mi log-agent-9mr4z 193m 672Mi log-agent-kzpd6 230m 762Mi log-agent-vk7b4 162m 681Mi log-archiver-66ccb7dd7b-4wpl7 3m 7Mi log-cleaner-5966f8cd55-vz8w7 0m 2Mi log-dumper-9b9d8dc5-b9vzv 398m 3773Mi log-kafka-0 1518m 8829Mi log-kafka-1 1341m 4480Mi log-kafka-2 874m 7426Mi log-zookeeper-0 6m 497Mi log-zookeeper-1 6m 509Mi log-zookeeper-2 7m 510Mi ijohn:~ john$
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 在Android上优雅的申请权限
- Comodo Positive SSL申请过程
- CodingPages申请SSL/TLS证书错误
- Android开发 - 更"聪明"的申请权限方式
- App申请安卓系统权限机制分析与建议
- 如何免费申请js.org二级域名
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Java in a Nutshell, 6th Edition
Benjamin J Evans、David Flanagan / O'Reilly Media / 2014-10 / USD 59.99
The latest edition of Java in a Nutshell is designed to help experienced Java programmers get the most out of Java 7 and 8, but it's also a learning path for new developers. Chock full of examples tha......一起来看看 《Java in a Nutshell, 6th Edition》 这本书的介绍吧!