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

What is the Etcd3 cluster building in kubernetes practice?

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces you to the Etcd3 cluster construction in kubernetes practice. The content is very detailed. Interested friends can refer to it for reference. I hope it can help you.

1: Etcd Profile

ETCD is a distributed, consistent KV storage system for shared provisioning and service discovery. Similar to Zookeeper.

ETCD usage scenarios: configuration management, service registration with discovery, master selection, application scheduling, distributed queues, distributed locks.

ETCD uses the Raft protocol to maintain state consistency among nodes in the cluster. In short, ETCD cluster is a distributed system, composed of multiple nodes communicating with each other to form an overall external service, each node stores complete data, and through the Raft protocol to ensure that the data maintained by each node is consistent.

2: Etcd3 Cluster Background

10.116.137.196 k8s_master

10.116.82.28 k8s_node1

10.116.36.57 k8s_node2

Etcd version: etcd-v3.1.8-linux-amd64.tar.gz (https://github.com/coreos/etcd/releases)

Etcd3 installation

1. vi /etc/profile

export ETCDCTL_API=3

2. Shut down the system firewall.

systemctl disable firewalld

systemctl stop firewalld

3. installation

tar -zxvf etcd-v3.1.8-linux-amd64.tar.gz

cp etcd /usr/bin/

cp etcdctl /usr/bin/

Create the/etc/etcd/etcd.conf configuration file

Create the/usr/lib/systemd/system/etcd.service systemctl startup file.

4. Configuration file (blue background is where the three nodes need to be modified)

etcd.service

Click here to fold or open

[Unit]

Description=Etcd Server

After=network.target

After=network-online.target

Wants=network-online.target

[Service]

Type=notify

WorkingDirectory=/var/lib/etcd/

EnvironmentFile=/etc/etcd/etcd.conf

ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\" --data-dir=\"${ETCD_DATA_DIR}\" --listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\" --listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" --advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\" --initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" --initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" --initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""

Restart=on-failure

LimitNOFILE=65536

[Install]

WantedBy=multi-user.target

etcd.conf configuration file (https://github.com/coreos/etcd/blob/master/etcd.conf.yml.sample)

Click here to fold or open

# [member]

ETCD_NAME=k8s_master

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

ETCD_LISTEN_PEER_URLS="http://120.25.154.90:2380"

ETCD_LISTEN_CLIENT_URLS="http://120.25.154.90:2379,http://127.0.0.1:2379"

# [cluster]

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://120.25.154.90:2380"

ETCD_INITIAL_CLUSTER="k8s_master=http://120.25.154.90:2380,k8s_node1=http://120.25.220.176:2380,k8s_node2=http://112.74.105.178:2380"

ETCD_INITIAL_CLUSTER_STATE="new"

ETCD_INITIAL_CLUSTER_TOKEN="k8s-etcd-cluster"

ETCD_ADVERTISE_CLIENT_URLS="http://120.25.154.90:2379"

5. Start the etcd service with systemctl start and add the service to the boot list with systemctl enable

systemctl daemon-reload

systemctl enable etcd.service

systemctl start etcd.service

6. Start Result Query

IV: Etcd configuration parameter description (https://coreos.com/etcd/docs/latest/op-guide/configuration.html)

Click here to fold or open

Etcd parameters are configured in two ways, one is the command-line way, and the other is the environment variable way. Command-line mode takes precedence over environment variable mode.

Etcd defaults to port 2379 to handle client requests; port 2380 is used for communication between cluster members.

#[member]

-name or ETCD_NAME:

Specifies that the name of the current etcd member defaults to "default," usually named by the user Hostname.

-data-dir or ETCD_DATA_DIR:

etcd data file directory, default is "${name}.etcd"

-snapshot-count or ETCD_SNAPSHOT_COUNT:

Specifies how many commit operations trigger a disk snapshot, default is 10000

- heartbeat interval or ETCD_ELECTION_TIMEOUT:

Heartbeat signal interval, millisecond level, default is 100 milliseconds.

- liste-peer-urls or ETCD_LISTEN_PEER_URLS

The address used to listen for outgoing messages from other members of the cluster. Default is "http://localhost:2380"

- liste-client-urls or ETCD_LISTEN_CLIENT_URLS:

The address used to listen for messages from clients. Default value is "http://localhost:2379"

-max-snapshots or ETCD_MAX_SNAPSHOTS

Maximum number of image files, default is 5.0 means unlimited

-max-wals or ETCD_MAX_WALS:

#[cluster]

- initial-advertisement-peer-urls or ETCD_INITIAL_ADVERTISE_PEER_URLS:

The address where nodes in the cluster communicate with each other.

-initial-cluster or ETCD_INITIAL_CLUSTER:

The default is "default =http://localhost:2380"

-initial-cluster-state or ETCD_INITIAL_CLUSTER_STATE

The initial state of the cluster, with values of "new" and "existing", default is "new"

-initial-cluster-token:ETCD_INITIAL_CLUSTER_TOKEN:

cluster name

-advertise-client-urls or ETCD_ADVERTISE_CLIENT_URLS:

client-cluster communication address

About kubernetes practice Etcd3 cluster building is how to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

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

Internet Technology

Wechat

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

12
Report