Toggle navigation
主页
English
K8S
Golang
Guitar
About Me
归档
标签
Welcome to Sanger's Blog!
K8S request和limit
K8S
2024-01-10 17:34:36
24
0
0
sanger
K8S
[TOC] # 背景 近期dev环境资源比较紧张,需要开发deployment配置做下改变 # request和limit Requests: 就是需求限制,也叫软限制 Limits:最大限制,也叫硬限制 通常来说:Limits >= Requests 并且requests 和 limits 通常要一起配置,若只配置了requests,而不配置limits,则很可能导致Pod会吃掉所有资源。 # 配置修改 ## 命令行修改 ``` kubectl set resources deployment test --limits=cpu=50m,memory=64Mi -n test ``` ## 从文件修改 ``` apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: app: test name: test namespace: test spec: minReadySeconds: 10 progressDeadlineSeconds: 600 replicas: 1 # 如无特殊需求,尽量做1副本 revisionHistoryLimit: 10 selector: matchLabels: app: test version: v1 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 type: RollingUpdate template: metadata: creationTimestamp: null labels: app: test version: v1 namespace: test spec: containers: - args: - nohup ./test -conf /test/config/config.json command: - /bin/sh - -c env: - name: JAEGER_AGENT_HOST valueFrom: fieldRef: apiVersion: v1 fieldPath: status.hostIP image: reg.sanger.cc/test/xxx:v1 imagePullPolicy: Always lifecycle: preStop: exec: command: - /bin/sleep - "20" name: test resources: limits: # 自己设定最大的限制 cpu: 200m memory: 256Mi requests: # 修改为0 cpu: 0 memory: 0 terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /data/logs name: logs - mountPath: /test/config name: config dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 60 volumes: - hostPath: path: /data/logs type: "" name: logs - configMap: defaultMode: 420 name: test-config name: config ```
上一篇:
Ingress
下一篇:
ACK专有集群手动签发替换Apiserver证书指导
0
赞
24 人读过
新浪微博
微信
更多分享
腾讯微博
QQ空间
人人网
文档导航