易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 24|回复: 1
收起左侧

kubernets(k8s)init 初始化节点

[复制链接]
发表于 2024-12-29 21:21:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
kubernets(k8s)init 初始化节点6 d  u0 J0 b* p  D. G) U2 L
kubeadm init --apiserver-advertise-address=192.168.8.190 --node-name=k8s-master  --image-repository registry.aliyuncs.com/google_containers  --kubernetes-version v1.28.2 --service-cidr=192.182.22.0/20 --pod-network-cidr=192.172.21.0/20  --cri-socket=unix:///var/run/cri-dockerd.sock" ~! r/ U3 _6 i/ s/ K

1 _6 D# Q+ _. n- |! U# ^
$ F* N. y4 W) E
0 I. _; E3 L: {' S建议cidir不要写太大,因为写太大会有些问题存在。比如本地的网段和规划的大网段存在冲突。$ d+ J9 A; V- u$ M# g* L
- e1 M2 O) R# Q5 H
2 M3 p; x* z9 \9 u
 楼主| 发表于 2024-12-29 21:22:14 | 显示全部楼层
[root@k8s-master ~]#  kubeadm config images list9 Z9 Y6 A. [% _) e) V3 V2 d0 s+ _
I1229 21:16:13.799696    2756 version.go:256] remote version is much newer: v1.32.0; falling back to: stable-1.280 `4 ^" o- `0 J. o# ~0 D* y
registry.k8s.io/kube-apiserver:v1.28.15
6 w3 {8 i( q, [- I" H" `# R4 Q5 h/ Yregistry.k8s.io/kube-controller-manager:v1.28.15- i" i2 r/ I: Y) f) j: a# u7 t
registry.k8s.io/kube-scheduler:v1.28.15
7 |' }4 a  N4 R, T% N2 B2 i- |! xregistry.k8s.io/kube-proxy:v1.28.15
7 T4 P6 A, d$ ]3 L3 T/ Rregistry.k8s.io/pause:3.9$ d, g2 r" d8 o5 j3 o% c+ k' c9 r
registry.k8s.io/etcd:3.5.9-0
3 n3 S; E% I7 U+ D: C# ]registry.k8s.io/coredns/coredns:v1.10.1
! X0 O8 n5 H  z6 [" o* L, k[root@k8s-master ~]#  kubeadm init --apiserver-advertise-address=192.168.8.190 --node-name=k8s-master  --image-repository registry.aliyuncs.com/google_containers  --kubernetes-version v1.28.2 --service-cidr=192.182.22.0/20 --pod-network-cidr=192.172.21.0/20  --cri-socket=unix:///var/run/cri-dockerd.sock
  ?# \, g, v5 G: C# ^[init] Using Kubernetes version: v1.28.2
$ H- m' l: [$ i% K[preflight] Running pre-flight checks
) ?' N$ x8 Z/ X3 D[preflight] Pulling images required for setting up a Kubernetes cluster
/ c! i2 q9 d( }& h[preflight] This might take a minute or two, depending on the speed of your internet connection
$ Y  x" N4 V$ }$ Q* a[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'& {8 B& s: V. T" j& {# X4 Z
[certs] Using certificateDir folder "/etc/kubernetes/pki"$ ]: R2 ]& C" l7 m& Y' x& C4 u' ~# K
[certs] Generating "ca" certificate and key/ L/ e5 B, B" C0 Q8 L2 A* }
[certs] Generating "apiserver" certificate and key& ^) v! v8 u3 J- q
[certs] apiserver serving cert is signed for DNS names [k8s-master kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [192.182.16.1 192.168.8.190]
; q' j4 W9 H! v$ X& I[certs] Generating "apiserver-kubelet-client" certificate and key
) M+ J2 @; q/ |: q[certs] Generating "front-proxy-ca" certificate and key* S4 G' Y8 W2 l! I, i
[certs] Generating "front-proxy-client" certificate and key0 L) W/ j5 Z3 X0 Z% o' B: e
[certs] Generating "etcd/ca" certificate and key
9 G2 x7 P1 M$ e- k; q[certs] Generating "etcd/server" certificate and key( K$ e4 q. v9 |9 n: X+ N
[certs] etcd/server serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.8.190 127.0.0.1 ::1]5 H5 U0 I0 n- Q) s/ U2 q
[certs] Generating "etcd/peer" certificate and key. G9 b+ I/ k/ k2 P
[certs] etcd/peer serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.8.190 127.0.0.1 ::1]& U3 \7 l  O$ ?0 ?* I2 l: E
[certs] Generating "etcd/healthcheck-client" certificate and key
$ t$ o  n2 w, F) a5 s4 Q1 \4 f% U[certs] Generating "apiserver-etcd-client" certificate and key
6 l- F, _$ a2 ]' _9 `, c[certs] Generating "sa" key and public key+ T' T% o) R9 C* }
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"5 M) c  r$ R4 A
[kubeconfig] Writing "admin.conf" kubeconfig file/ ]( e8 ~( G; J/ f' m
[kubeconfig] Writing "kubelet.conf" kubeconfig file
1 E4 r+ E* c2 ?[kubeconfig] Writing "controller-manager.conf" kubeconfig file
1 H7 O& D& Y% ^  k[kubeconfig] Writing "scheduler.conf" kubeconfig file
, H% B2 H: c+ S- a5 I[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"& x& u: r5 l7 D) Q
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
8 S5 B0 A" a6 t) R. E[control-plane] Creating static Pod manifest for "kube-apiserver"
& l' w, D2 w3 _7 H4 z3 I[control-plane] Creating static Pod manifest for "kube-controller-manager"% k/ S& P/ R3 ?" Y
[control-plane] Creating static Pod manifest for "kube-scheduler"/ @' m: J4 K( M' w! N+ N7 T
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env": m6 ]: t: I" {0 `$ a* b
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
8 \! j0 v% P, }( s2 L[kubelet-start] Starting the kubelet
9 q* ?; S8 [2 N" k2 }4 r; N$ D: [# U[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
3 W3 I5 W3 V* J) x[apiclient] All control plane components are healthy after 10.503849 seconds6 [' u4 R$ m' b7 s% X  @
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace3 }* A( X; Z3 |& z
[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration for the kubelets in the cluster
: M+ a, Z! a* d- V[upload-certs] Skipping phase. Please see --upload-certs4 z. ~4 I$ ?4 O4 Y7 k
[mark-control-plane] Marking the node k8s-master as control-plane by adding the labels: [node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]  W& L) O8 e8 I6 l, n
[mark-control-plane] Marking the node k8s-master as control-plane by adding the taints [node-role.kubernetes.io/control-plane:NoSchedule]
# j% ]/ x8 N! x# E[bootstrap-token] Using token: gz21hk.okzfsa63qkqquxwr9 N# T6 ^5 a- @- n+ z7 G4 c+ |
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles. n% f, |* y" m, p; K
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes4 q' _1 I: |( C9 F! M
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
4 h" Z7 H) X7 `& A" Y% b: w$ i[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
" c4 k* r6 J6 I3 r5 M  O: J6 C[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster3 {7 F2 o; y0 W4 r- S! p
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace; o$ W% \( Z+ M2 x7 C
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key: K9 B* E2 G) C
[addons] Applied essential addon: CoreDNS7 F1 x& M$ i( f7 k2 B, K6 E
[addons] Applied essential addon: kube-proxy
! d& h7 D2 Y7 U" U' [! Z  k& g/ m$ U, U* J) Z, i
Your Kubernetes control-plane has initialized successfully!
' {# D" ]" i: N8 o5 u/ L  n
. Q- Y0 F+ V* u3 ]$ ~  c1 Z) MTo start using your cluster, you need to run the following as a regular user:( D0 `4 A, u: c
! {' F5 n% _  V! m
  mkdir -p $HOME/.kube' z# X& \+ o2 h+ A0 k
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
4 O) ~: I! s6 P0 k/ \5 g( X  sudo chown $(id -u):$(id -g) $HOME/.kube/config
# \& x9 D7 b5 n) k$ S. }( G
: ^! S1 F2 ?# x3 N& XAlternatively, if you are the root user, you can run:
" X# v; i8 h( O1 |: B$ G  R$ A0 E$ o( _' m
  export KUBECONFIG=/etc/kubernetes/admin.conf
2 o0 J8 ]/ f3 m# |
7 r, Z- r, }# ~; JYou should now deploy a pod network to the cluster.
, l4 v" J9 K4 X( d7 FRun "kubectl apply -f [podnetwork].yaml" with one of the options listed at:  N3 z4 C4 Z$ x* o
  https://kubernetes.io/docs/conce ... inistration/addons/
- f- M  ^' T; |9 U. p" W9 x
& y) q( s' F3 [% R. |+ ^1 zThen you can join any number of worker nodes by running the following on each as root:7 l: ?" v: L' w  R# E9 S

1 p( H1 G) T* Ykubeadm join 192.168.8.190:6443 --token gz21hk.okzfsa63qkqquxwr \) U5 r; ?" w; B9 ]+ F9 p
        --discovery-token-ca-cert-hash sha256:5aeba3bb6d94b76440997cbc4ee9c2ef8a791211a7da0abb39a75142a040bc00
- R0 D' y  R  m1 g, Z
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-9 01:11 , Processed in 0.054610 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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