etcdのK8Sバイナリインストール

etcd

インストールetcd
wget https://github.com/etcd-io/etcd/releases/download/v3.3.9/etcd-v3.3.9-linux-amd64.tar.gz
tar -xvf etcd-v3.3.9-linux-amd64.tar.gz
mv etcd-v3.3.9-linux-amd64/etcd* /usr/local/bin/
ブートファイルを作成しますetcd
cat > /usr/lib/systemd/system/etcd.service << EOF
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
Documentation=https://github.com/coreos
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
ExecStart=/usr/local/bin/etcd \\
  --name k8s-master \\
  --cert-file=/etc/kubernetes/ssl/kubernetes.pem \\
  --key-file=/etc/kubernetes/ssl/kubernetes-key.pem \\
  --peer-cert-file=/etc/kubernetes/ssl/kubernetes.pem \\
  --peer-key-file=/etc/kubernetes/ssl/kubernetes-key.pem \\
  --trusted-ca-file=/etc/kubernetes/ssl/ca.pem \\
  --peer-trusted-ca-file=/etc/kubernetes/ssl/ca.pem \\
  --initial-advertise-peer-urls https://172.16.20.206:2380 \\
  --listen-peer-urls https://172.16.20.206:2380 \\
  --listen-client-urls https://172.16.20.206:2379,http://127.0.0.1:2379 \\
  --advertise-client-urls https://172.16.20.206:2379 \\
  --initial-cluster-token etcd-cluster \\
  --initial-cluster k8s-master=https://172.16.20.206:2380,k8s-node1=https://172.16.20.207:2380,k8s-node2=https://172.16.20.208:2380 \\
  --initial-cluster-state new \\
  --data-dir=/var/lib/etcd
Restart=on-failure
RestartSec=5
LimitNOFILE=65536                                                                                                                               
[Install]                                                                                                                                       
WantedBy=multi-user.target
EOF

#####説明
etcdデータディレクトリは/ var / libに/ etcdに、あなたがサービスを開始する前に、このディレクトリを作成する必要がある場合、またはサービスを開始するとエラーになります「ステップCHDIR産卵は/ usrに失敗しました / binに/ etcd:そのようなファイルまたはディレクトリ「;
同じ名前と現在のホストに後者のオプション--name名前
--initial -広告ピアのURL、 -聞く-ピアのURL、 -聞く-クライアントのURLを、 - -クライアントのURLを聞きます、 -ネイティブIPでなければならない、-クライアントのURLを宣伝
--initial-クラスタ注クラスタのホスト名とIP対応の間で
#####命令を
指定し、は/ var / libに/ etcdデータディレクトリを作業ディレクトリをetcd / var / libに/ etcd、あなたがサービスを開始する前に、2つのディレクトリを作成する必要があり、
通信のセキュリティを確保するために、あなたは、公開鍵と秘密鍵etcd(証明書ファイルとキー・ファイル)を指定する必要があり、ピアは、パブリックおよびプライベートCA証明書(と通信peer-証明書ファイル、ピア・キー-ファイル、ピア信頼-CA-ファイル)、 クライアントのCA証明書(信頼-CA-ファイル);
ホストの証明書を作成するときに使用されるフィールドkubernetes-csr.jsonファイルには、すべてのkubernetes.pemが含まれていますIP etcdノード、そうでない場合は、証明書検証エラーが発生し、
--initialクラスタ状態が新規である場合、 - -nameパラメータ値は--initial-クラスタリストになければなりません。

各ノードに分配

ディレクトリに対応する各ノードの分布etcd.service、etcd.confは/ usr /ローカル/ binに/ etcd *; etcd.conf交配は、現在のノード情報に対応する修飾。

scp -r /usr/local/bin/etcd* k8s-node1:/usr/local/bin/
scp -r /usr/local/bin/etcd* k8s-node2:/usr/local/bin/
scp -r /etc/etcd k8s-node1:/etc/
scp -r /etc/etcd k8s-node2:/etc/
scp /usr/lib/systemd/system/etcd.service k8s-node1:/usr/lib/systemd/system/
scp /usr/lib/systemd/system/etcd.service k8s-node2:/usr/lib/systemd/system/
etcd開始

すべてのノードが実行します

systemctl daemon-reload
systemctl start etcd
systemctl status etcd
systemctl enable etcd
検証
etcdctl \
  --ca-file=/etc/kubernetes/ssl/ca.pem \
  --cert-file=/etc/kubernetes/ssl/kubernetes.pem \
  --key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
  cluster-health

member 4cc910cd64041b9f is healthy: got healthy result from https://172.16.20.206:2379
member 71e662482c67f8f0 is healthy: got healthy result from https://172.16.20.207:2379
member d3813a08e230ddef is healthy: got healthy result from https://172.16.20.208:2379
cluster is healthy
######  清除所有数据

etcdctl / --prefix

おすすめ

転載: blog.51cto.com/phospherus/2445744