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

How kubeadm deploys multi-node master clusters

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

How to deploy multi-node master cluster in kubeadm, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Version information

Linux Centos7kubernetes v1.14.5docker v18.06.1-ce

Node information

VIP:47.110.19.11 Ali Cloud load balancer

Pre-installation preparation

Make sure that all nodes have normal network and access to the public network before starting the deployment. The main operations are carried out on the VPC-OPEN-MASTER001 node, and setting VPC-OPEN-MASTER001 can log in to other nodes without a password. All operations are done using the root user identity.

Server description

We are using five centos-7.6 virtual machines here. Details are as follows: system type IP address node role CPU Memory Hostnamecentos-7.6 192.168.3.42 master > = 2 > = 4G master01centos-7.6 192.168.3.43 master > = 2 > = 4G master02centos-7.6 192.168.3.44 master > = 2 > = 4G master03centos-7.6 192.168.3.45 worker > = 2 > = 4G node01centos-7.6 192.168.3.46 worker > = 2 > = 4G node02

I. Environmental preparation

1. Set the host name

# check the host name $hostname# modify the host name $hostnamectl set-hostname huoban-k8s-master01# configure host so that all nodes can access each other through hostname > 2, configure hosts to resolve vim / etc/hosts

192.168.3.42 huoban-k8s-master01 master01

192.168.3.43 huoban-k8s-master02 master02

192.168.3.44 huoban-k8s-master03 master03

192.168.3.45 huoban-k8s-node01 node01

192.168.3.46 huoban-k8s-node02 node02

> 3. Install dependency package update yum

$yum update

Install dependency packages

$yum install-y conntrack ipvsadm ipset jq sysstat curl iptables libseccomp

> 4. Disable firewall and swap, and reset iptables to disable firewall.

$systemctl stop firewalld & & systemctl disable firewalld

Reset iptables

$iptables-F & & iptables-X & & iptables-F-t nat & & iptables-X-t nat & & iptables-P FORWARD ACCEPT

Close swap

$swapoff-a

$sed-I'/ swap/s/ ^ (. *) $/ #\ 1Universe g'/ etc/fstab

Close selinux

$setenforce 0

Close dnsmasq (otherwise the docker container may not be able to resolve the domain name)

$service dnsmasq stop & & systemctl disable dnsmasq

> 5. Make configuration file by setting system parameters

$cat > / etc/sysctl.d/kubernetes.conf 1. Configuring kubelet the following operations require reloading the kubelet system configuration on all nodes

Systemctl daemon-reload

Set boot to boot, do not start kubelet for the time being

Systemctl enable kubelet

> 2. Initialize the cluster according to the configuration file and use kubeadm-config.yaml to configure k8s1.14.5 cluster cat init.sh

LOAD_BALANCER_DNS= "47.110.19.11"

LOAD_BALANCER_PORT= "6443"

Generate kubeadm configuration file

Cat > kubeadm-master.config 4, install network plug-ins

Kubectl apply-f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

> 5. Copy master certificate to other node cat scp.sh

USER=root

CONTROL_PLANE_IPS= "192.168.3.43 192.168.3.44"

For host in ${CONTROL_PLANE_IPS}; do

Scp / etc/kubernetes/pki/ca.crt "${USER}" @ $host:

Scp / etc/kubernetes/pki/ca.key "${USER}" @ $host:

Scp / etc/kubernetes/pki/sa.key "${USER}" @ $host:

Scp / etc/kubernetes/pki/sa.pub "${USER}" @ $host:

Scp / etc/kubernetes/pki/front-proxy-ca.crt "${USER}" @ $host:

Scp / etc/kubernetes/pki/front-proxy-ca.key "${USER}" @ $host:

Scp / etc/kubernetes/pki/etcd/ca.crt "${USER}" @ $host:etcd-ca.crt

Scp / etc/kubernetes/pki/etcd/ca.key "${USER}" @ $host:etcd-ca.key

Scp / etc/kubernetes/admin.conf "${USER}" @ $host:

Ssh ${USER} @ ${host} 'mkdir-p / etc/kubernetes/pki/etcd'

Ssh ${USER} @ ${host}'mv / ${USER} / ca.crt / etc/kubernetes/pki/'

Ssh ${USER} @ ${host}'mv / ${USER} / ca.key / etc/kubernetes/pki/'

Ssh ${USER} @ ${host}'mv / ${USER} / sa.pub / etc/kubernetes/pki/'

Ssh ${USER} @ ${host}'mv / ${USER} / sa.key / etc/kubernetes/pki/'

Ssh ${USER} @ ${host}'mv / ${USER} / front-proxy-ca.crt / etc/kubernetes/pki/'

Ssh ${USER} @ ${host}'mv / ${USER} / front-proxy-ca.key / etc/kubernetes/pki/'

Ssh ${USER} @ ${host}'mv / ${USER} / etcd-ca.crt / etc/kubernetes/pki/etcd/ca.crt'

Ssh ${USER} @ ${host}'mv / ${USER} / etcd-ca.key / etc/kubernetes/pki/etcd/ca.key'

Ssh ${USER} @ ${host}'mv / ${USER} / admin.conf / etc/kubernetes/admin.conf'

Done

7. Deployment on other nodes

# master

Kubeadm join 47.110.19.11 discovery-token-ca-cert-hash sha256:62579157003c3537deb44b30f652c500e7fa6505b5ef6826d796ba1245283899 6443-token qlrq5y.1yhm3rz9r7ynfqf1-discovery-token-ca-cert-hash sha256:62579157003c3537deb44b30f652c500e7fa6505b5ef6826d796ba1245283899-experimental-control-plane

# node

Kubeadm join 47.110.19.11 discovery-token-ca-cert-hash sha256:62579157003c3537deb44b30f652c500e7fa6505b5ef6826d796ba1245283899 6443-token qlrq5y.1yhm3rz9r7ynfqf1-discovery-token-ca-cert-hash sha256:62579157003c3537deb44b30f652c500e7fa6505b5ef6826d796ba1245283899

This is the answer to the question about how to deploy multi-node master clusters in kubeadm. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

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