|NO.Z.00034|——————————|^^ 部署 ^^|——|KuberNetes&二进制部署.V12|5台Server|——|kubernetes-node|kubelet配置|
一、node节点组件配置
### --- 复制证书
~~~ 从k8s-master01节点复制证书到node节点
### --- 进入证书目录下
[root@k8s-master01 bootstrap]# cd /etc/kubernetes/
### --- 将需要的证书复制到node节点下
[root@k8s-master01 kubernetes]# for NODE in k8s-master02 k8s-master03 k8s-node01 k8s-node02; do
ssh $NODE mkdir -p /etc/kubernetes/pki /etc/etcd/ssl /etc/etcd/ssl
for FILE in etcd-ca.pem etcd.pem etcd-key.pem; do
scp /etc/etcd/ssl/$FILE $NODE:/etc/etcd/ssl/
done
for FILE in pki/ca.pem pki/ca-key.pem pki/front-proxy-ca.pem bootstrap-kubelet.kubeconfig; do
scp /etc/kubernetes/$FILE $NODE:/etc/kubernetes/${FILE}
done
done
~~~ 注:输出结果:
etcd-ca.pem 100% 1367 31.4KB/s 00:00
etcd.pem 100% 1509 767.7KB/s 00:00
etcd-key.pem 100% 1679 629.8KB/s 00:00
ca.pem 100% 1411 316.4KB/s 00:00
ca-key.pem 100% 1679 953.2KB/s 00:00
front-proxy-ca.pem 100% 1143 308.3KB/s 00:00
bootstrap-kubelet.kubeconfig 100% 2299 517.1KB/s 00:00
etcd-ca.pem 100% 1367 1.0MB/s 00:00
etcd.pem 100% 1509 886.9KB/s 00:00
etcd-key.pem 100% 1679 940.7KB/s 00:00
ca.pem 100% 1411 500.9KB/s 00:00
ca-key.pem 100% 1679 505.2KB/s 00:00
front-proxy-ca.pem 100% 1143 351.2KB/s 00:00
bootstrap-kubelet.kubeconfig
二、kubelet配置
### --- 所有node节点创建配置需要目录
~~~ # 创建node节点部署目录
[root@k8s-master01 kubernetes]# mkdir -p /var/lib/kubelet /var/log/kubernetes /etc/systemd/system/kubelet.service.d /etc/kubernetes/manifests/
### --- 所有node节点配置kubelet service
~~~ # 创建kubelet.service配置文件
[root@k8s-master01 ~]# vim /usr/lib/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/kubernetes/kubernetes
After=docker.service
Requires=docker.service
[Service]
ExecStart=/usr/local/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10
[Install]
WantedBy=multi-user.target
### --- 所有节点10-kubelet.conf配置文件下配置kubelet.service参数
~~~ # 所有节点10-kubelet.conf下配置kubelet.service参数
[root@k8s-master01 ~]# vim /etc/systemd/system/kubelet.service.d/10-kubelet.conf
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.kubeconfig --kubeconfig=/etc/kubernetes/kubelet.kubeconfig"
Environment="KUBELET_SYSTEM_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin"
Environment="KUBELET_CONFIG_ARGS=--config=/etc/kubernetes/kubelet-conf.yml --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2"
Environment="KUBELET_EXTRA_ARGS=--node-labels=node.kubernetes.io/node='' "
ExecStart=
ExecStart=/usr/local/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_SYSTEM_ARGS $KUBELET_EXTRA_ARGS
### --- 创建kubelet配置文件
~~~ # 注意:如果更改了k8s的service网段,需要更改kubelet-conf.yml 的clusterDNS:配置,
~~~ # 改成k8s Service网段的第十个地址,比如10.96.0.10
~~~ # 创建kubelet.conf配置文件
[root@k8s-master01 bootstrap]# vim /etc/kubernetes/kubelet-conf.yml
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
address: 0.0.0.0
port: 10250
readOnlyPort: 10255
authentication:
anonymous:
enabled: false
webhook:
cacheTTL: 2m0s
enabled: true
x509:
clientCAFile: /etc/kubernetes/pki/ca.pem
authorization:
mode: Webhook
webhook:
cacheAuthorizedTTL: 5m0s
cacheUnauthorizedTTL: 30s
cgroupDriver: systemd
cgroupsPerQOS: true
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
containerLogMaxFiles: 5
containerLogMaxSize: 10Mi
contentType: application/vnd.kubernetes.protobuf
cpuCFSQuota: true
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
kubeAPIBurst: 10
kubeAPIQPS: 5
makeIPTablesUtilChains: true
maxOpenFiles: 1000000
maxPods: 110
nodeStatusUpdateFrequency: 10s
oomScoreAdj: -999
podPidsLimit: -1
registryBurst: 10
registryPullQPS: 5
resolvConf: /etc/resolv.conf
rotateCertificates: true
runtimeRequestTimeout: 2m0s
serializeImagePulls: true
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 4h0m0s
syncFrequency: 1m0s
volumeStatsAggPeriod: 1m0s
三、启动kubelet并查看日志
### --- 启动所有节点kubelet并设置开机自启动
~~~ # 启动kubelet服务并设置开机自启动
[root@k8s-master01 ~]# systemctl daemon-reload
[root@k8s-master01 ~]# systemctl enable --now kubelet
Created symlink from /etc/systemd/system/multi-user.target.wants/kubelet.service to /usr/lib/systemd/system/kubelet.service.
[root@k8s-master01 ~]# systemctl status kubelet
### --- 查看系统日志
~~~ # 此时系统日志/var/log/messages
~~~ Unable to update cni config: no networks found in /etc/cni/net.d
~~~ 显示只有如下信息为正常
四、查看集群状态
### --- 查看集群状态
[root@k8s-master01 ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
k8s-master01 NotReady <none> 2m27s v1.20.0
k8s-master02 NotReady <none> 2m27s v1.20.0
k8s-master03 NotReady <none> 2m29s v1.20.0
k8s-node01 NotReady <none> 119s v1.20.0
k8s-node02 NotReady <none> 111s v1.20.0
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构