易陆发现互联网技术论坛

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

kubernets(k8s)init 初始化节点

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

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

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

x
kubernets(k8s)init 初始化节点
7 w( P9 V: m5 p- e 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.sock2 H) h% ]( o3 `$ o6 u. P7 E
, {# z; O2 V4 u8 W3 x
# e0 r/ ]9 r; X5 k/ ^2 b3 }; R
7 b7 m: E1 f- E% ?$ m
建议cidir不要写太大,因为写太大会有些问题存在。比如本地的网段和规划的大网段存在冲突。
! f8 u' w* @& n" ~$ h
4 F$ g/ l: M9 w5 [7 K' Q' X7 }  i1 T$ C+ i
 楼主| 发表于 2024-12-29 21:22:14 | 显示全部楼层
[root@k8s-master ~]#  kubeadm config images list
5 P. Y5 i; q: P' q, VI1229 21:16:13.799696    2756 version.go:256] remote version is much newer: v1.32.0; falling back to: stable-1.28- ]+ u# U$ G4 U9 w9 L4 t
registry.k8s.io/kube-apiserver:v1.28.15, r* @/ L; `. G# p  e
registry.k8s.io/kube-controller-manager:v1.28.15
! ~& f# A' u% v1 Zregistry.k8s.io/kube-scheduler:v1.28.155 b2 T0 D. A7 L. q7 i$ r
registry.k8s.io/kube-proxy:v1.28.150 j7 [' E9 Q* m2 t
registry.k8s.io/pause:3.98 c3 P7 H# W  g" c0 O8 T4 |
registry.k8s.io/etcd:3.5.9-0
. d5 o. \& [% W! U( `& @0 Yregistry.k8s.io/coredns/coredns:v1.10.1
& d6 r( a) H0 T3 Z[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, Q5 F9 n$ }# K+ ~* A! _
[init] Using Kubernetes version: v1.28.2
: @3 ~& j' d% p3 J; L, A[preflight] Running pre-flight checks% Z* z' G& Z8 C  H
[preflight] Pulling images required for setting up a Kubernetes cluster
* Y) {, ~- j4 {* w7 e[preflight] This might take a minute or two, depending on the speed of your internet connection
, C& I- w. Y  w3 F( }[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
: l" Q* U& `, S5 G5 z[certs] Using certificateDir folder "/etc/kubernetes/pki"0 P3 @3 Y( M3 [, B5 @
[certs] Generating "ca" certificate and key
8 R  X7 Y: T+ V3 A4 b: @5 H[certs] Generating "apiserver" certificate and key4 w( O; G- Z' ^5 z0 h, C: i5 u* f
[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]
! K0 `# W% b5 N$ U: j[certs] Generating "apiserver-kubelet-client" certificate and key$ O% [3 ~% s6 z$ m4 S
[certs] Generating "front-proxy-ca" certificate and key
  A8 z/ i( z. A' T" t8 i[certs] Generating "front-proxy-client" certificate and key2 F& {# ^3 L; e; h. w9 A
[certs] Generating "etcd/ca" certificate and key
  Q" t! I) R$ f. N+ E$ Y1 h[certs] Generating "etcd/server" certificate and key
- l! b! E( ]9 K7 I3 `[certs] etcd/server serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.8.190 127.0.0.1 ::1]& l9 g( C) y" _3 X
[certs] Generating "etcd/peer" certificate and key+ v- P' w/ X+ x9 r
[certs] etcd/peer serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.8.190 127.0.0.1 ::1]7 G$ R# o0 C; T5 Y
[certs] Generating "etcd/healthcheck-client" certificate and key
: V4 p# Z# B4 G$ Y8 i+ z! ?[certs] Generating "apiserver-etcd-client" certificate and key
7 s8 G) L5 [( C[certs] Generating "sa" key and public key
8 |$ e# v4 n6 F) }7 j4 l[kubeconfig] Using kubeconfig folder "/etc/kubernetes"7 O  Y' f6 K/ g! G+ P5 S
[kubeconfig] Writing "admin.conf" kubeconfig file- O0 a3 t2 h3 S( }  J
[kubeconfig] Writing "kubelet.conf" kubeconfig file
5 I2 _8 x( v1 p: `1 f! s[kubeconfig] Writing "controller-manager.conf" kubeconfig file; y% J; A7 l' E0 Y+ v4 K
[kubeconfig] Writing "scheduler.conf" kubeconfig file
3 T! h0 i: \7 m2 j0 p* y+ n" y[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
( d. b6 A5 g% y, Y[control-plane] Using manifest folder "/etc/kubernetes/manifests". @8 M. w5 t5 y$ M3 e5 ~
[control-plane] Creating static Pod manifest for "kube-apiserver"
: }, Q4 ^! }- S% R# e* m[control-plane] Creating static Pod manifest for "kube-controller-manager"
: N( s3 K" |& x! x2 u3 F) Z8 p[control-plane] Creating static Pod manifest for "kube-scheduler"
+ w: O" M( |: R9 ^" g& C0 ][kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
7 f% A9 i* |% p. F$ [[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
% ~! X& ]( D& w. x[kubelet-start] Starting the kubelet6 O7 o( i9 e1 h4 P' j, c/ V
[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
4 e+ Y" m2 G( c$ E3 ?7 v[apiclient] All control plane components are healthy after 10.503849 seconds8 |* T/ T( _. _% O
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
/ x1 x! X$ [- S5 Z, F[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration for the kubelets in the cluster% v' c$ Y) {3 r( c( j* z" L
[upload-certs] Skipping phase. Please see --upload-certs
5 e! g' l1 k) u9 m+ q! Z[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]- J- I7 ]' _5 g* Z9 c9 A
[mark-control-plane] Marking the node k8s-master as control-plane by adding the taints [node-role.kubernetes.io/control-plane:NoSchedule]
: Z4 Z8 T/ C$ O: |" |( t[bootstrap-token] Using token: gz21hk.okzfsa63qkqquxwr
6 {' S: }& U' }2 o8 r$ N[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
% V& K% \: C  O) ?[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes
4 e; z1 U6 [5 y& U2 N. q& m5 y/ _[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
8 O( `* N7 n. q; r7 b[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token. t, W' x1 h; K  b1 K
[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster  B9 K/ E2 ?* ^1 v- _' [* Q0 T6 H7 T
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
+ v* g) f% H4 m* R0 Y* [[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key: \8 ]$ g9 e4 I  n; A! }
[addons] Applied essential addon: CoreDNS# k7 @: \% A; a3 Q+ _1 L% \
[addons] Applied essential addon: kube-proxy
% j* C5 P) Y5 U  i; C$ z* V$ D% F# T& x
Your Kubernetes control-plane has initialized successfully!  E; I; Q2 w" Z0 G
' t. U0 ?5 g; r3 e) t! B0 q
To start using your cluster, you need to run the following as a regular user:
, k0 X. J0 A6 N8 ~* W/ H! M8 d8 q6 \! r/ y# R0 c- V% q
  mkdir -p $HOME/.kube
5 J5 B: {0 }" j  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
; ?. R+ `  c4 g/ k9 {# ~  sudo chown $(id -u):$(id -g) $HOME/.kube/config* d6 g4 @( e! ]# ?0 T4 w- a8 N

& `) h7 k+ A: X- ]4 cAlternatively, if you are the root user, you can run:/ k" @! Z) N' `' c' C/ [

5 i1 ^9 V9 J, E+ t& }6 n5 W' H- x  export KUBECONFIG=/etc/kubernetes/admin.conf
( O( e- A0 @+ j7 x" _/ n8 x/ P4 D4 r& A2 ?$ n7 w! C
You should now deploy a pod network to the cluster.
# S3 b6 y, S9 f9 _9 g. `Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:+ v& S, R; \; k  e% C
  https://kubernetes.io/docs/conce ... inistration/addons/: a4 I- p* z- @  z% U
9 Q) }; x  J! f
Then you can join any number of worker nodes by running the following on each as root:( ]7 s0 M+ U* d! J# t' R; q0 ?

' q; o( h3 b0 q7 C0 T4 wkubeadm join 192.168.8.190:6443 --token gz21hk.okzfsa63qkqquxwr \
! k0 Q9 R$ v0 j' Z        --discovery-token-ca-cert-hash sha256:5aeba3bb6d94b76440997cbc4ee9c2ef8a791211a7da0abb39a75142a040bc00 2 n4 h$ x8 O0 S; F: t
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

GMT+8, 2026-4-8 21:27 , Processed in 0.046017 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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