Let’s review K8S cluster architecture, and find a cluster architecture diagram on the Internet to illustrate the wave
1. The master component
- apiserver
Unified entrance of the cluster, restful way, and finally handed over to etcd storage
- shcheduler
Node scheduling, select node node for application deployment
- controller-manager
Handle regular background tasks in the cluster, one resource corresponds to one controller
- etcd
Storage system, used to store cluster-related data
2. Node component, working node
- kubelet
The master is arranged to the node representative to manage the container of the machine
- kube-proxy
Provide network proxy, load balancing and other operations
k8s core concept
1、Pod
- Minimal deployment logic unit
- Is a collection of containers
- Shared network
- Short life cycle
2、controller
- Ensure the expected number of Pod copies
- Stateless application deployment / Stateful application deployment
- Ensure that all nodes run the same Pod
- Perform one-time tasks and timed tasks
3、service
- Define a set of Pod access rules
Kubernetes installation method:
- Use the official minikube
- Use kubeadmin for deployment. The k8s deployment tool runs in k8s. This is relatively simple to use
kubeadmin provides kubeadmin init and kubeadmin join for rapid deployment of k8s cluster
The official website address is: https://kubernetes.io/docs/reference/setup-tools/kubeadm/
- Use the kubernetes binary method to install and deploy by yourself (this deployment method, we must take this step when we learn, and build it step by step, so that we can encounter many problems, and then solve him and become familiar with him)
Official minikube
Click Launch Terminal, you can see the following interface
The official version of minikube provided to us is v1.8.1
The system is Ubuntu 18.04
CPU 2 core
RAM 2 G
Disk around 145 G
Kubernetes version v1.17.6
Docker version 19.03.
We can use kubectl get pods -n kube-system
check the pod node
kubeadmin for deployment
Use kubeadmin to deploy, it is simpler and easier than using binary to deploy. Let's plan the deployment plan first.
Platform Planning
Single master construction method
Multi-master construction method
kubeadmin began to deploy
Use kubeadmin to deploy the k8s environment, and complete the deployment of kubernetes through the following two instructions:
- kubeadm init
Create a master node
- kubeadm join <IP and port of master node>
Add the node node to the cluster
test environment hardware requirements
master node: 2 cores, 2G, disk 20G
node node: 4 cores, 8G, disk 80G
- One or more machines, the operating system is optional, it can be ubuntu or centos
- The hardware configuration is as above
- All nodes in the cluster communicate with each other
- Can access the external network, can pull the mirror image
- Prohibit swap partition
first install kubectl
The official provides 4 ways to install kubecrl
- Use curl to install kubectl in Linux system
- mounting native package management tool
- with other package management tools installed
- part of Google Cloud SDK, install
Let's use the first type directly:
1. Use the following command to download the latest version of kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
2. Download the kubectl checksum file
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
3. Verify the executable file of kubectl
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
# echo "$(<kubectl.sha256) kubectl" | sha256sum --check
kubectl: OK
In the above situation, in order to pass the verification
4. Install kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
5. Check the version we installed
kubectl version --client
# kubectl version --client
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.0", GitCommit:"c2b5237ccd9c0f1d600d3072634ca66cefdf272f", GitTreeState:"clean", BuildDate:"2021-08-04T18:03:20Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
- GitVersion
The version of git is v1.22.0
- GoVersion
The version of go is 1.16.6
- BuildDate
The build time is 2021-08-04T18:03, which is fairly new
Configure kubectl auto-completion function
The auto-completion function of kubectl relies on bash-completion, so we need to install it
1. Install bash-completion
apt-get install bash-completion
2. Start kubectl auto-completion function
Import (source) the completion script in ~/.bashrc
echo 'source <(kubectl completion bash)' >>~/.bashrc
Add the completion script to the directory /etc/bash_completion.d
kubectl completion bash >/etc/bash_completion.d/kubectl
If kubectl has an associated alias, you can extend the shell completion to adapt this alias
echo 'alias k=kubectl' >>~/.bashrc
echo 'complete -F __start_kubectl k' >>~/.bashrc
The installation and deployment method of kubernetes has a lot of steps. This must be practiced step by step by yourself, otherwise you will not be able to learn anything. You can find more on the official website.
https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
Reference materials:
Welcome to like, follow, favorite
Friends, your support and encouragement are my motivation to keep sharing and improve quality
Okay, that's it for this time
Technology is open, and our mindset should be more open. Embrace the change, live toward the sun, and work hard to move forward.
I’m Nezha , welcome to like and follow the collection, see you next time~
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。