kubeadm初始化集群时配置kubelet组件

493次阅读
没有评论

共计 3398 个字符,预计需要花费 9 分钟才能阅读完成。

kubeadm初始化集群时配置kubelet组件

使用kubeadm初始化集群时,可以在kubeadm配置文件中声明一些组件的参数来初始化,从而减少后续运维过程多次修改组件参数导致集群不稳定的影响。此处记录下在kubeadm中的kubelet的配置

KubeletConfiguration

KubeProxyConfiguration 类型用来更改传递给在集群中部署的 kube-proxy 实例的配置。 如果此对象没有提供,或者仅部分提供,kubeadm 将使用默认值

查看kubeadm生成的默认配置中也没有KubeletConfiguration的声明

[root@k8s-master ~]# kubeadm config print init-defaults
W0219 15:26:56.929815   98025 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
apiVersion: kubeadm.k8s.io/v1beta2
bootstrapTokens:
- groups:
  - system:bootstrappers:kubeadm:default-node-token
  token: abcdef.0123456789abcdef
  ttl: 24h0m0s
  usages:
  - signing
  - authentication
kind: InitConfiguration
localAPIEndpoint:
  advertiseAddress: 1.2.3.4
  bindPort: 6443
nodeRegistration:
  criSocket: /var/run/dockershim.sock
  name: k8s-master
  taints:
  - effect: NoSchedule
    key: node-role.kubernetes.io/master
---
apiServer:
  timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
  type: CoreDNS
etcd:
  local:
    dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.18.0
networking:
  dnsDomain: cluster.local
  serviceSubnet: 10.96.0.0/12
scheduler: {}

博主这里在用kubeadm初始集群时也没有定义KubeletConfiguration的配置

[root@k8s-master ~]# cat kubeadm-config.yaml
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: v1.18.9
imageRepository: registry.aliyuncs.com/k8sxio
controlPlaneEndpoint: "apiserver.demo:6443"
networking:
  serviceSubnet: "10.96.0.0/16"
  podSubnet: "10.100.0.1/16"
  dnsDomain: "cluster.local"

增加KubeletConfiguration配置

该配置文件在声明初始化集群后,会在kubelet启动时挂载到/var/lib/kubelet/config.yaml,所以直接不会写的读者可以参考这个文件来写

[root@k8s-master ~]# cat /var/lib/kubelet/config.yaml
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
  anonymous:
    enabled: false
  webhook:
    cacheTTL: 0s
    enabled: true
  x509:
    clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
  mode: Webhook
  webhook:
    cacheAuthorizedTTL: 0s
    cacheUnauthorizedTTL: 0s
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 10s
evictionPressureTransitionPeriod: 30s
evictionSoft:
  memory.available: 512Mi
evictionHard:
  memory.available: 256Mi
evictionSoftGracePeriod:
   memory.available: 30s
fileCheckFrequency: 10s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 60s
imageMinimumGCAge: 129600s
kind: KubeletConfiguration
nodeStatusReportFrequency: 60s
maxPods: 80
nodeStatusUpdateFrequency: 10s
rotateCertificates: true
runtimeRequestTimeout: 30s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 15m
syncFrequency: 60s
volumeStatsAggPeriod: 60s

参考上面一些配置来生成一份kubeadm集群配置文件

[root@k8s-master ~]# cat kubeadm-config.yaml
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: v1.18.9
imageRepository: registry.aliyuncs.com/k8sxio
controlPlaneEndpoint: "apiserver.demo:6443"
networking:
  serviceSubnet: "10.96.0.0/16"
  podSubnet: "10.100.0.1/16"
  dnsDomain: "cluster.local"
---
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cpuManagerReconcilePeriod: 10s
evictionPressureTransitionPeriod: 30s
evictionSoft:
  memory.available: 512Mi
evictionHard:
  memory.available: 256Mi
evictionSoftGracePeriod:
   memory.available: 30s
fileCheckFrequency: 10s
httpCheckFrequency: 60s
imageMinimumGCAge: 129600s
nodeStatusReportFrequency: 60s
maxPods: 80
nodeStatusUpdateFrequency: 10s
rotateCertificates: true
runtimeRequestTimeout: 30s
streamingConnectionIdleTimeout: 15m
syncFrequency: 60s
volumeStatsAggPeriod: 60s

参考文档:

正文完
 
xadocker
版权声明:本站原创文章,由 xadocker 2020-12-19发表,共计3398字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)