|
|
楼主 |
发表于 2024-12-29 21:22:14
|
显示全部楼层
[root@k8s-master ~]# kubeadm config images list
2 G( [1 X! j" `I1229 21:16:13.799696 2756 version.go:256] remote version is much newer: v1.32.0; falling back to: stable-1.28
) O8 N+ l- Y+ \6 Z7 }registry.k8s.io/kube-apiserver:v1.28.15/ C5 `$ F8 m% ?0 B( X9 w7 i
registry.k8s.io/kube-controller-manager:v1.28.15
( ?* M6 D8 B% Y1 }' tregistry.k8s.io/kube-scheduler:v1.28.15/ A' T- C$ R4 N {+ a( E7 Z: [( t* T
registry.k8s.io/kube-proxy:v1.28.15
, L& f* T5 A: G7 B7 |4 Jregistry.k8s.io/pause:3.9) A/ l5 t: R$ w, l, ?
registry.k8s.io/etcd:3.5.9-02 x" P$ Q! f9 d$ S! Z& a) v
registry.k8s.io/coredns/coredns:v1.10.1
( T2 q) G8 X C8 ~, f9 _[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
* c- m$ g+ p" U" \( Z" w# K, |[init] Using Kubernetes version: v1.28.2
* v0 F0 L* P9 E* H, ^; Y[preflight] Running pre-flight checks# B0 g: |7 }! N, a9 a
[preflight] Pulling images required for setting up a Kubernetes cluster7 N2 l% P* n8 n" a' p0 R$ l
[preflight] This might take a minute or two, depending on the speed of your internet connection. N8 J# U$ \, j0 f/ S5 c0 J" J
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
) ~9 k& v- f5 x[certs] Using certificateDir folder "/etc/kubernetes/pki"
/ Z5 B. \: b' p2 x7 [[certs] Generating "ca" certificate and key6 H$ B! _! ?2 @; c. W4 G
[certs] Generating "apiserver" certificate and key
4 o. E0 ~' U1 \/ y5 z# {4 E[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]" S5 q+ E* ~& i9 Q+ I
[certs] Generating "apiserver-kubelet-client" certificate and key
- z* b4 d2 o( l' K! h2 ~3 l' p[certs] Generating "front-proxy-ca" certificate and key
# P( D9 Y# ~; u) f2 O& N$ K[certs] Generating "front-proxy-client" certificate and key
/ s# q3 V# E, O[certs] Generating "etcd/ca" certificate and key! g: \$ Z4 w6 v; f' B5 e
[certs] Generating "etcd/server" certificate and key7 O/ {" T5 ^9 C
[certs] etcd/server serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.8.190 127.0.0.1 ::1]3 b. k7 K6 J) Y
[certs] Generating "etcd/peer" certificate and key1 ~% L2 Z* Y+ l8 q) w
[certs] etcd/peer serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.8.190 127.0.0.1 ::1]! y, D% G' w+ X' B5 i6 P V
[certs] Generating "etcd/healthcheck-client" certificate and key4 }& {2 y! |) i/ w' {' \3 R
[certs] Generating "apiserver-etcd-client" certificate and key
% T. P2 _- W( Z6 S4 Q: ^0 @[certs] Generating "sa" key and public key0 F' [3 j4 l/ t/ j" \
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
6 N# J+ \9 D. Z. E9 Z2 ^0 o[kubeconfig] Writing "admin.conf" kubeconfig file
8 c0 A' O9 P8 E) F* ~[kubeconfig] Writing "kubelet.conf" kubeconfig file
3 C7 N# x# A, ?* [3 C" c[kubeconfig] Writing "controller-manager.conf" kubeconfig file8 Y! Y& H, g9 x$ U* R
[kubeconfig] Writing "scheduler.conf" kubeconfig file; j5 k6 [/ h' A2 p# h, C9 e4 E- u0 x0 L
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"7 o/ ~. J$ ]0 ?- s: N+ V
[control-plane] Using manifest folder "/etc/kubernetes/manifests". _+ n/ x# n7 c: W/ G
[control-plane] Creating static Pod manifest for "kube-apiserver"
; \( F) l$ D) g8 ?. g( O0 W7 ^9 {[control-plane] Creating static Pod manifest for "kube-controller-manager"8 S6 p$ u! m$ {5 B/ { a/ ^
[control-plane] Creating static Pod manifest for "kube-scheduler"
3 k- z( A' s( e; z1 }[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
8 w( s. r% ~# S7 b$ ~[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"; m. G2 A8 F$ h) K# C/ E
[kubelet-start] Starting the kubelet+ V/ ^7 d* t t {. s
[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) }, O+ V9 B7 Q0 Q. D) M* h( b
[apiclient] All control plane components are healthy after 10.503849 seconds
3 g0 |- J1 {! t! ` O[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
5 b5 b1 q5 I# F3 a1 i) Y. B* j. l9 w[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration for the kubelets in the cluster d6 T9 F% W. a3 P2 T. e
[upload-certs] Skipping phase. Please see --upload-certs
+ N0 O* a( ~$ Q- @$ w- E' P! J[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]4 G3 ^- M8 _# g3 c+ a5 c' m3 A
[mark-control-plane] Marking the node k8s-master as control-plane by adding the taints [node-role.kubernetes.io/control-plane:NoSchedule]
; B, g2 {# o$ j3 \9 p[bootstrap-token] Using token: gz21hk.okzfsa63qkqquxwr
& @& P0 Y0 |7 x n$ r: ]% Y% t, V[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
6 ], V2 G$ h' u$ C) {7 g6 a- s[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes
/ D/ x, J: I, B. {[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
! n7 F( p; W# o) ]. i: @[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token3 }6 M, j4 S' w3 s" J; x0 w
[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
) u$ K8 @' U+ U[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace' D8 `$ z5 `- J' y
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key0 w6 k9 s' q# |! j3 v, ^ j
[addons] Applied essential addon: CoreDNS
# J5 |3 T# u+ w _' _( `[addons] Applied essential addon: kube-proxy
7 I3 s! t" f* ^. }) E7 }
8 _7 b6 T$ F5 D, w8 jYour Kubernetes control-plane has initialized successfully!, ^9 Q Y/ G1 I# Z! C2 F: P/ L& U
1 L: R* L6 G2 Z# I4 B5 W+ R; d+ cTo start using your cluster, you need to run the following as a regular user:5 n; H. I5 ?. @/ v% V% ]
4 L) j3 P, F% B5 }4 O1 C
mkdir -p $HOME/.kube
! \) u- B, k! d; C3 E: y3 { sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config0 Y0 _" j) S H# b& E2 J
sudo chown $(id -u):$(id -g) $HOME/.kube/config! D b/ q8 A- @7 {! F
) I9 B9 X+ F- l" R6 h; C; [Alternatively, if you are the root user, you can run:
! [' A5 H# O; _; l1 \# b, d( j) S2 Y+ j5 t4 R- o# o
export KUBECONFIG=/etc/kubernetes/admin.conf# s5 U8 c1 [6 U6 Q7 ?- p
8 `$ c0 G- \7 Y# T9 {, L
You should now deploy a pod network to the cluster.
2 R; a9 c6 n9 `6 t/ |! H7 k& Q: t6 L+ BRun "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
$ v" f. H7 {3 t, v https://kubernetes.io/docs/conce ... inistration/addons/
F) j3 }5 |1 z; ]4 F" u( e( ^+ [ T) }. ^; I% {3 Q, Q
Then you can join any number of worker nodes by running the following on each as root:
) r0 M) O7 E' c* u$ X* {! h6 z, b- s
- `1 b: F% D7 L0 [( Bkubeadm join 192.168.8.190:6443 --token gz21hk.okzfsa63qkqquxwr \
/ f: L/ I- J1 X; F$ Q9 n1 x --discovery-token-ca-cert-hash sha256:5aeba3bb6d94b76440997cbc4ee9c2ef8a791211a7da0abb39a75142a040bc00 ( F, n/ D! z$ l B: ?% E3 n
|
|