码迷,mamicode.com
首页 > 其他好文 > 详细

k8s-etcd

时间:2021-01-07 11:46:58      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:出错   sed   cto   ln -s   clu   initial   chm   install   sig   

安装部署主控节点服务 -- etcd
  部署master节点服务
  部署etcd集群
  集群规划
  HDss7-12.host.com ectc lead 192.168.154.12
  HDss7-21.host.com ectc follow 192.168.154.21
  HDss7-22.host.com ectc follow 192.168.154.22
  #注释:这里部署文档以HDss7-12.host.com主机为例,另外两台安装部署方法类似
vi /opt/certs/ca-config.json

{
    "signing": {
        "default": {
            "expiry": "175200h"
        },
        "profiles": {
            "server": {
                "expiry": "175200h",
                "usages": [
                    "signing",
                    "key encipherment",
                    "server auth"
                ]
            },
            "client": {
                "expiry": "175200h",
                "usages": [
                    "signing",
                    "key encipherment",
                    "client auth"
                ]
            },
            "peer": {				
                "expiry": "175200h",
                "usages": [
                    "signing",
                    "key encipherment",
                    "server auth",
                    "client auth"
                ]
            }
        }
    }
}

  

vi /opt/certs/etcd-peer-csr.json

{
    "CN": "k8s-etcd",
    "hosts": [
        "10.4.7.11",
        "10.4.7.12",
        "10.4.7.21",
        "10.4.7.22"
    ],
    "key": {
        "algo": "rsa",
        "size": 2048
    },
    "names": [
        {
            "C": "CN",
            "ST": "beijing",
            "L": "beijing",
            "O": "od",
            "OU": "ops"
        }
    ]
}

cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=peer etcd-peer-csr.json |cfssl-json -bare etcd-peer

ls|grep etcd
etcd-peer.csr
etcd-peer-key.pem
etcd-peer.pem
etcd-peer-scr.json
useradd -s /sbin/nologin -M etcd
mkdir /opt/src
tar xfv etcd-v3.1.20-linux-amd64.tar.gz -C /opt/
mv /opt/etcd-v3.1.20-linux-amd64 etcd-v3.1.20
ln -s /opt/etcd-v3.1.20 /opt/etcd
部署etcd集群
准备证书
mkdir -p /opt/etcd/certs /data/etcd /data/logs/etcd-server
cd /opt/etcd/certs
scp hdss7-12:/opt/certs/ca.pem .
scp hdss7-12:/opt/certs/etcd-peer-key.pem .
scp hdss7-12:/opt/certs/etcd-peer.pem .
改变属组
cd /opt/etcd/certs
chown -R etcd.etcd /opt/etcd/certs /data/etcd /data/logs/etcd-server
创建etcd服务启动脚本IP地址改成本机IP -- 此文件本目录中有,上传修改即可,不要粘贴复制,格式容易出错
vi /opt/etcd/etcd-server-startup.sh
#!/bin/sh
./etcd --name etcd-server-7-12 \
--data-dir /data/etcd/etcd-server \
--listen-peer-urls https://10.4.7.12:2380 \
--listen-client-urls https://10.4.7.12:2379,http://127.0.0.1:2379 \
--quota-backend-bytes 8000000000 \
--initial-advertise-peer-urls https://10.4.7.12:2380 \
--advertise-client-urls https://10.4.7.12:2379,http://127.0.0.1:2379 \
--initial-cluster etcd-server-7-12=https://10.4.7.12:2380,etcd-server-7-21=https://10.4.7.21:2380,etcd-server-7-22=https://10.4.7.22:2380 \
--ca-file ./certs/ca.pem \
--cert-file ./certs/etcd-peer.pem \
--key-file ./certs/etcd-peer-key.pem \
--client-cert-auth \
--trusted-ca-file ./certs/ca.pem \
--peer-ca-file ./certs/ca.pem \
--peer-cert-file ./certs/etcd-peer.pem \
--peer-key-file ./certs/etcd-peer-key.pem \
--peer-client-cert-auth \
--peer-trusted-ca-file ./certs/ca.pem \
--log-output stdout
chmod +x /opt/etcd/etcd-server-startup.sh
chown -R etcd.etcd /opt/etcd-v3.1.20/ /data/etcd /data/logs/etcd-server
yum install supervisor -y
systemctl enable --now supervisord
更改supervisord的配置文件:[program:etcd-server-7-12]名字需要根据实际更改
vi /etc/supervisord.d/etcd-server.ini
[program:etcd-server-7-12]
command=/opt/etcd/etcd-server-startup.sh ; the program (relative uses PATH, can take args)
numprocs=1 ; number of processes copies to start (def 1)
directory=/opt/etcd ; directory to cwd to before exec (def no cwd)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; retstart at unexpected quit (default: true)
startsecs=30 ; number of secs prog must stay running (def. 1)
startretries=3 ; max # of serial start failures (default 3)
exitcodes=0,2 ; ‘expected‘ exit codes for process (default 0,2)
stopsignal=QUIT ; signal used to kill process (default TERM)
stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
user=etcd ; setuid to this UNIX account to run the program
redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/data/logs/etcd-server/etcd.stdout.log ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=64MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=4 ; # of stdout logfile backups (default 10)
stdout_capture_maxbytes=1MB ; number of bytes in ‘capturemode‘ (default 0)
stdout_events_enabled=false ; emit events on stdout writes (default false)
创建后端启动etcd
supervisorctl update
supervisorctl status
netstat -luntp|grep etcd
三台etcd节点都需要配置
/opt/etcd/etcdctl cluster-health
部署apiserver

k8s-etcd

标签:出错   sed   cto   ln -s   clu   initial   chm   install   sig   

原文地址:https://www.cnblogs.com/xiaoyunhui/p/14229334.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!