Add the current user to the docker group so that the docker command does not need to be entered into sudo later. Assumes that the current user name is stu, execute:
1
sudo usermod -aG docker stu
Note that for the above command to take effect, you need to log in again
To verify the installation, you can execute some commonly used docker commands to see if they are working properly, such as:
1
docker images
1
docker --version
Change the host name
Use the following command to change the host。
Install the list at the beginning of the article to make ip addresses to make modifications.
Note: Replace the apiserver-advertise-address value with your master node IP
–apiserver-advertise-address: The deployment address of the main service apiserver in k8s, fill in your own management node IP
–pod-network-cidr: This is the node network used by k8s, because we will use flannel as the k8s network, as a learning environment, here is 10.244.0.0/16
After the running is complete, you can see a prompt similar to the following
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/
Then you can join any number of worker nodes by running the following on each as root:
Warning: policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+ podsecuritypolicy.policy/psp.flannel.unprivileged created clusterrole.rbac.authorization.k8s.io/flannel created clusterrolebinding.rbac.authorization.k8s.io/flannel created serviceaccount/flannel created configmap/kube-flannel-cfg created daemonset.apps/kube-flannel-ds created
Verify
Executes on the master node
1
kubectl get nodes
You can see it
1 2
NAME STATUS ROLES AGE VERSION master Ready control-plane,master 21m v1.23.0
[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' W1213 11:09:04.079403 1772383 utils.go:69] The recommended value for"resolvConf"in"KubeletConfiguration" is: /run/systemd/resolve/resolv.conf; the provided value is: /run/systemd/resolve/resolv.conf [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.
After the above command line was executed on all worker nodes,Can be returned to the master node for execution:
1
kubectl get nodes
If you see a similar message, the k8s cluster has been successfully installed
1 2 3 4
NAME STATUS ROLES AGE VERSION master Ready control-plane,master 26m v1.23.0 node-02 Ready <none> 62s v1.23.0 node-03 Ready <none> 2m58s v1.23.0