十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
一、安装前准备
我们注重客户提出的每个要求,我们充分考虑每一个细节,我们积极的做好网站制作、成都网站建设服务,我们努力开拓更好的视野,通过不懈的努力,创新互联赢得了业内的良好声誉,这一切,也不断的激励着我们更好的服务客户。 主要业务:网站建设,网站制作,网站设计,重庆小程序开发,网站开发,技术开发实力,DIV+CSS,PHP及ASP,ASP.Net,SQL数据库的技术开发工程师。
etcd软件版本:etcd-v3.3.10-linux-amd64.tar.gz
系统:centos7.3
防火墙关闭
systemctl stop firewalld
systemctl disable firewalld
selinux关闭
配置/etc/hosts(三台操作)
192.168.159.121 k8s-master-01
192.168.159.122 k8s-node01
192.168.159.123 k8s-node02
配置时间同步
yum-yinstall ntpdate
crontab–e
#时间同步
*/5 * * * * /usr/sbin/ntpdate 0.asia.pool.ntp.org
二、配置免密钥登录(三台操作)
三台先操作
ssh-keygen
三台操作
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-node01
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-node02
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-master-01
三、安装etcd软件
三台创建目录
mkdir -p /app/etcd/{bin,cfg,ssl}
解压文件
tar zxvf etcd-v3.3.10-linux-amd64.tar.gz
cp etcd-v3.3.10-linux-amd64/{etcd,etcdctl} /app/etcd/bin/
scp/app/etcd/bin/*root@k8s-node01:/app/etcd/bin/
scp/app/etcd/bin/*root@k8s-node02:/appt/etcd/bin/
四、配置etcd tls
1、下载cfssl(三台操作)
curl -L https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -o /usr/local/bin/cfssl
curl -L https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 -o /usr/local/bin/cfssljson
curl -L https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 -o /usr/local/bin/cfssl-certinfo
chmod +x /usr/local/bin/cfssl /usr/local/bin/cfssljson /usr/local/bin/cfssl-certinfo
2、生成证书
mkdir etcd-cert
cd etcd-cert
vi etcd-cert.sh
cat > ca-config.json < { "signing": { "default": { "expiry": "87600h" }, "profiles": { "www": { "expiry": "87600h", "usages": [ "signing", "key encipherment", "server auth", "client auth" ] } } } } EOF cat > ca-csr.json < { "CN": "etcd CA", "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "zhejiang", "ST": "hangzhou" } ] } EOF cfssl gencert -initca ca-csr.json | cfssljson -bare ca - #----------------------- cat > server-csr.json < { "CN": "etcd", "hosts": [ "192.168.159.121", "192.168.159.122", "192.168.159.123" ], "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "zhejiang", "ST": "hangzhou" } ] } EOF cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=www server-csr.json | cfssljson -bare server 执行脚本生成证书 sh etcd-cert.sh 把生成证书到三台/app/etcd/ssl/ cp ca.pem server-key.pem server.pem /app/etcd/ssl/ scp /app/etcd/ssl/* k8s-node01:/app/etcd/ssl/ scp /app/etcd/ssl/* k8s-node02:/app/etcd/ssl/ 五、配置etcd加证书 1、k8s-master-01主机配置 配置 vi /app/etcd/cfg/etcd #[Member] ETCD_NAME="etcd01" ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_PEER_URLS="https://192.168.159.121:2380" ETCD_LISTEN_CLIENT_URLS="https://192.168.159.121:2379" #[Clustering] ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.159.121:2380" ETCD_ADVERTISE_CLIENT_URLS="https://192.168.159.121:2379" ETCD_INITIAL_CLUSTER="etcd01=https://192.168.159.121:2380,etcd02=https://192.168.159.122:2380,etcd03=https://192.168.159.123:2380" ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster" ETCD_INITIAL_CLUSTER_STATE="new" 配置etcd自动启动脚本 vi /usr/lib/systemd/system/etcd.service [Unit] Description=Etcd Server After=network.target After=network-online.target Wants=network-online.target [Service] Type=notify EnvironmentFile=/app/etcd/cfg/etcd ExecStart=/app/etcd/bin/etcd --name=${ETCD_NAME} --data-dir=${ETCD_DATA_DIR} --listen-peer-urls=${ETCD_LISTEN_PEER_URLS} --listen-client-urls=${ETCD_LISTEN_CLIENT_URLS},http://127.0.0.1:2379 --advertise-client-urls=${ETCD_ADVERTISE_CLIENT_URLS} --initial-advertise-peer-urls=${ETCD_INITIAL_ADVERTISE_PEER_URLS} --initial-cluster=${ETCD_INITIAL_CLUSTER} --initial-cluster-token=${ETCD_INITIAL_CLUSTER_TOKEN} --initial-cluster-state=new --cert-file=/app/etcd/ssl/server.pem --key-file=/app/etcd/ssl/server-key.pem --peer-cert-file=/app/etcd/ssl/server.pem --peer-key-file=/app/etcd/ssl/server-key.pem --trusted-ca-file=/app/etcd/ssl/ca.pem --peer-trusted-ca-file=/app/etcd/ssl/ca.pem Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target 2、配置k8s-node01主机配置 配置 vi /app/etcd/cfg/etcd #[Member] ETCD_NAME="etcd02" ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_PEER_URLS="https://192.168.159.122:2380" ETCD_LISTEN_CLIENT_URLS="https://192.168.159.122:2379" #[Clustering] ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.159.122:2380" ETCD_ADVERTISE_CLIENT_URLS="https://192.168.159.122:2379" ETCD_INITIAL_CLUSTER="etcd01=https://192.168.159.121:2380,etcd02=https://192.168.159.122:2380,etcd03=https://192.168.159.123:2380" ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster" ETCD_INITIAL_CLUSTER_STATE="new" 配置etcd自动启动脚本 vi /usr/lib/systemd/system/etcd.service [Unit] Description=Etcd Server After=network.target After=network-online.target Wants=network-online.target [Service] Type=notify EnvironmentFile=/app/etcd/cfg/etcd ExecStart=/app/etcd/bin/etcd --name=${ETCD_NAME} --data-dir=${ETCD_DATA_DIR} --listen-peer-urls=${ETCD_LISTEN_PEER_URLS} --listen-client-urls=${ETCD_LISTEN_CLIENT_URLS},http://127.0.0.1:2379 --advertise-client-urls=${ETCD_ADVERTISE_CLIENT_URLS} --initial-advertise-peer-urls=${ETCD_INITIAL_ADVERTISE_PEER_URLS} --initial-cluster=${ETCD_INITIAL_CLUSTER} --initial-cluster-token=${ETCD_INITIAL_CLUSTER_TOKEN} --initial-cluster-state=new --cert-file=/app/etcd/ssl/server.pem --key-file=/app/etcd/ssl/server-key.pem --peer-cert-file=/app/etcd/ssl/server.pem --peer-key-file=/app/etcd/ssl/server-key.pem --trusted-ca-file=/app/etcd/ssl/ca.pem --peer-trusted-ca-file=/app/etcd/ssl/ca.pem Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target 3、配置k8s-node02主机配置 配置 vi /app/etcd/cfg/etcd #[Member] ETCD_NAME="etcd03" ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_PEER_URLS="https://192.168.159.123:2380" ETCD_LISTEN_CLIENT_URLS="https://192.168.159.123:2379" #[Clustering] ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.159.123:2380" ETCD_ADVERTISE_CLIENT_URLS="https://192.168.159.123:2379" ETCD_INITIAL_CLUSTER="etcd01=https://192.168.159.121:2380,etcd02=https://192.168.159.122:2380,etcd03=https://192.168.159.123:2380" ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster" ETCD_INITIAL_CLUSTER_STATE="new" 配置etcd自动启动脚本 vi /usr/lib/systemd/system/etcd.service [Unit] Description=Etcd Server After=network.target After=network-online.target Wants=network-online.target [Service] Type=notify EnvironmentFile=/app/etcd/cfg/etcd ExecStart=/app/etcd/bin/etcd --name=${ETCD_NAME} --data-dir=${ETCD_DATA_DIR} --listen-peer-urls=${ETCD_LISTEN_PEER_URLS} --listen-client-urls=${ETCD_LISTEN_CLIENT_URLS},http://127.0.0.1:2379 --advertise-client-urls=${ETCD_ADVERTISE_CLIENT_URLS} --initial-advertise-peer-urls=${ETCD_INITIAL_ADVERTISE_PEER_URLS} --initial-cluster=${ETCD_INITIAL_CLUSTER} --initial-cluster-token=${ETCD_INITIAL_CLUSTER_TOKEN} --initial-cluster-state=new --cert-file=/app/etcd/ssl/server.pem --key-file=/app/etcd/ssl/server-key.pem --peer-cert-file=/app/etcd/ssl/server.pem --peer-key-file=/app/etcd/ssl/server-key.pem --trusted-ca-file=/app/etcd/ssl/ca.pem --peer-trusted-ca-file=/app/etcd/ssl/ca.pem Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target 启动etcd systemctl daemon-reload systemctl restart etcd systemctl status etcd systemctl enable etcd
文章标题:配置Etcd集群和TLS认证
标题网址:http://6mz.cn/article/jhposi.html