Kubernetes探祕—kubelet的配置參數

kubelet是Kubernetes中的核心組件,須要在每個節點安裝,也是kubernetes集羣啓動的第一個服務。kubelet的參數存放在多個目錄,修改時若是不完整就會致使各類錯誤,下面咱們kubelet的參數存放位置和配置方法一探究竟。node

在Ubuntu18.04上kubelet是使用宿主機的systemd來啓動的,目前kubernetes 1.12.3爲止都尚未將其容器化。git

kubelet的配置參數存放在三個不一樣的目錄:github

  • /etc/kubernetes,kubenetes主目錄,其中kubelet.conf包括apiserver鏈接參數和鏈接證書。
  • /lib/systemd/system/kubelet.service,kubelet服務的配置文件。
  • /var/lib/kubelet,kubelet的數據目錄。

kubelet主數據目錄參數

位於/var/lib/kubelet,包含本機由kubelet管理的全部資源。web

supermap@podc01:/var/lib/kubelet$ tree
.
├── config.yaml
├── cpu_manager_state
├── device-plugins
│   ├── DEPRECATION
│   ├── kubelet_internal_checkpoint
│   └── kubelet.sock
├── kubeadm-flags.env
├── pki
│   ├── kubelet-client-2018-11-23-10-08-12.pem
│   ├── kubelet-client-2018-11-23-10-08-38.pem
│   ├── kubelet-client-current.pem -> /var/lib/kubelet/pki/kubelet-client-2018-11-23-10-08-38.pem
│   ├── kubelet.crt
│   └── kubelet.key
├── plugin-containers [error opening dir]
├── plugins [error opening dir]
├── plugins_registry [error opening dir]
├── pod-resources [error opening dir]
└── pods [error opening dir]

7 directories, 11 files

其中config.yaml的內容以下:api

address: 10.1.1.201
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
  anonymous:
    enabled: false
  webhook:
    cacheTTL: 2m0s
    enabled: true
  x509:
    clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
  mode: Webhook
  webhook:
    cacheAuthorizedTTL: 5m0s
    cacheUnauthorizedTTL: 30s
cgroupDriver: cgroupfs
cgroupsPerQOS: true
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
configMapAndSecretChangeDetectionStrategy: Watch
containerLogMaxFiles: 5
containerLogMaxSize: 10Mi
contentType: application/vnd.kubernetes.protobuf
cpuCFSQuota: true
cpuCFSQuotaPeriod: 100ms
cpuManagerPolicy: none
cpuManagerReconcilePeriod: 10s
enableControllerAttachDetach: true
enableDebuggingHandlers: true
enforceNodeAllocatable:
- pods
eventBurst: 10
eventRecordQPS: 5
evictionHard:
  imagefs.available: 15%
  memory.available: 100Mi
  nodefs.available: 10%
  nodefs.inodesFree: 5%
evictionPressureTransitionPeriod: 5m0s
failSwapOn: true
fileCheckFrequency: 20s
hairpinMode: promiscuous-bridge
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 20s
imageGCHighThresholdPercent: 85
imageGCLowThresholdPercent: 80
imageMinimumGCAge: 2m0s
iptablesDropBit: 15
iptablesMasqueradeBit: 14
kind: KubeletConfiguration
kubeAPIBurst: 10
kubeAPIQPS: 5
makeIPTablesUtilChains: true
maxOpenFiles: 1000000
maxPods: 110
nodeLeaseDurationSeconds: 40
nodeStatusUpdateFrequency: 10s
oomScoreAdj: -999
podPidsLimit: -1
port: 10250
registryBurst: 10
registryPullQPS: 5
resolvConf: /etc/resolv.conf
rotateCertificates: true
runtimeRequestTimeout: 2m0s
serializeImagePulls: true
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 4h0m0s
syncFrequency: 1m0s
volumeStatsAggPeriod: 1m0s
  • 注意:
    • 其中添加了node-ip: 10.1.1.201,指定啓動的節點IP地址,對於有多個網卡的服務器能夠經過該參數指定kubelet服務綁定的IP地址。
    • 在etcd.yaml中,指定hostIP: 10.1.1.201\podIP: 10.1.1.201爲該pod的發起IP。

更多參考

相關文章
相關標籤/搜索