Install Kubernetes

KubernetesAn overview of the

Kubernetes(hereinafter referred to as K8S) is a complete distributed system support platform. Security protection, load balancing, and multi-granularity resource quota management capabilities.

The following describes the components of K8S


Service

  • ServiceIs the core of the distributed cluster architecture, aServiceThe object has the following key characteristics.
    • Have a uniquely specified name (such as Redis-server).
    • Has a virtual IP(Cluster IP or VIP) and a port number.
    • Can provide some kind of remote service capability.
    • Can be mapped to a set of container applications that provide this service capability.

Pod

  • PodIs the smallest administrative element of K8S.
    • It is a combination of one or more containers. Do these containers share storage, networks, and namespaces, as well as specifications for how to operate
    • aPodThe shared context ofLinuxNamespace,cgroupsAnd other potentially quarantined content
    • In differentPodContainers in, have differentIPAddress, and therefore cannot communicate directly between processes. Commonly used between containersPod IPAddress to communicate.
    • PodRunning on nodesNodeOn the environment.
    • eachPodRun a special containerPause. Others are business containers.
    • These business containers sharePauseThe container’s network stack andVolumeMount the volume.

Node

  • Node is the host on which the Pod actually runs. It can be a physical machine or a virtual machine.
    • To manage pods, each Node must run at least the Container Runtime (such as Docker or RKT), Kubelet, and Kube-Proxy services.
    • These processes are responsible forPodCreate, start, monitor, restart, destroy, and implement software mode load balancer.
    • The node status information contains
      • Addresses. Describes network Addresses
      • Condition. Describe allRunningNode status
      • Capacity. Describes the hardware resources available on the node:CPU.RAM.DISKThe biggestPodNumber, etc.
      • Info. Description Basic node information. For example, the kernel version and OS name.

Set upKubernetes

System to prepare

* OS: CentOS Linux Release 7 + * USER: root 1+ (if CPUNumber is less than 2, 'kubeadm init' needs to add '--ignore-preflight-errors=NumCPU' option * RAM: 2Gib+Copy the code

The machine to prepare

OS CPU RAM LocaoIP NOTE
CentOS Linux release 7.3 1 2Gib 172.17.50.23 master
CentOS Linux release 7.3 1 2Gib 172.17.50.24 node1
CentOS Linux release 7.3 1 2Gib 172.17.50.25 node2

Deployment steps

Disabling the Firewall
sudo systemctl stop firewalld
sudo systemctl disable firewalld
Copy the code
Shut downSELINUX
## Temporary shutdown
sudo setenforce 0
## Permanently closed
sudo sed "s/SELINUX=*/SELINUX=disabled/g" -i /etc/selinux/config
Copy the code
Shut downswap
sudo swapoff -a
Copy the code
Set iptables not to process bridge data
sudo cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system
Copy the code
The installationDocker(v18.06.3)
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

## Change to Ali Yunyuansudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sudo yum makecache Fast sudo yum-y --setopt= Obsoletes =0 Install Docker-ce-18.06.3. Ce 3.el7 \ Docker-ce-selinux-18.06.3. Ce 3.el7## Now enable and set boot auto
sudo systemctl enable docker && systemctl start docker
Copy the code
addK8SThe source
## The default source is Google
sudo cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
Copy the code
The installationkubelet kubeadm kubectl
sudo yum install -y kubelet kubeadm kubectl

## Set boot
sudo systemctl enable kubelet && systemctl start kubelet
Copy the code

checkKubernetesversion

# kubectl version

Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:20:10Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
Copy the code

At this point, Kubernetes is installed on the master, leaving the rest of the Node machines to follow the steps

Or use the one-click install command below to deploy


One-click install command

curl -sSL https://raw.githubusercontent.com/charSLee013/Kubernetes-learn/master/chapter01/kubernetes-centos-install.sh | bash
Copy the code

Matters needing attention

  • The one-click install command will putyumThe source toAliyun
  • According to thePod NetworkDepending on the selection, some components may need to be enablediptablesForwarding function (please refer to the component’s official website for details)

To learn more about this article, click here