A, description,
I learned some concepts about K8S from the previous sections, and also tried some small experiments. But the operation always does not understand some of the meaning and essence, so it is going to start from Kubesphere in turn to learn our K8S, with some basic concepts of K8S, kubesphere should not be very difficult to understand. So the next series of notes will focus on how TO deploy Fastapi to our Kubesphere.
First of all, the main purpose is for me to learn, so the corresponding generation environment, related server requirements are not the same, my environment is mainly based on the local virtual machine to practice. So maybe there’s a way out with the production environment.
In addition, the official website of Kubesphere provides a very friendly operation document manual. In fact, most of the practice can be carried out according to the operation of mobile phones provided by the official website. I am mainly here to deepen my understanding and refer to the manual provided by the official website to supplement my own operation notes. For reference only!
Second, the environment
2.1 PREPARING VMS
The first is the configuration information of the vm, such as memory and processor:
In this case, it is recommended to give more memory because the default installation will be installed when the following installation is minimized. After the installation, the memory is insufficient and some components may fail to be installed and scheduled.
2.1 Installing Kubesphere on a single node
PS: The following operation steps, most of the steps provided by the official website!
Website source address: kubesphere.com.cn/docs/quick-…
2.1.1 Preparations and Basic Requirements for Linux Machines
Because my default is to use a clean virtual machine to practice. So the container runtime environment, I did not install, use the official website to provide the installation script, it will automatically install Docker for you by default.
2.1.2 Basic preparations for installing Kubernetes and KubeSphere on Linux
Ps: Basic preparation is key, because the installation will check the relevant environment requirements, such as firewall and swap, Selinux status, etc. These are all closed. And I met a problem in the process of time, I found:
Sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ >/etc/selinux/config when SELINUX is disabled and the installation is restarted
Failed to get etcdctl: Failed to exec command: Sudo – > / bin/sh E – c “docker run – rm – v/usr/local/bin: / systembindir error problem, the final approach: just temporary closure is ok!
Step 1: Turn off the firewall or open the necessary [firewall ports]
[root@k81-master01 ~]#systemctl disable firewalld
[root@k81-master01 ~]#systemctl stop firewalld
[root@k81-master01 ~]#systemctl status firewalld
Copy the code
Step 2: Disable the swap partition
[root@k81-master01 ~]#swapoff -a
[root@k81-master01 ~]#echo "vm.swappiness=0" >> /etc/sysctl.conf
[root@k81-master01 ~]#sysctl -p /etc/sysctl.conf
vm.swappiness = 0
Copy the code
Step 3: Disable the Selinux state
[root@k81-master01 ~]sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config [root@k81-master01 ~]reboot [root@k81-master01 ~]## check Selinux status [root@k81-master01 ~]# getenForce Disabled [root@k81-master01 ~]# Perform temporary shutdown again [root@k81-master01 ~]# setenforce 0Copy the code
Step 4: Configure an EPEL source — Optional
[root@k81-master01 ~]#rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
Copy the code
Step 5 update software packages (recommended)
[root@k81-master01 ~]#yum -y update
Copy the code
Step 6: Install the base dependency components
[root@k81-master01 ~]#yum install -y ebtables socat ipset conntrack
Copy the code
2.1.3 Installing a Single node using KK
KubeKey is a one-click installation tool provided by Kubesphere! Very nice! The following steps are basically step-by-step follow the official website to the document operation can be! I here directly copy over! Ha ha
Step 1: Download KubeKey
First execute the following command to ensure that you download KubeKey from the correct area.
[root@k81-master01 ~]# export KKZONE=cn #Copy the code
Execute the following command to download KubeKey.
The curl - sfL https://get-kk.kubesphere.io | VERSION = v1.1.1 sh -Copy the code
note
After you download KubeKey, if you upload it to a new machine and access to Googleapis is also limited, be sure to run export KKZONE=cn again before you > perform the following steps.
Add executable permission to kk:
chmod +x kk
Copy the code
Step 2: Start one-click installation of Kubernetes and Kubesphere
[root@k81-master01 ~]#./kk create cluster --with-kubernetes v1.20.4 --with-kubesphere v3.1.1 [root@localhost ~]#./kk Create cluster --with-kubernetes v1.20.4 --with-kubesphere v3.1.1 +-------------------------------------+------+------+---------+----------+-------+-------+-----------+---------+-------- ----+-------------+------------------+--------------+ | name | sudo | curl | openssl | ebtables | socat | ipset | conntrack | docker | nfs client | ceph client | glusterfs client | time | +-------------------------------------+------+------+---------+----------+-------+-------+-----------+---------+-------- ----+-------------+------------------+--------------+ | localhost.localdomain.cluster.local | y | y | y | y | y | y | y | 20.10.8 | | | | CST 17:33:14 | +-------------------------------------+------+------+---------+----------+-------+-------+-----------+---------+-------- ----+-------------+------------------+--------------+ This is a simple check of your environment. Before installation, you should ensure that your machines meet all requirements specified at https://github.com/kubesphere/kubekey#requirements-and-recommendations Continue this installation? [yes/no]: yesCopy the code
Step 3: Wait for installation
It's slow. Let's get a cup of coffee!Copy the code
Step 4 after the installation is complete
The following illustration appears:
##################################################### ### Welcome to KubeSphere! # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Console: http://192.168.219.143:30880 Account: admin Password: P @ 88 w0rd NOTES: 1. After you log into the console, please check the monitoring status of service components in "Cluster Management". If any service is not ready, please wait patiently until all components are up and running. 2. Please change the default password after login. ##################################################### https://kubesphere.io 2021-09-13 17:45:52 ##################################################### INFO[17:46:05 CST] Installation is complete. Please check the result using the command: kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -fCopy the code
Step 5 Verify the installation
[root@k81-master01 ~]# kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
Copy the code
The IP address and port number of the Web console are displayed. The default NodePort is 30880. You can now access the console using the default account and password (admin/P@88w0rd) via
:30880.
Step 6: Login experience
2.1.4 useKubeKeyTo add a working node (to form a cluster)
Ps: As of KubeSphere v3.0.0, you can add new nodes to the cluster using the new installer KubeKey. Basically, this operation is based on Kubelet’s registration mechanism. In other words, the new node will automatically join the existing Kubernetes cluster. KubeSphere supports mixed environments, which means that new host operating systems can be CentOS or Ubuntu.
About the node management website document address: kubesphere.com.cn/docs/instal…
Prepare new nodes for my virtual server:
2.1.4.1 Do the basic preparation of Kubernetes and KubeSphere as before
- Step 1: Turn off the firewall or open the necessary [firewall ports]
- Step 2: Disable the swap partition
- Step 3: Disable the Selinux state (reboot)
- Step 4: Configure an EPEL source — Optional
- Step 5: Update software packages (recommended) (You can perform this operation first after the VM is installed, and then disable Selinux.)
- Step 6: Install the base dependency components
2.1.4.2 Downloading Working Nodes KubeKey
Download KubeKey:
First execute the following command to ensure that you download KubeKey from the correct area.
[root@k81-master01 ~]# export KKZONE=cn #Copy the code
Execute the following command to download KubeKey.
The curl - sfL https://get-kk.kubesphere.io | VERSION = v1.1.1 sh -Copy the code
Download KubeKey: Method 2: copy the previously downloaded components directly from the master node to avoid re-downloading related components.
Copy kK to new working node:
[root@localhost ~]# SCP kk [email protected]:/root/ The authenticity of host '192.168.219.144 ' can't be established. ECDSA key fingerprint is SHA256:96v+n8/ZY/wbVqH+R03ZAC9aHwAkG7q15Z7ggmX8f/g. ECDSA key fingerprint is MD5:de:51:eb:c0:ee:61:47:2b:b5:93:d2:a2:10:a5:ff:b9. Are you sure you want to continue connecting (yes/no)? Yes Warning: Permanently added '192.168.219.144' (ECDSA) to the list of known hosts. [email protected]'s password: You have new mail in /var/spool/mail/root [root@localhost ~]#Copy the code
Copy kubekey to new working node:
[root@localhost ~]# tar -cvzf kubekey.tar.gz kubekey kubekey/ kubekey/v1.20.4/ kubekey/v1.20.4/amd64/ Kubekey/v1.20.4 / amd64 / kubeadm kubekey/v1.20.4 / amd64 / kubelet kubekey/v1.20.4 / amd64 / kubectl kubekey/v1.20.4 / amd64 / helm Kubekey v1.20.4 / amd64 / the cni - plugins - Linux - amd64 - v0.8.6. TGZ kubekey/config - localhost. Localdomain. Cluster. The local kubekey/network-plugin.yaml [root@localhost ~]# ll total 125676 -rw-------. 1 root root 1247 Sep 13 16:08 anaconda-ks.cfg -rwxr-xr-x 1 1001 121 13668116 Jul 12 15:02 kk drwxr-xr-x 3 root root 98 Sep 13 16:57 kubekey -rw-r--r-- 1 root root 101624288 Sep 14 11:48 kubekey.tar.gz -rw-r--r-- 1 root root 13341858 Sep 13 16:26 Kubekey-v1.1.1-linux-amd64.tar. gz-rw-r --r-- 1 1001 121 22906 Jul 12 15:00 readme. md-rw-r --r-- 1 1001 121 22845 Jul 12 15:00 readme_zh-cn. md copy [root@localhost ~]# SCP kubekey.tar.gz [email protected]:/root/ [email protected]'s Password: kubekey.tar.gz 100% 97MB 42.9MB/s 00:02 [root@localhost ~]#Copy the code
View the file information of the new working node:
[root@localhost ~]# ll total 112596 -rw-------. 1 root root 1247 Sep 14 11:15 anaconda-ks.cfg -rwxr-xr-x 1 root root 13668116 Sep 14 11:49 kk-rw-r --r-- 1 root root 101624288 Sep 14 11:54 kubekey.tar.gz [root@localhost ~]# [root@localhost ~]# tar -xzvf kubekey.tar.gz kubekey kubekey/ kubekey/v1.20.4/ kubekey/v1.20.4/amd64/ Kubekey/v1.20.4 / amd64 / kubeadm kubekey/v1.20.4 / amd64 / kubelet kubekey/v1.20.4 / amd64 / kubectl kubekey/v1.20.4 / amd64 / helm Kubekey v1.20.4 / amd64 / the cni - plugins - Linux - amd64 - v0.8.6. TGZ kubekey/config - localhost. Localdomain. Cluster. The local kubekey/network-plugin.yaml [root@localhost ~]# ll total 112596 -rw-------. 1 root root 1247 Sep 14 11:15 anaconda-ks.cfg -rwxr-xr-x 1 root root 13668116 Sep 14 11:49 kk drwxr-xr-x 3 root root 98 Sep 13 16:57 kubekey -rw-r--r-- 1 root root 101624288 Sep 14 11:54 kubekey.tar.gz [root@localhost ~]# cd kubekey [root@localhost kubekey]# ll total 192 -rw-r--r-- 1 root root 5583 Sep 13 17:36 config-localhost.localdomain.cluster.local -rw-r--r-- 1 root root 187179 Sep 13 17:36 network-plugin.yaml drwxr-xr-x 3 root root 19 Sep 13 16:26 v1.20.4 [root@localhost kubekey]#Copy the code
2.1.5 Adding a Working Node procedure
Step 1 Use KubeKey on the Master node to search for cluster information.
PS: The preceding command is executed on the Master node
-
Use KubeKey to retrieve cluster information. The following command creates the configuration file (sample.yaml).
[root@localhost ~]# ./kk create config --from-cluster Notice: /root/sample.yaml has been created. Some parameters need to be filled in by yourself, please complete it. Copy the code
note
If you already have configuration files on your machine, you can skip this step. For example, to add a node to a multi-node cluster set up by KubeKey, you might still have the configuration file if you did not remove the cluster.
-
In the configuration file, put information about the new node under hosts and roleGroups. This example adds two new nodes (node1). Here master1 is the existing node.
- 192.168.219.143 is
master
- 192.168.219.144 is
node1
Change the host name of Node:
[root@localhost ~]# hostnamectl ``set``-hostname node1
Copy the code
Edit the file sample.yaml:
apiVersion: kubekey.kubesphere.io/v1alpha1 kind: Cluster metadata: name: sample spec: hosts: # You should complete the ssh information of the hosts - {name: localhost.localdomain.cluster.local, address: 192.168.219.143, internalAddress: 192.168.219.143} - {name: node1, address: 192.168.219.144, internalAddress: 192.168.219.144, user: root, password: 123456} roleGroups: etcd: - localhost. Localdomain. Cluster. The local master: - localhost.localdomain.cluster.local worker: - localhost.localdomain.cluster.local - node1 controlPlaneEndpoint: # If loadbalancer was used, 'address' should be set to loadbalancer's ip. domain: lb.kubesphere.local address: "" port: 6443 kubernetes: version: v1.20.4 clusterName: cluster.local proxyMode: ipvs masqueradeAll: false maxPods: 110 nodeCidrMaskSize: 24 network: plugin: calico kubePodsCIDR: 10.233.64.0/18 kubeServiceCIDR: 10.233.0.0/18 Registry: privateRegistry: ""Copy the code
File modification points:
- If the main host name is already set, do not change it, so it is best to change it at first
- The main EDCT configuration also needs to be specified, using the host on the primary node (of course later you can separate etCD hosts).
Step 2 Run the following command:
[root@localhost ~]# ./kk add nodes -f sample.yaml +-------------------------------------+------+------+---------+----------+-------+-------+-----------+---------+-------- ----+-------------+------------------+--------------+ | name | sudo | curl | openssl | ebtables | socat | ipset | conntrack | docker | nfs client | ceph client | glusterfs client | time | +-------------------------------------+------+------+---------+----------+-------+-------+-----------+---------+-------- ----+-------------+------------------+--------------+ | node1 | y | y | y | y | | y | | | | | | CST 12:36:43 | | Localhost. Localdomain. Cluster. The local | y | y | | | | | | y y y y y 20.10.8 | | | | CST 12:31:12 | +-------------------------------------+------+------+---------+----------+-------+-------+-----------+---------+-------- ----+-------------+------------------+--------------+ node1: conntrack is required.Copy the code
Then do it again:
[root@localhost ~]# ./kk add nodes -f sample.yaml
Copy the code
The result is as follows:
Step 3 Wait for the installation of the working node.
It is suggested that the working node install Docker directly first, if kK is installed, it will be a little slow! Patience is needed!Copy the code
PS: If it still doesn’t work for a long time, abort it again!!
INFO[13:58:51 CST] Joining nodes to cluster
[node1 192.168.219.144] MSG:
[preflight] Running pre-flight checks
[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.8. Latest validated version: 19.03
[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'
W0914 14:04:24.425611 18613 utils.go:69] The recommended value for "clusterDNS" in "KubeletConfiguration" is: [10.233.0.10]; the provided value is: [169.254.25.10]
[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.
[node1 192.168.219.144] MSG:
node/node1 labeled
INFO[13:59:09 CST] Congratulations! Scaling cluster is successful.
[root@localhost ~]#
Copy the code
After the above problem is prompted, check the node added successfully!!
Step 4 View node information.
The above is just a personal combination of their own actual needs, do study practice notes! If there are clerical errors! Welcome criticism and correction! Thank you!
At the end
END
Jane: www.jianshu.com/u/d6960089b…
The Denver nuggets: juejin. Cn/user / 296393…
Public account: wechat search [children to a pot of wolfberry wine tea]
Let students | article | QQ: welcome to learn communication 】 【 308711822