[K8S&K3S]Single node deployment for K8S
Single node deployment for K8S
The content of this experiment is the experiment of K8S deployment with kubeadm single node in ubuntu18.04 2 core 4G memory environment
Environment Introduction
why use ubuntu ?
centos7 ubuntu18,.04 and win10 ,They are popular operating systems that support kbueadm
Our next experiment is a test under the same environment as K3S
K3s is not perfect for Centos and does not support Win10
so we use ubuntu18.04 to test.
why use 2core and 4G memory Run the configure ?
Because this is the limit min configure of one single k8s requirements.
But the k3s is requeirement 1core and 512MB to run.
Environment construction
I use vmvare in a Windows10 environment
Because the virtual machine environment for configuration upgrade cloning and server rollback is very convenient compared to the physical computer is more suitable for rapid experiments.
Of course, if you have the ability or try to choose a physical machine for the experiment
The experimental steps
- Start experimenting from remote SSH entry to the server
- Close disk Swap to improve performance
swapoff - a
- Configure the network accordingly
modprobe br_netfilter
echo 1 > /proc/sys/net/ipv4/ip_forward
- install docker
- Due to the special network environment in China added by Aliyun, China's accelerated foreign users can not join -mirror Aliyun environment
curl -fssl https://get.docker.com | bash -s docker --mirror aliyun
It is recommended that the virtual machine after docker installation should be used for snapshot storage in subsequent experiments. We can quickly clone the current environment
4. Quickly deploy Kubernetes clusters using the Kubeadm tool provided by the Official Kubernetes
1. Since the default pull mirror address k8S. gCR. IO cannot be accessed in China, the address of Aliyun mirror warehouse is specified here.
2.
kubeadm init --cri-socket /run/containerd/containerd.sock --pod-network-cidr=10.244.0.0/16 --node-name=master --image-repository registry.cn-hangzhou.aliyuncs.com/google_containers --kubernetes-version v1.18.2
- After waiting for some time, the K8S cluster has been successfully deployed and I still need to do some configuration before the deployment is officially successful
rm -rf $HOME/.kube
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
The configuration file is placed in the Kube /config folder for us to modify the configuration later
6. Mark the primary node as available for POD scheduling
kubectl taint nodes master node - role. Kubernetes. io/master -
- Install the Flannel Network plug-in
kubectl create -f/share/lesson/ kubernetes/kube - flannel. Yml
- Verify that THE POD is working within the cluster
kubectl get Po - a
At this point we have successfully configured a single-node test environment
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-546565776c-4k6cn 1/1 Running 0 6m16s
kube-system coredns-546565776c-sdd4n 1/1 Running 1 6m16s
kube-system etcd-master 1/1 Running 0 6m25s
kube-system kube-apiserver-master 1/1 Running 0 6m25s
kube-system kube-controller-manager-master 1/1 Running 0 6m25s
kube-system kube-flannel-ds-amd64-glzlx 1/1 Running 0 54s
kube-system kube-proxy-gzkbf 1/1 Running 0 6m17s
kube-system kube-scheduler-master 1/1 Running 0 6m25s
- Validation node
kubectl get node
NAME STATUS ROLES AGE VERSION
master Ready master 6m40s v1.18.2
The experimental conclusion
Isn't it easy to deploy a single-node K8S
I met some problems during the experiment
-
Docker installation problems
- The Chinese environment USES Sudo Install Docker-CE too slowly => Switch to the official installation script Support to reference Chinese mirror source for acceleration effect
-
K8s failed to pull docker image => Google servers are not accessible in China Configuring China Aliyun's mirror site in Hangzhou, Zhejiang, China solves this problem
-
Kubeadm init failed
- Did not close disk SWAP
-
Unable to operate with Kubectl
- The primary node is not marked as available for POD scheduling
- The Flannel network plug-in was not installed
It may seem simple, but the first time you use it, you have a lot of problems
The next experiment will make it easier and faster to deploy K3S in the same
environment with a one-click setup script from rancher K3s
The experience of a single node is not that different
Subsequent multi-node deployments will be more complex and the k3S and K8S installation experiences will be more different