This is the 15th day of my participation in the August More Text Challenge. For details, see:August is more challenging
【K8S series 】 K8S learning two, Kubernetes core concepts and preliminary understanding of the installation and deployment mode
Let’s review the components of the K8S cluster architecture again, and find a cluster architecture diagram on the Internet
1. Master component
- apiserver
Unified entrance to the cluster, restful way, and finally to etCD storage
- shcheduler
Node scheduling: Select nodes for application deployment
- controller-manager
This section describes how to handle common background tasks in a cluster. One resource corresponds to one controller
- etcd
Storage system used to store data related to the cluster
2. Node component: work node
- kubelet
Master is represented by node and manages local containers
- kube-proxy
Provides network proxy and load balancing operations
K8s core concept
1, the Pod
- The smallest deployed logical unit
- Is a collection of containers
- Sharing network
- Short life cycle
2, the controller
- Ensure the expected number of Pod copies
- Stateless application deployment/Stateless application deployment
- Make sure all nodes are running the same Pod
- Execute one-off tasks and scheduled tasks
3, the service
- Defines a set of access rules for pods
Kubernetes:
- Use the official minikube
- Deploy with Kubeadmin, the k8s deployment tool, running inside k8S, which is relatively easy to use
Kubeadmin Provides kubeadmin Init and kubeadmin Join for rapid deployment of the K8S cluster
Website address is: kubernetes. IO/docs/refere…
- I use kubernetes binary installation and deployment (this deployment mode, we must go through this step when learning, step by step to build, in order to encounter a lot of problems, and then solve him, familiar with him)
Official minikube
minikube
Click Launch Terminal to view the following interface
The official version of Minikube is V1.8.1
The system is Ubuntu 18.04
CPU 2 nuclear
The memory of 2 G
The disk is about 145 GB
Kubernetes version v1.17.6
The Docker version 19.03.6
We can use kubectl get Pods -n kube-system to check out the Pod node
Kubeadmin for deployment
Using Kubeadmin to deploy is easier than using binary, so let’s plan the deployment first
Platform planning
Single Master configuration mode
Multi-master configuration mode
Kubeadmin starts deployment
Use kubeadmin to deploy k8S environment. Deploy Kubernetes by following two instructions:
- kubeadm init
Create a master node
- Kubeadm join
Add node to the cluster
Test environment hardware requirements
Master node: 2-core, 2 GB, and 20 GB disks
Node node: four cores, 8 GB, and 80 GB disks
- One or more machines, operating system optional, can be Ubuntu, centos
- Hardware configuration:
- All nodes in the cluster are communicating correctly
- You can access the Internet and pull mirrors
- Disable swap
Let’s install Kubectl first
There are four ways to install Kubecrl
- Use curl to install Kubectl on Linux
- Install using the native package management tool
- Install with another package management tool
- Install on Linux as part of the Google Cloud SDK
Let’s use the first one directly:
1. Run the following command to download the latest kubectl version
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Copy the code
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"
Copy the code
3, verify kubectl executable file
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
# echo "$(<kubectl.sha256) kubectl" | sha256sum --check
kubectl: OK
Copy the code
If the preceding situation occurs, the verification succeeds
Install Kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Copy the code
5. Check the version we installed
kubectl version --client
# kubectl version --clientClient Version: Version. The 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"}Copy the code
- GitVersion
Git version is V1.22.0
- GoVersion
The go version is 1.16.6
- BuildDate
The build time is 2021-08-04T18:03, which is quite new
Configure kubectl autocomplete
Kubectl’s auto-completion relies on bash-completion, so we need to install it
1. Install bash-completion
apt-get install bash-completion
2. Start kubectl autocomplete 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 shell completion to accommodate the alias
echo 'alias k=kubectl' >>~/.bashrc
echo 'complete -F __start_kubectl k' >>~/.bashrc
Copy the code
The installation and deployment of Kubernetes is relatively a bit much, this must be their own step by step practice, otherwise it is not to learn things, you can be more in the official website touch fish
Kubernetes. IO/docs/tasks /…
References:
kubernetes docs
Welcome to like, follow and collect
Dear friends, your support and encouragement are the motivation for me to keep sharing and improve the quality
All right, that’s it for this time
Technology is open, our mentality, should be more open. Embrace change, live in the sun, and strive to move forward.
I am nezha, welcome to like the collection, see you next time ~