• 部署ETCD集群


    环境介绍
    
    10.0.0.179  etcd01
    
    10,0,0,180  etcd02
    
    10,0,0.181  etcd03


    1.安装cfssl证书生成工具
    
    yum install -y wget
    
    wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
    wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
    wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
    chmod +x cfssl_linux-amd64 cfssljson_linux-amd64 cfssl-certinfo_linux-amd64 
    mv cfssl_linux-amd64 /usr/local/bin/cfssl 
    mv cfssljson_linux-amd64 /usr/local/bin/cfssljson 
    mv cfssl-certinfo_linux-amd64 /usr/bin/cfssl-certinfo
    2.生成ca 配置
    
    cat >ca-config.json<<EOF{
    
    "signing": {
    "default": {
    "expiry": "87600h"
    },
    "profiles": {
    "kubernetes": {
    "usages": [
    "signing",
    "key encipherment",
    "server auth",
    "client auth"
    ],
    "expiry": "87600h"
    }
    }
    }
    }
    EOF
    3.部署etcd 证书生成 etcd-ca-key.pem  etcd-ca.pem  etcd-key.pem  etcd.pem
    
    cat >etcd-ca-csr.json<<EOF
    {
    "CN": "etcd",
    "key": {
    "algo": "rsa",
    "size": 2048
    },
    "names": [
    {
    "C": "CN",
    "ST": "BeiJing",
    "L": "BeiJing",
    "O": "etcd",
    "OU": "Etcd Security"
    }
    ]
    }
    EOF
    
    cfssl gencert -initca etcd-ca-csr.json | cfssljson -bare etcd-ca
    
    cat >etcd-csr.json<<EOF
    {
    "CN": "etcd",
    "hosts": [
    "127.0.0.1",
    "10.0.0.179",
    "10.0.0.180",
    "10.0.0.181"
    ],
    "key": {
    "algo": "rsa",
    "size": 2048
    },
    "names": [
    {
    "C": "CN",
    "ST": "BeiJing",
    "L": "BeiJing",
    "O": "etcd",
    "OU": "Etcd Security"
    }
    ]
    }
    EOF
    
    cfssl gencert -ca=etcd-ca.pem -ca-key=etcd-ca-key.pem -config=ca-config.json 
    -profile=kubernetes etcd-csr.json | cfssljson -bare etcd
    4.建立etcd目录和加入变量
    下载二进制包 :wget https://github.com/coreos/etcd/releases/download/v3.2.18/etcd-v3.2.18-linux-amd64.tar.gz
    mv etcd etcdctl 移动到/opt/kubernetes/bin下面 
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/kubernetes/bin 加入环境变量
    5.创建etcd配置文件
    cat > /usr/lib/systemd/system/etcd.service <<EOF
    
    [Unit]
    Description=Etcd Server
    After=network.target
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    Type=notify
    EnvironmentFile=-/opt/kubernetes/cfg/etcd
    ExecStart=/opt/kubernetes/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} 
    --initial-cluster-state=new 
    --cert-file=/opt/kubernetes/ssl/etcd.pem 
    --key-file=/opt/kubernetes/ssl/etcd-key.pem 
    --peer-cert-file=/opt/kubernetes/ssl/etcd.pem 
    --peer-key-file=/opt/kubernetes/ssl/etcd-key.pem 
    --trusted-ca-file=/opt/kubernetes/ssl/etcd-ca.pem 
    --peer-trusted-ca-file=/opt/kubernetes/ssl/etcd-ca.pem
    Restart=on-failure
    LimitNOFILE=65536
    [Install]
    WantedBy=multi-user.target
    
    启动配置
    
    cat > /opt/kubernetes/cfg/etcd <<EOF
    
    #[Member]
    ETCD_NAME="etcd02"
    ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
    ETCD_LISTEN_PEER_URLS="https://10.0.0.180:2380" 
    ETCD_LISTEN_CLIENT_URLS="https://10.0.0.180:2379"
    #[Clustering]
    ETCD_INITIAL_ADVERTISE_PEER_URLS="https://10.0.0.180:2380"
    ETCD_ADVERTISE_CLIENT_URLS="https://10.0.0.180:2379"
    ETCD_INITIAL_CLUSTER="etcd01=https://10.0.0.179:2380,etcd02=https://10.0.0.180:2380,etcd03=https://10.0.0.181:2380"
    ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
    ETCD_INITIAL_CLUSTER_STATE="new
    
    
    6检查集群状态
    
    etcdctl --ca-file=etcd-ca.pem --cert-file=etcd.pem --key-file=etcd-key.pem --endpoints="https://10.0.0.179:2379,https://10.0.0.180:2379,https://10.0.0.181:2379" cluster-health
    
    
    

      

      
  • 相关阅读:
    【codevs1922】骑士共存问题——网络流
    【bzoj1855||hdu3401】股票交易——单调队列优化dp
    【bzoj2002】弹飞绵羊——分块
    【bzoj3790】神奇项链——manacher+贪心
    【hdu2149】Public Sale
    【hdu1846】Brave Game
    【hdu3294】Girls' research——manacher
    【hdu3068】最长回文——manacher算法
    [BZOJ] 1634: [Usaco2007 Jan]Protecting the Flowers 护花
    [BZOJ] 1651: [Usaco2006 Feb]Stall Reservations 专用牛棚
  • 原文地址:https://www.cnblogs.com/zhangcaiwang1/p/9538192.html
Copyright © 2020-2023  润新知