root@longinus-master-1:~# timedatectl status Local time: Tue 2024-01-16 09:44:38 CST Universal time: Tue 2024-01-16 01:44:38 UTC RTC time: Tue 2024-01-16 01:44:37 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no
root@longinus-master-1:~# dpkg -l ipset ipvsadm Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==============-==============-============-================================> ii ipset 7.15-1build1 amd64 administration tool for kernel I> ii ipvsadm 1:1.31-1build2 amd64 Linux Virtual Server support pro>
root@longinus-master-1:~# systemctl status containerd.service root@longinus-master-1:~# systemctl status docker.service root@longinus-master-1:~# systemctl status docker.socket
Jan 16 11:02:01 longinus-master-1 systemd[1]: kubelet.service: Main process exi> Jan 16 11:02:01 longinus-master-1 systemd[1]: kubelet.service: Failed with resu> lines 1-12/12 (END)...skipping... ● kubelet.service - kubelet: The Kubernetes Node Agent Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/kubelet.service.d └─10-kubeadm.conf Active: activating (auto-restart) (Result: exit-code) since Tue 2024-01-16 11:02:01 CST; 1s ago Docs: https://kubernetes.io/docs/home/ Process: 7108 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=1/FAILURE) Main PID: 7108 (code=exited, status=1/FAILURE) CPU: 61ms
Jan 16 11:02:01 longinus-master-1 systemd[1]: kubelet.service: Main process exited, code=exited, status=1/FAILURE Jan 16 11:02:01 longinus-master-1 systemd[1]: kubelet.service: Failed with result 'exit-code'.
root@longinus-master-1:~# kubeadm config images list I0116 11:07:18.093407 7309 version.go:256] remote version is much newer: v1.29.0; falling back to: stable-1.28 registry.k8s.io/kube-apiserver:v1.28.5 registry.k8s.io/kube-controller-manager:v1.28.5 registry.k8s.io/kube-scheduler:v1.28.5 registry.k8s.io/kube-proxy:v1.28.5 registry.k8s.io/pause:3.9 registry.k8s.io/etcd:3.5.9-0 registry.k8s.io/coredns/coredns:v1.10.1
拉取镜像
1 2 3 4 5 6 7 8 9
root@longinus-master-1:~# kubeadm config images pull I0116 11:08:28.342502 7361 version.go:256] remote version is much newer: v1.29.0; falling back to: stable-1.28 [config/images] Pulled registry.k8s.io/kube-apiserver:v1.28.5 [config/images] Pulled registry.k8s.io/kube-controller-manager:v1.28.5 [config/images] Pulled registry.k8s.io/kube-scheduler:v1.28.5 [config/images] Pulled registry.k8s.io/kube-proxy:v1.28.5 [config/images] Pulled registry.k8s.io/pause:3.9 [config/images] Pulled registry.k8s.io/etcd:3.5.9-0 [config/images] Pulled registry.k8s.io/coredns/coredns:v1.10.1
Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/
You can now join any number of the control-plane node running the following command on each as root:
Please note that the certificate-key gives access to cluster sensitive data, keep it secret! As a safeguard, uploaded-certs will be deleted in two hours; If necessary, you can use "kubeadm init phase upload-certs --upload-certs" to reload certs afterward.
Then you can join any number of worker nodes by running the following on each as root:
root@longinus-master-1:~# kubectl apply -f kube-flannel.yml namespace/kube-flannel created serviceaccount/flannel created clusterrole.rbac.authorization.k8s.io/flannel created clusterrolebinding.rbac.authorization.k8s.io/flannel created configmap/kube-flannel-cfg created daemonset.apps/kube-flannel-ds created
root@longinus-master-1:~# kubectl get cs Warning: v1 ComponentStatus is deprecated in v1.19+ NAME STATUS MESSAGE ERROR scheduler Healthy ok controller-manager Healthy ok etcd-0 Healthy ok
[preflight] Running pre-flight checks [preflight] Reading configuration from the cluster... [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml' [kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml" [kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env" [kubelet-start] Starting the kubelet [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...
This node has joined the cluster: * Certificate signing request was sent to apiserver and a response was received. * The Kubelet was informed of the new secure connection details.
Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
root@longinus-master-1:~# kubectl create deployment nginx --image=docker.io/library/nginx:latest deployment.apps/nginx created
检查
1 2 3
root@longinus-master-1:~# kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-75446c786c-9b9nd 1/1 Running 0 50s 10.244.1.2 longinus-node-1 <none> <none>
root@longinus-node-1:~/.kube# curl 10.244.1.2 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p>
<p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p> </body> </html>
root@longinus-node-1:~/.kube# curl 10.244.2.2 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p>
<p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p> </body> </html>
root@longinus-node-1:~/.kube# curl 10.244.3.2 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p>
<p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p> </body> </html>