一条指令搞定,
kubeadm init phase kubeconfig admin
如果有多个网卡,需要用–apiserver-advertise-address指定apiserver监听地址,证书地址可以用–cert-dir指定,默认/etc/kubernetes/pki,生成的admin.conf默认为/etc/kubernetes/admin.conf
[root@master ~]# kubeadm init phase kubeconfig admin --help
Generate the kubeconfig file for the admin and for kubeadm itself, and save it to admin.conf file.
Usage:
kubeadm init phase kubeconfig admin [flags]
Flags:
--apiserver-advertise-address string The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.
--apiserver-bind-port int32 Port for the API Server to bind to. (default 6443)
--cert-dir string The path where to save and store the certificates. (default "/etc/kubernetes/pki")
--config string Path to a kubeadm configuration file.
--control-plane-endpoint string Specify a stable IP address or DNS name for the control plane.
-h, --help help for admin
--kubeconfig-dir string The path where to save the kubeconfig file. (default "/etc/kubernetes")
--kubernetes-version string Choose a specific Kubernetes version for the control plane. (default "stable-1")
Global Flags:
--add-dir-header If true, adds the file directory to the header of the log messages
--log-file string If non-empty, use this log file
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--one-output If true, only write logs to their native severity level (vs also writing to each lower severity level)
--rootfs string [EXPERIMENTAL] The path to the 'real' host root filesystem.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
-v, --v Level number for the log level verbosity