【kubernetes/k8s概念】kubelet启动参数

kubernetes version: v1.12.1

Desc

       The kubelet is the primary "node agent" that runs on each node. The kubelet works in terms of a PodSpec. A PodSpec is a YAML or JSON object that describes a pod. The kubelet takes a set of PodSpecs that are provided through various mechanisms (primarily through the apiserver) and ensures that the containers described in those PodSpecs are running and healthy. The kubelet doesn't manage containers which were not created by Kubernetes.

      Other than from an PodSpec from the apiserver, there are three ways that a container manifest can be provided to the Kubelet.

  • File: Path passed as a flag on the command line. Files under this path will be monitored periodically for updates. The monitoring period is 20s by default and is configurable via a flag.
  • HTTP endpoint: HTTP endpoint passed as a parameter on the command line. This endpoint is checked every 20 seconds (also configurable with a flag).
  • HTTP server: The kubelet can also listen for HTTP and respond to a simple API (underspec'd currently) to submit a new manifest.

启动命令行如下:

/usr/bin/kubelet \
  --address=10.12.51.171 \
  --hostname-override=10.12.51.171 \
  --pod-infra-container-image=harbor.local.com/images/pause-amd64:3.0 \
  --experimental-bootstrap-kubeconfig=/etc/kubernetes/bootstrap.kubeconfig \
  --kubeconfig=/etc/kubernetes/kubelet.kubeconfig \
  --cert-dir=/etc/kubernetes/ssl \
  --network-plugin=cni \
  --cni-conf-dir=/etc/cni/net.d \
  --cni-bin-dir=/usr/bin \
  --cluster-dns=10.254.0.2 \
  --cluster-domain=zqdlk8s.local. \
  --hairpin-mode hairpin-veth \
  --allow-privileged=true \
  --fail-swap-on=false \
  --logtostderr=true \
  --log-dir=/var/log/kubernetes/kubelet \
  --v=4 \
  --eviction-hard=memory.available<1024Mi,nodefs.available<10%,nodefs.inodesFree<5 \
  --system-reserved cpu=0.5,memory=1G

 

Kubelet启动参数详解

Usage:
  kubelet [flags]

--allow-privileged=true允许容器请求特权模式
--anonymous-auth=false

允许匿名请求到 kubelet 服务。未被另一个身份验证方法拒绝的请求被视为匿名请求。匿名请求包含系统的用户名: anonymous ,以及系统的组名: unauthenticated (默认 true )

--application-metrics-count-limit int每一个容器store最大application metrics(default 100)
--authentication-token-webhook-cache-ttl duration

webhook 令牌身份验证缓存响应时间 (2m0s)

--authorization-mode string

授权模式(AlwaysAllow/ Webhook),Webhook 模式使用 SubjectAccessReview API 来确定授权

--authorization-webhook-cache-authorized-ttl duration

webhook 模式认证响应缓存时间(default 5m0s)

--authorization-webhook-cache-unauthorized-ttl durationwebhook 模式认证未响应缓存时间(default 30s)
--authentication-token-webhook=true使用 TokenReview API 来确定不记名令牌的身份验证
--bootstrap-kubeconfig string

kubelet 客户端证书的kubeconfig 文件路径,如果指定的文件不存在,将

使用 bootstrap kubeconfig 从 API 服务器请求一个客户端证书,成功后生成证书文件和密钥的 kubeconfig 将被写入指定的文件,客户端证书和密钥将被保存在 --cert-dir 指定的目录

--cadvisor-port=0cAdvisor 端口(默认 4194)
 --cert-dir string客户端证书和密钥将被保存在 --cert-dir 指定的目录
--cgroup-driver=cgroupfs可选值有cgroupfs和systemd(默认cgroupfs)与docker驱动一致
--cgroup-root string

对于 pods 的可选root cgroup

--cgroups-per-qos

开启创建 QoS cgroup 层级,

true 意味着创建顶级 QoS 和pod cgroups (默认 true)

--client-ca-file=/etc/kubernetes/ssl/ca.pem集群ca证书
--cluster-dns=10.10.10.10DNS 服务器的IP列表,逗号分隔
--cluster-domain=xxx.xxx集群域名, kubelet 将配置所有容器除了主机搜索域还将搜索当前域
--cni-bin-dir=/opt/cni/binCNI插件二进制文件路径
--cni-conf-dir=/etc/cni/net.dCNI插件配置文件的完整路径
--container-runtime string

容器运行时engine(docker / rkt)

 --cpu-cfs-quota

开启cpu cfs配额来对容器指定cpu限制(默认 true)

--cpu-cfs-quota-period duration设置cpu cfs配置周期值,cpu.cfs_period_us(default 100ms)

--enable-controller-attach-detach

开启attach detach controller来管理调度到该节点上的volume
--enforce-node-allocatable strings 默认为pods,要为kube组件和System进程预留资源,则需要设置为pods,kube-reserved,system-reserve
--event-burst int32

突发事件记录的最大值

--eviction-hard mapStringString驱逐阈值的集合,达到该阈值将触发一次容器驱逐(default imagefs.available<15%,memory.available<100Mi,nodefs.available<10%,nodefs.inodesFree<5%)
--eviction-max-pod-grace-period int32当满足软驱逐阈值而终止pod时所允许的最长宽限期(秒)如果为负数,则推迟到pod指定的值
--eviction-minimum-reclaim=memory.available=0Mi,nodefs.available=500Mi,imagefs.available=2Gikubelet 压力较大时 ,执行 pod 驱逐回收的资源最小值
--eviction-soft=memory.available<1.5Gi驱逐阈值的集合,如果达到一个清理周期将触发一次容器驱逐
--eviction-soft-grace-period=memory.available=300s,nodefs.available=300s,nodefs.inodesFree=300s驱逐周期的集合,在触发一个容器清理之前一个软清理阈值需要保持多久
--fail-swap-on如果设置为true则启动kubelet失败(default true)

--hairpin-mode string                       (符合值为promiscuous-bridge / hairpin-veth)

nat hairpin也可以叫端口回流或者NAT回环(default "promiscuous-bridge")

--healthz-bind-address ip

健康检查服务的IP地址(默认 127.0.0.1 )

--healthz-port int32

本地健康检查服务的端口号(默认 10248 )

--host-ipc-sources strings

允许 pod 使用宿主机 ipc 命名空间列表(default [*])

--host-network-sources strings允许 pod 使用宿主机 net 命名空间列表(default [*])
--host-pid-sources strings允许 pod 使用宿主机 pid 命名空间列表(default [*])
--hostname-override=xxxcluster中的node name

--http-check-frequency duration

通过 http 检查新数据的周期(default 20s)

--image-gc-high-threshold int32

磁盘使用率最大值,超过此值将执行镜像垃圾回收(default 85)

--image-gc-low-threshold int32磁盘使用率最大值,

低于此值将停止镜像垃圾回收

(default 80)
--image-pull-progress-deadline=10m镜像拉取进度最大时间,如果在这段时间拉取镜像没有任何进展,将取消拉取(默认 1m0s)
 --iptables-drop-bit int32

用于标记丢弃数据包的 fwmark  bit,取值范围[0,31](default 15)

--iptables-masquerade-bit int32

标记 SNAT 数据包的 fwmark bit,取值范围[0,31],此参数与 kube-proxy 中的相应参数匹配(default 14)

--kube-api-burst=30与 kubernetes apiserver 会话时的并发数(默认 10)
--kube-api-qps=15与 kubernetes apiserver 会话时的 QPS (默认 15)
--kube-reserved mapStringString

资源预留量,(例如cpu=200m,memory=500Mi, storage=1Gi ),针对

kubernetes 系统组件

 

--kubeconfig=/etc/kubernetes/kubelet.kubeconfig用来指定如何连接到 API server
--log-dir=/var/log/kubernetes日志文件路径
--logtostderr=false日志信息输出到stderr 而不是文件
--max-pods=300可以运行的容器组数目(默认 110)
--network-plugin=cni使用cni插件
--node-ip=10.x.x.x节点的IP地址,kubelet 将使用这个地址作为节点ip地址,主要针对多网卡
--node-labels=env=test加入集群时贴上标签
--pod-infra-container-image=每个 pod 中的 network/ipc 命名空间容器将使用的pause镜像
--pod-manifest-path=/etc/kubernetes/manifests 
--register-with-taints=env=test:NoSchedule加入集群时自带的taint,用于防止node刚加入集群时会有容器调度到新机器上
--root-dir=/var/lib/k8s/kubeletkubelet 的工作目录
--registry-burst=10拉取镜像的最大并发数,允许同时拉取的镜像数,不能超过 registry-qps ,仅当 --registry-qps 大于 0 时使用(默认 10)
--serialize-image-pulls=false禁止一次只拉取一个镜像
--stderrthreshold=3 
--system-reserved=cpu=4,memory=5Gi系统预留资源
--tls-cert-file=/etc/kubernetes/pki/kubelet.crt用于 https 服务的 x509 证书的文件 (中间证书,如果有,在服务器认证后使用)。如果没有提供 --tls-cert-file 和 --tls-private-key-file , 将会生产一个自签名的证书及密钥给公开地址使用,并将其保存在 --cert-dir 指定的目录。
--tls-private-key-file=/etc/kubernetes/pki/kubelet.key包含 x509 私钥匹配的文件
--v=4日志级别

--address 0.0.0.0

服务监听的IP地址(默认 0.0.0.0 为 0.0.0.0 监听所有地址)

  

dsf

 

 

 

 

 

Kubelet Node Allocatable

Capacity:
 cpu:                1
 ephemeral-storage:  17397Mi
 hugepages-2Mi:      0
 memory:             2840764Ki
 pods:               110
Allocatable:
 cpu:                1
 ephemeral-storage:  16417868978
 hugepages-2Mi:      0
 memory:             2738364Ki
 pods:               110

 

  • --enforce-node-allocatable,默认为pods,为kube组件和System进程预留资源,设置为pods,kube-reserved,system-reserve
  • --cgroups-per-qos,Enabling QoS and Pod level cgroups,默认开启。开启后,kubelet会将管理所有workload Pods的cgroups。
  • --kube-reserved,为kube组件(kubelet,kube-proxy,dockerd等)预留的资源量,比如—kube-reserved=cpu=1000m,memory=8Gi,ephemeral-storage=16Gi。
  • --kube-reserved-cgroup,如果设置--kube-reserved,一定要设置对应的cgroup,并且该cgroup目录要事先创建好,否则kubelet将不会自动创建导致kubelet启动失败。比如为kube-reserved-cgroup=/kubelet.service 
  • --system-reserved,为System进程预留的资源量,比如—system-reserved=cpu=500m,memory=4Gi,ephemeral-storage=4Gi。
  • --system-reserved-cgroup,如果设置--system-reserved,一定要设置对应的cgroup,并且该cgroup目录要事先创建好,否则kubelet将不会自动创建导致kubelet启动失败。比如为system-reserved-cgroup=/system.slice
  • --eviction-hard,配置 kubelet的hard eviction 条件,只支持memory和ephemeral-storage两种不可压缩资源。当出现MemoryPressure时,Scheduler不会调度新的Best-Effort QoS Pods到此节点。当出现DiskPressure时,Scheduler不会调度任何新Pods到此节点
--enforce-node-allocatable=pods,kube-reserved,system-reserved
--kube-reserved-cgroup=/kubelet.service
--system-reserved-cgroup=/system.slice
--kube-reserved=cpu=1,memory=2Gi,ephemeral-storage=1Gi
--system-reserved=cpu=500m,memory=1Gi,ephemeral-storage=1Gi
--eviction-hard=memory.available<500Mi,nodefs.available<10%

      NodeAllocatable = NodeCapacity - Kube-reserved - system-reserved - eviction-threshold

 

       Scheduler会确保Node上所有的Pod Resource Request不超过NodeAllocatable。Pods所使用的memory和storage之和超过NodeAllocatable后就会触发kubelet Evict Pods

 

       kube-reserved设置的cpu其实最终是写到kube-reserved-cgroup下面的cpu shares

 

      在Kubernetes 1.8版本,kubelet启动会检查cgroup subsystem:cpu、cpuacct、cpuset、memory、systemd。所以需要确保这些cgroup目录的存在

mkdir -p /sys/fs/cgroup/cpu/system.slice/kubelet.service
mkdir -p /sys/fs/cgroup/cpuacct/system.slice/kubelet.service
mkdir -p /sys/fs/cgroup/cpuset/system.slice/kubelet.service
mkdir -p /sys/fs/cgroup/memory/system.slice/kubelet.service
mkdir -p /sys/fs/cgroup/systemd/system.slice/kubelet.service

 

 

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值