Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Deploy a kubernets single-node cluster using kubeadm

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Experimental topology diagram:

Experimental environment:

First turn off the firewall of the three hosts

Add three network cards to three hosts respectively

The first network card enables the node network set to 172.20.0.0and16 fields.

The second network card is set to the pod network with the field 10.244.0. 0.

The third network card is set to the service network with the field 10.96.0.0plus 12.

Set the hostname of the three hosts and configure the / etc/hosts of the three hosts so that the three hosts can resolve addresses according to the hostname

Note: make sure that the kernel of the three hosts has been upgraded to more than 4.0 before installing the service.

The first step is the initialization of master node

Download the rpm package using Aliyun's mirror site

First download the repo file of the docker mirror site, wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo, manually configure the repo file of the kubernets mirror site [kubernets] name=kubernetsbaseurl= https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/enabled=1gpgcheck=0 to rebuild the yum repository yum repolist

Install the appropriate package on the master node

Configure the service file and set it to boot

The yum install-y docker-ce kubeadm kubectlsystemctl restart dockersystemctl enable dockersystemctl enable kubelet / / kubelet service component does not start to change the data in the following two configuration files to 1/proc/sys/net/bridge/bridge-nf-call-iptables/proc/sys/net/bridge/bridge-nf-call-ip6tables before completing init initialization. Vim / etc/sysconfig/kubeletKUBELET_EXTRA_ARGS= function vim / etc/sysconfig/kubeletKUBELET_EXTRA_ARGS= "--fail-swap-on=false" is executing the kubead init control node Add-- ignore-preflight-errors=Swap option during initialization

It should be noted when initializing the master node with kubeadm init. Because the K8s image repository cannot be accessed, you need to use the docker service to pull down the required K8s image from the dockerhub repository in advance, and then re-tag it.

Configure the accelerator for the docker service

Vim / etc/docker/daemon.json {"registry-mirrors": ["https://rvnrd340.mirror.aliyuncs.com"] / / accelerated image site of Ali Cloud} restart the docker service systemctl daemon-reloadsystemctl restart docker

Get the image from dockerhub. The latest version of the image is used here.

Replace the label of the image after download

Docker pull mirrorgooglecontainers/kube-apiserver-amd64:v1.15.0docker pull mirrorgooglecontainers/kube-apiserver-amd64:v1.15.0docker pull mirrorgooglecontainers/kube-controller-manager-amd64:v1.15.0docker pull mirrorgooglecontainers/kube-scheduler-amd64:v1.15.0docker pull mirrorgooglecontainers/kube-proxy-amd64:v1.15.0docker pull mirrorgooglecontainers/pause:3.1docker pull mirrorgooglecontainers/etcd-amd64:3.3.10docker pull coredns/coredns:1.3.1

Change label

Docker tag docker.io/mirrorgooglecontainers/kube-proxy-amd64:v1.15.0 k8s.gcr.io/kube-proxy-amd64:v1.15.0docker tag docker.io/mirrorgooglecontainers/kube-scheduler-amd64:v1.15.0 k8s.gcr.io/kube-scheduler-amd64:v1.15.0docker tag docker.io/mirrorgooglecontainers/kube-apiserver-amd64:v1.15.0 k8s.gcr.io/kube-apiserver-amd64:v1.15.0docker tag docker.io/mirrorgooglecontainers/kube-controller-manager-amd64 : v1.15.0 k8s.gcr.io/kube-controller-manager-amd64:v1.15.0docker tag docker.io/mirrorgooglecontainers/etcd-amd64:3.3.10 k8s.gcr.io/etcd-amd64:3.3.10docker tag docker.io/mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1docker tag docker.io/coredns/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1

Start cluster control node initialization

Kubeadm init-pod-network-cidr=10.244.0.0/16-service-cidr=10.96.0.0/12-ignore-preflight-errors=Swap

Save the last generated key information, which is needed when deploying the control node.

Kubeadm join 172.20.128.2 6443-token vasw7s.h3v3fe3mzg3pqgil\-discovery-token-ca-cert-hash sha256:c2f2fafd5d43f23a23e9b15c9965c10708c45dbdc07b544912b9e9394a7a2b45

Configure the basic environment

Mkdir-p $HOME/.kubecp-I / etc/kubernetes/admin.conf $HOME/.kube/config installation and deployment flannel Network Accessories kubectl apply-f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml check whether the k8s cluster component is running kubectl get pods-n kube-system

At this point, the mstaer deployment is complete, and then install and deploy the two node nodes

Copy the repo file of the mirror site of the master node to the two node nodes, and turn off the firewall of the node node

Scp / etc/yum.repos.d/docker-ce.repo node1:/etc/yum.repos.d/scp / etc/yum.repos.d/kubernets.repo node1:/etc/yum.repos.d/scp / etc/yum.repos.d/docker-ce.repo node2:/etc/yum.repos.d/scp / etc/yum.repos.d/kubernets.repo node2:/etc/yum.repos.d/systemctl stop firewalldsystemctl disable firewalld installation and deployment software yum install-y docker-ce kubelet kubeadm Disable swap function vim / etc/sysconfig/kubeletKUBELET_EXTRA_ARGS= "--fail-swap-on=false" enable docker service systemctl start dockersystemctl enable docker settings kubeletl boot auto start systemctl enable kubelet set the contents of the two files as 1echo "1" > / proc/sys/net/bridge/bridge-nf-call-iptablesecho "1" > / proc/sys/net/bridge/bridge-nf-call-ip6tables you will need the following to execute the command to join the node node to the cluster Three mirrors copy the image package directly from the master node to the node node docker save-o myimage.gz k8s.gcr.io/kube-proxy quay.io/coreos/flannel k8s.gcr.io/pausescp muimage.gz node1:/scp muimage.gz node2:/ expand the package docker load-I myimages.gz on two node nodes and execute the key information generated by the master node on the two node nodes Note that the command parameter kubeadm join 172.20.128.2 discovery-token-ca-cert-hash sha256:c2f2fafd5d43f23a23e9b15c9965c10708c45dbdc07b544912b9e9394a7a2b45 6443-- token vasw7s.h3v3fe3mzg3pqgil-- discovery-token-ca-cert-hash sha256:c2f2fafd5d43f23a23e9b15c9965c10708c45dbdc07b544912b9e9394a7a2b45-- ignore-preflight-errors=Swap that ignores swap is added at the end.

Execute kubectl get nodes to view the running status information of the entire cluster

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report