← 返回命令列表

Linux command

kubeadm 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Initialize control plane

sudo kubeadm init

Join worker node

sudo kubeadm join [control-plane:6443] --token [token] --discovery-token-ca-cert-hash [hash]

Create join token

kubeadm token create --print-join-command

Reset node

sudo kubeadm reset

Upgrade cluster

sudo kubeadm upgrade apply [v1.28.0]

Generate default config

kubeadm config print init-defaults

说明

kubeadm is the official Kubernetes cluster bootstrapping tool that automates the setup of a production-grade control plane. It handles the complex initialization process including generating TLS certificates for cluster components, configuring the kubelet, deploying the kube-apiserver, kube-controller-manager, and kube-scheduler as static pods, and installing cluster-essential add-ons like CoreDNS and kube-proxy. The workflow centers on two primary commands: `kubeadm init` to create a new control plane on the first node, and `kubeadm join` to add worker nodes or additional control plane nodes to an existing cluster using bootstrap tokens. The tool also manages cluster lifecycle operations such as upgrading Kubernetes versions across the cluster, rotating certificates, and resetting nodes back to a clean state. kubeadm follows Kubernetes best practices and conformance standards, but intentionally does not provision the underlying infrastructure or install a CNI network plugin, keeping it focused on cluster bootstrapping while remaining composable with other tools for complete cluster management.

参数

init
Initialize control plane.
join _ENDPOINT_
Join cluster as node.
reset
Reset node to pre-init state.
upgrade
Upgrade cluster components.
token _CMD_
Manage join tokens.
config _CMD_
Manage configuration.
--help
Display help information.

FAQ

What is the kubeadm command used for?

kubeadm is the official Kubernetes cluster bootstrapping tool that automates the setup of a production-grade control plane. It handles the complex initialization process including generating TLS certificates for cluster components, configuring the kubelet, deploying the kube-apiserver, kube-controller-manager, and kube-scheduler as static pods, and installing cluster-essential add-ons like CoreDNS and kube-proxy. The workflow centers on two primary commands: `kubeadm init` to create a new control plane on the first node, and `kubeadm join` to add worker nodes or additional control plane nodes to an existing cluster using bootstrap tokens. The tool also manages cluster lifecycle operations such as upgrading Kubernetes versions across the cluster, rotating certificates, and resetting nodes back to a clean state. kubeadm follows Kubernetes best practices and conformance standards, but intentionally does not provision the underlying infrastructure or install a CNI network plugin, keeping it focused on cluster bootstrapping while remaining composable with other tools for complete cluster management.

How do I run a basic kubeadm example?

Run `sudo kubeadm init` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does init do in kubeadm?

Initialize control plane.