$ vim /etc/fstab # /etc/fstab # Created by anaconda on Fri Nov 12 00:53:22 2021 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs defaults 0 0 UUID=ab32a4a5-53cf-449d-b6b6-64a4e4bdc0b7 /boot xfs defaults 0 0 # /dev/mapper/centos-swap swap swap defaults 0 0 $ reboot
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.
在maser节点执行命令查看节点:
1 2 3 4 5
[root@master download]# kubectl get node NAME STATUS ROLES AGE VERSION master NotReady master 71s v1.18.0 node1 NotReady <none> 31s v1.18.0 node2 NotReady <none> 22s v1.18.0
[root@master k8s]# kubectl get node NAME STATUS ROLES AGE VERSION master Ready master 72m v1.18.0 node1 Ready <none> 72m v1.18.0 node2 Ready <none> 71m v1.18.0
已经变成Ready状态。
创建Pod测试
在Kubernetes集群中创建一个nginx的pod,验证是否正常运行:
1 2 3 4 5 6 7 8
# 自动拉取nginx镜像并创建pod $ kubectl create deployment nginx --image=nginx # 查看状态 $ kubectl get pod # 暴露端口 $ kubectl expose deployment nginx --port=80 --type=NodePort # 查看对外端口 $ kubectl get pod,svc
测试如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[root@master k8s]# kubectl create deployment nginx --image=nginx deployment.apps/nginx created [root@master k8s]# kubectl get pod NAME READY STATUS RESTARTS AGE nginx-f89759699-z744t 0/1 ContainerCreating 0 25s [root@master k8s]# kubectl get pod NAME READY STATUS RESTARTS AGE nginx-f89759699-z744t 1/1 Running 0 62s [root@master k8s]# kubectl expose deployment nginx --port=80 --type=NodePort service/nginx exposed [root@master k8s]# kubectl get pod,svc NAME READY STATUS RESTARTS AGE pod/nginx-f89759699-z744t 1/1 Running 0 5m27s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 93m service/nginx NodePort 10.104.221.51 <none> 80:31900/TCP 107s
[root@node1 k8s]# curl 192.168.117.156:31900 <!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>
说明nginx启动成功。
相关问题
问题1
部署master出现如下错误:
1 2 3 4 5 6 7 8 9 10
Unfortunately, an error has occurred: timed out waiting for the condition
This error is likely caused by: - The kubelet is not running - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands: - 'systemctl status kubelet' - 'journalctl -xeu kubelet'
[root@node1 ~]# kubeadm join 192.168.117.156:6443 --token blq5e1.69fw04mz5gldiynq --discovery-token-ca-cert-hash sha256:ef5b7163cebfd25a2d844befd66767a38f084a9ee249cbc384ad1ec64b961abb W1112 01:13:04.455538 15663 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set. [preflight] Running pre-flight checks [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/ error execution phase preflight: couldn't validate the identity of the API Server: Get https://192.168.117.156:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s: x509: certificate has expired or is not yet valid To see the stack trace of this error execute with --v=5 or higher