找回密码
 注册
查看: 13|回复: 0

kubeadm reset 集群以及kubeadm init 使用config文件重新初始化kubernetes集群

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2025-1-6 02:00:01 | 显示全部楼层 |阅读模式
kubernets先重置配置reset 1 y6 Z5 @. |  N
[root@k8s-master ~]# kubeadm reset --v=5 --cri-socket=unix:///var/run/cri-dockerd.sock
6 A; M' q- y1 B, d5 w. a: zI0103 22:43:08.557654   83642 reset.go:126] [reset] Could not obtain a client set from the kubeconfig file: /etc/kubernetes/admin.conf
7 u. c3 c4 H: z+ @8 pW0103 22:43:08.557782   83642 preflight.go:56] [reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
% G2 I: R* P3 ]+ m, f  ?8 Q  J+ l[reset] Are you sure you want to proceed? [y/N]: Y
' H, x4 O' U  O8 `; i2 ^  }* X6 M[preflight] Running pre-flight checks. |6 A0 J. \; Y6 ~$ Y
I0103 22:43:13.735565   83642 removeetcdmember.go:60] [reset] Checking for etcd config
1 s# \5 s; D% j" W( bW0103 22:43:13.735621   83642 removeetcdmember.go:106] [reset] No kubeadm config, using etcd pod spec to get data directory
! ^% ]# ^- k" rI0103 22:43:13.735774   83642 cleanupnode.go:65] [reset] Getting init system
0 Q- I+ ]7 O0 v, U- P" T; O[reset] Stopping the kubelet service& O, [$ j: B1 W( J
[reset] Unmounting mounted directories in "/var/lib/kubelet"* A% ]* s  o1 Q9 J6 d; V) F* ?6 S: W
I0103 22:43:13.743121   83642 cleanupnode.go:103] [reset] Removing Kubernetes-managed containers' }) N* x% w; b: ?+ l' F
[reset] Deleting contents of directories: [/etc/kubernetes/manifests /var/lib/kubelet /etc/kubernetes/pki]4 _. e! o! `. L1 A; w: X; Q
[reset] Deleting files: [/etc/kubernetes/admin.conf /etc/kubernetes/super-admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/bootstrap-kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf]# \( Z; s& ~" H+ a

5 B2 ~/ p; a9 r5 E- m4 p. YThe reset process does not clean CNI configuration. To do so, you must remove /etc/cni/net.d# K5 f; _. l) g/ Z% Z3 i
* ^  s9 J" E: r5 y6 P
The reset process does not reset or clean up iptables rules or IPVS tables.% S$ L! K5 }4 i+ f7 o- [4 S
If you wish to reset iptables, you must do so manually by using the "iptables" command.3 B9 D% _+ s" b+ _# R; ]  D% C+ h

) z/ C2 F6 H% UIf your cluster was setup to utilize IPVS, run ipvsadm --clear (or similar)
' g  B. W- S0 W( u' C& a; M$ rto reset your system's IPVS tables.) v: ]5 M3 I, g" s: y6 n+ c# e: [
1 F) d) {6 {% X0 o! Z/ n' Y
The reset process does not clean your kubeconfig files and you must remove them manually.
: `, N: K- x! m7 ]# GPlease, check the contents of the $HOME/.kube/config file.
8 o; |: P% k2 x' _8 \, w, A
  U3 A2 N1 ~7 A0 R7 `重新通过文件初始化:" B1 l! `& i; H$ y$ E, L. i
/ l5 b8 ~5 O1 a' Z6 {9 u+ T7 f
[root@k8s-master ~]# kubeadm init  --config=kubeadm-init-config.yaml  --v=5 --ignore-preflight-errors=SystemVerification ! g* _+ E# P+ _
I0104 08:21:57.040996    3326 initconfiguration.go:261] loading configuration from "kubeadm-init-config.yaml"* A( j& \2 D% \- \
I0104 08:21:57.044966    3326 kubelet.go:195] the value of KubeletConfiguration.cgroupDriver is empty; setting it to "systemd"
) s; ~: h2 e: t; I4 r2 g; S4 c[init] Using Kubernetes version: v1.31.0
% r' m- R! S& O: a9 u[preflight] Running pre-flight checks# d( G& a+ I5 q, V, D8 d6 M
I0104 08:21:57.050536    3326 checks.go:561] validating Kubernetes and kubeadm version- X  v* l3 E# L; T/ v6 I
I0104 08:21:57.050579    3326 checks.go:166] validating if the firewall is enabled and active2 u! E" M3 ?, b$ O
I0104 08:21:57.060446    3326 checks.go:201] validating availability of port 6443
0 I; [, }9 Y' ~  @I0104 08:21:57.060692    3326 checks.go:201] validating availability of port 10259
3 j4 d: n, L- ^I0104 08:21:57.060939    3326 checks.go:201] validating availability of port 102571 T7 ]. v( q9 d3 Q( b0 I' p% g
I0104 08:21:57.061025    3326 checks.go:278] validating the existence of file /etc/kubernetes/manifests/kube-apiserver.yaml
- }' p6 p3 e3 \5 h5 Z0 {( p9 DI0104 08:21:57.061056    3326 checks.go:278] validating the existence of file /etc/kubernetes/manifests/kube-controller-manager.yaml1 L7 e) G+ T& Z9 N5 Y  K
I0104 08:21:57.061107    3326 checks.go:278] validating the existence of file /etc/kubernetes/manifests/kube-scheduler.yaml
' y: b9 e6 \9 n% ^I0104 08:21:57.061147    3326 checks.go:278] validating the existence of file /etc/kubernetes/manifests/etcd.yaml
6 V) n7 x# N4 ^I0104 08:21:57.061183    3326 checks.go:428] validating if the connectivity type is via proxy or direct, ~" `' S. j+ @/ @# O/ [9 v
I0104 08:21:57.061246    3326 checks.go:467] validating http connectivity to first IP address in the CIDR
) Z* x, N5 L8 ^I0104 08:21:57.061353    3326 checks.go:467] validating http connectivity to first IP address in the CIDR
% u- B  S% X8 d: ]0 P$ H: Z0 rI0104 08:21:57.061375    3326 checks.go:102] validating the container runtime! s6 O. S' N3 h3 D- M
I0104 08:21:57.062389    3326 checks.go:637] validating whether swap is enabled or not# |9 s7 C! p& f3 n
I0104 08:21:57.062579    3326 checks.go:368] validating the presence of executable crictl
1 J' V  G8 e* q4 O8 E9 ~I0104 08:21:57.062652    3326 checks.go:368] validating the presence of executable conntrack6 n/ D* x4 v/ f) @6 P% i
I0104 08:21:57.062709    3326 checks.go:368] validating the presence of executable ip2 K3 E& I0 W) g+ _) s! x- r7 ^( `4 h
I0104 08:21:57.062777    3326 checks.go:368] validating the presence of executable iptables$ {+ j# E+ m2 s" A4 ]) u* A
I0104 08:21:57.062850    3326 checks.go:368] validating the presence of executable mount( Z* n" b6 T. m, E! i+ [. [/ @7 X
I0104 08:21:57.062979    3326 checks.go:368] validating the presence of executable nsenter. D3 v! F  L- j  k
I0104 08:21:57.063051    3326 checks.go:368] validating the presence of executable ethtool" [) g0 D  d: s2 X' X" p. S- }7 m% I, Q
I0104 08:21:57.063123    3326 checks.go:368] validating the presence of executable tc# t3 V/ t' z0 M9 g0 J
I0104 08:21:57.063178    3326 checks.go:368] validating the presence of executable touch3 g# a1 A( n7 {( A
I0104 08:21:57.063261    3326 checks.go:514] running all checks
! [& |4 f9 E+ Q$ k: _& g[preflight] The system verification failed. Printing the output from the verification:
, ^5 H3 s% f; C$ j' JKERNEL_VERSION: 4.18.16x86-4.18-16( c! c9 u! v$ i" Z3 }8 b0 P
OS: Linux
9 k7 {! K2 Y( M8 wCGROUPS_CPU: enabled
; z! K! b; T. D$ ICGROUPS_CPUACCT: enabled
1 ^% n- Z( p& L  lCGROUPS_CPUSET: enabled
: u5 T2 f4 |0 x. H$ V+ S4 A2 d  g: qCGROUPS_DEVICES: enabled2 Y& m! |! |1 l3 F& c6 H
CGROUPS_FREEZER: enabled8 i' v: G! l5 V+ b+ x2 M
CGROUPS_MEMORY: enabled5 k% r; @3 {2 Y
CGROUPS_PIDS: enabled  m+ B" K# l. {! m" [
CGROUPS_HUGETLB: enabled0 d; w! j" q/ O8 u/ h- u- H
CGROUPS_BLKIO: enabled. z7 |) y3 a0 Y4 p: e4 R! b& m
        [WARNING SystemVerification]: failed to parse kernel config: unable to load kernel module: "configs", output: "modprobe: FATAL: Module configs not found.\n", err: exit status 1# l* G$ n; B& k+ @6 ]
I0104 08:21:57.069077    3326 checks.go:399] checking whether the given node name is valid and reachable using net.LookupHost( D# T( _; Z3 c( G4 k. T
        [WARNING Hostname]: hostname "node" could not be reached
% j, i9 h  I; Z' s0 u        [WARNING Hostname]: hostname "node": lookup node on 202.106.0.20:53: no such host4 ]5 m- f3 u8 [6 t
I0104 08:21:57.075047    3326 checks.go:603] validating kubelet version
  c: e, A3 G0 H% c0 KI0104 08:21:57.148436    3326 checks.go:128] validating if the "kubelet" service is enabled and active, X% V0 P# L" p9 j- k$ R
I0104 08:21:57.159069    3326 checks.go:201] validating availability of port 10250
) j) R: o4 ~0 v/ k& ~% x+ p0 H5 o+ {I0104 08:21:57.159163    3326 checks.go:327] validating the contents of file /proc/sys/net/ipv4/ip_forward
; f2 k% s1 r' D/ y9 L9 w& UI0104 08:21:57.159232    3326 checks.go:201] validating availability of port 2379
3 p( O, X) R$ L/ g, \+ `* ZI0104 08:21:57.159292    3326 checks.go:201] validating availability of port 2380
2 e' B# F: w8 jI0104 08:21:57.159451    3326 checks.go:241] validating the existence and emptiness of directory /var/lib/etcd7 R/ q  P# F" }8 f3 x* o
[preflight] Pulling images required for setting up a Kubernetes cluster0 m& n4 K# j/ a5 g: ~
[preflight] This might take a minute or two, depending on the speed of your internet connection: D! M2 H7 Y9 y/ o4 h" h- I
[preflight] You can also perform this action beforehand using 'kubeadm config images pull'
- h  M2 ^5 M( M% w1 PI0104 08:21:57.162812    3326 checks.go:832] using image pull policy: IfNotPresent
( l2 _" J+ x. T" IW0104 08:21:57.163929    3326 checks.go:846] detected that the sandbox image "registry.k8s.io/pause:3.6" of the container runtime is inconsistent with that used by kubeadm.It is recommended to use "registry.aliyuncs.com/google_containers/pause:3.10" as the CRI sandbox image.4 A+ C, T7 ^0 q$ A& ~/ Y4 B
I0104 08:21:57.164932    3326 checks.go:871] pulling: registry.aliyuncs.com/google_containers/kube-apiserver:v1.31.09 w, Y7 h1 |0 L# t0 ?$ [' z
I0104 08:22:03.825498    3326 checks.go:871] pulling: registry.aliyuncs.com/google_containers/kube-controller-manager:v1.31.0
4 G% [# S: G. E4 jI0104 08:22:09.870677    3326 checks.go:871] pulling: registry.aliyuncs.com/google_containers/kube-scheduler:v1.31.0+ U* m# c; [8 }2 w( C
I0104 08:22:14.792245    3326 checks.go:871] pulling: registry.aliyuncs.com/google_containers/kube-proxy:v1.31.0. L5 g6 }" m, S+ a' K6 W, f
I0104 08:22:21.833498    3326 checks.go:871] pulling: registry.aliyuncs.com/google_containers/coredns:v1.11.3
: A- e3 @, e6 r2 S; h  B* qI0104 08:22:26.694562    3326 checks.go:871] pulling: registry.aliyuncs.com/google_containers/pause:3.10/ E6 C3 @0 X9 Q7 X' L9 t* B5 C
I0104 08:22:27.874314    3326 checks.go:871] pulling: registry.aliyuncs.com/google_containers/etcd:3.5.15-0
/ V7 X: u. A, k[certs] Using certificateDir folder "/etc/kubernetes/pki": ?+ U8 D/ {( J" H. k
I0104 08:22:38.609775    3326 certs.go:112] creating a new certificate authority for ca
! |& p" @; q2 G[certs] Generating "ca" certificate and key
1 H. I; q. H& I0 n: u; J$ nI0104 08:22:39.795060    3326 certs.go:473] validating certificate period for ca certificate
8 V, h9 E& _- c& Q[certs] Generating "apiserver" certificate and key
7 H9 i8 T% W% l9 }" e[certs] apiserver serving cert is signed for DNS names [kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local node] and IPs [172.29.16.1 1.2.3.4]
, N: S, N: F% ^  _$ x: Q[certs] Generating "apiserver-kubelet-client" certificate and key4 l* Z' ^0 z. K. v6 |
I0104 08:22:40.424934    3326 certs.go:112] creating a new certificate authority for front-proxy-ca0 I' l: u6 a% v, k0 f! Z! e
[certs] Generating "front-proxy-ca" certificate and key' k6 _9 X! t0 R
I0104 08:22:40.745566    3326 certs.go:473] validating certificate period for front-proxy-ca certificate
8 r4 f: X' v  P% k7 V[certs] Generating "front-proxy-client" certificate and key/ ^4 W) l. X; ~3 }( c
I0104 08:22:41.527532    3326 certs.go:112] creating a new certificate authority for etcd-ca3 l# \5 X; v1 F- x5 V
[certs] Generating "etcd/ca" certificate and key
" q% q, X5 m3 B8 gI0104 08:22:42.751929    3326 certs.go:473] validating certificate period for etcd/ca certificate- X* }& {4 i+ x) G) k" D
[certs] Generating "etcd/server" certificate and key6 g  P1 Y* ~1 z- X% Q7 M3 m/ X' G
[certs] etcd/server serving cert is signed for DNS names [localhost node] and IPs [1.2.3.4 127.0.0.1 ::1]0 H( m' }5 l% G- t9 ~# H8 F6 g
[certs] Generating "etcd/peer" certificate and key! b2 Z( p' O4 L, d  N9 z
[certs] etcd/peer serving cert is signed for DNS names [localhost node] and IPs [1.2.3.4 127.0.0.1 ::1]
6 D3 j0 l+ Y3 ?! y$ Z  \, e[certs] Generating "etcd/healthcheck-client" certificate and key
! O9 P4 x. w2 C! P( T[certs] Generating "apiserver-etcd-client" certificate and key8 w& N2 q7 [+ I$ a* j( @2 z* [" O
I0104 08:22:45.579717    3326 certs.go:78] creating new public/private key files for signing service account users% l5 [% _2 e) D
[certs] Generating "sa" key and public key# B) ^+ {; i; g& P
[kubeconfig] Using kubeconfig folder "/etc/kubernetes". E% Q7 @" z4 r6 }+ n
I0104 08:22:45.821509    3326 kubeconfig.go:111] creating kubeconfig file for admin.conf" ]  H) y9 _( y, F
[kubeconfig] Writing "admin.conf" kubeconfig file
' V' w0 S% D) L% Y( e5 AI0104 08:22:46.146568    3326 kubeconfig.go:111] creating kubeconfig file for super-admin.conf
6 p5 Q/ t, J; t7 P[kubeconfig] Writing "super-admin.conf" kubeconfig file8 M2 ?5 P/ A' q' j5 n
I0104 08:22:46.913876    3326 kubeconfig.go:111] creating kubeconfig file for kubelet.conf
2 v' Z; ?, U! D' e" c+ g! `; i[kubeconfig] Writing "kubelet.conf" kubeconfig file7 U' n6 m. |% q+ p5 K' f  W& J
I0104 08:22:47.189373    3326 kubeconfig.go:111] creating kubeconfig file for controller-manager.conf* H0 ]# p/ B6 Z) B" @% X
[kubeconfig] Writing "controller-manager.conf" kubeconfig file# G- r+ p' [6 [1 k: r
I0104 08:22:47.789782    3326 kubeconfig.go:111] creating kubeconfig file for scheduler.conf$ a9 B2 n; B. r+ B$ j' ~
[kubeconfig] Writing "scheduler.conf" kubeconfig file  z2 i* R# L: U4 x
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"3 Q& w; `# d2 D/ q. j. z' F2 h+ a
I0104 08:22:48.176199    3326 local.go:65] [etcd] wrote Static Pod manifest for a local etcd member to "/etc/kubernetes/manifests/etcd.yaml"$ t1 |0 C/ B' e% B, ]
[control-plane] Using manifest folder "/etc/kubernetes/manifests"! U9 G9 L" v4 S1 d5 ]( s
[control-plane] Creating static Pod manifest for "kube-apiserver"
, E3 d8 J( R( M6 m% UI0104 08:22:48.176664    3326 manifests.go:103] [control-plane] getting StaticPodSpecs
6 j' o8 S  v+ X! m/ C+ GI0104 08:22:48.177133    3326 certs.go:473] validating certificate period for CA certificate% \2 w' _5 \! j( O0 N1 X; ^, F
I0104 08:22:48.177225    3326 manifests.go:129] [control-plane] adding volume "ca-certs" for component "kube-apiserver"
* \# L7 R4 C& [: r, `6 W, ^I0104 08:22:48.177245    3326 manifests.go:129] [control-plane] adding volume "etc-pki-ca-trust" for component "kube-apiserver"
. D5 Y3 v; r! Y/ `" @I0104 08:22:48.177257    3326 manifests.go:129] [control-plane] adding volume "etc-pki-tls-certs" for component "kube-apiserver"
$ T  K1 e) V4 |: mI0104 08:22:48.177270    3326 manifests.go:129] [control-plane] adding volume "k8s-certs" for component "kube-apiserver", y. D/ u5 @& Y! R
I0104 08:22:48.178627    3326 manifests.go:158] [control-plane] wrote static Pod manifest for component "kube-apiserver" to "/etc/kubernetes/manifests/kube-apiserver.yaml". q' [( m2 {& M) W! F8 A
[control-plane] Creating static Pod manifest for "kube-controller-manager"
' _0 d. s6 I: P2 w1 w7 z1 `I0104 08:22:48.178653    3326 manifests.go:103] [control-plane] getting StaticPodSpecs
/ ~6 H! T/ s8 j6 II0104 08:22:48.178973    3326 manifests.go:129] [control-plane] adding volume "ca-certs" for component "kube-controller-manager"
/ ?( g, E" f4 {5 K7 W1 y! D2 `8 vI0104 08:22:48.178993    3326 manifests.go:129] [control-plane] adding volume "etc-pki-ca-trust" for component "kube-controller-manager"
9 w" d0 d3 |( ?7 N6 MI0104 08:22:48.179005    3326 manifests.go:129] [control-plane] adding volume "etc-pki-tls-certs" for component "kube-controller-manager"
2 F; s; \* p8 o* ]. oI0104 08:22:48.179018    3326 manifests.go:129] [control-plane] adding volume "flexvolume-dir" for component "kube-controller-manager"
( I; R# y( Z1 M, kI0104 08:22:48.179030    3326 manifests.go:129] [control-plane] adding volume "k8s-certs" for component "kube-controller-manager"
: |8 W+ G; Y) V; q/ d' gI0104 08:22:48.179043    3326 manifests.go:129] [control-plane] adding volume "kubeconfig" for component "kube-controller-manager"
1 g* R& J( S' q$ m7 H* u5 Y. r/ sI0104 08:22:48.180113    3326 manifests.go:158] [control-plane] wrote static Pod manifest for component "kube-controller-manager" to "/etc/kubernetes/manifests/kube-controller-manager.yaml"/ x- Y9 E6 H( Y, w  M0 }/ ]+ `
[control-plane] Creating static Pod manifest for "kube-scheduler"
6 T8 _- o& N. j8 U) lI0104 08:22:48.180140    3326 manifests.go:103] [control-plane] getting StaticPodSpecs
4 C0 l0 t7 u* UI0104 08:22:48.180470    3326 manifests.go:129] [control-plane] adding volume "kubeconfig" for component "kube-scheduler"
9 y9 \: {3 G+ w6 D9 {I0104 08:22:48.181362    3326 manifests.go:158] [control-plane] wrote static Pod manifest for component "kube-scheduler" to "/etc/kubernetes/manifests/kube-scheduler.yaml"
% C% `: t: q/ |) ]I0104 08:22:48.181506    3326 kubelet.go:68] Stopping the kubelet+ \& e& K, h- v, S7 z$ V5 L7 g4 y
I0104 08:22:48.194634    3326 flags.go:101] setting kubelet hostname-override to "node"; s1 e( a  Y. G/ a% n6 i9 L
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
$ W$ V  C3 m  Y+ X0 A[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
, G0 m) A" {+ |! W[kubelet-start] Starting the kubelet
' d# m6 g0 p2 Z! P[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests"4 Q' A- j" E! ?% t7 L
[kubelet-check] Waiting for a healthy kubelet at http://127.0.0.1:10248/healthz. This can take up to 4m0s1 D( r: ]9 {2 m/ \; d: U
[kubelet-check] The kubelet is healthy after 2.502312387s
& G( E; M$ f: u# b- D[api-check] Waiting for a healthy API server. This can take up to 4m0s
" H  `: p, X  W0 _, e) x
# s$ B: t# |% S# J. ?" [1 v# _8 s9 A6 A" y7 S$ l
1 n" N9 x  x  u3 c

+ g2 J- Y- s+ R8 e1 Z6 P: K
- e  D5 L9 i$ G9 P* Y) J: D& S7 h8 n( Z
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-11 23:31 , Processed in 0.016614 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表