#!/bin/bash
# Author: Michael Lee
# Email: xxx@163.com
# Date: 07/26/2022
# Filename: etcd.sh


# 定义变量
url="https://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz"
path="/root/etcd"


# 下载 etcd 客户端并加入环境变量
if [ ! -d "$path" ];then
    mkdir $path
fi

cd $path && wget $url && tar -zxf *.tar.gz
mv */etcdctl /usr/local/bin && chmod +x /usr/local/bin/


# 查看 etcdctl 版本
etcdctl version


# 查看 etcd 高可用集群健康状态
ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key --write-out=table --endpoints=192.168.200.3:2379,192.168.200.4:2379,192.168.200.5:2379 endpoint health


# 查看 etcd 高可用集群列表
ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key --write-out=table --endpoints=192.168.200.3:2379,192.168.200.4:2379,192.168.200.5:2379 member list


# 查看 etcd 高可用集群 leader
ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key --write-out=table --endpoints=192.168.200.3:2379,192.168.200.4:2379,192.168.200.5:2379 endpoint status

注意:需要修改脚本里面证书的路径,不要直接运行。这个脚本是运行在 kubeadm 部署的 k8s 集群上的,二进制部署的不敢保证适合。

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐