Commit 66acb675 by tingweiwang

Delete 2-etcd_install.sh

1 parent 4ce63e2d
Showing with 0 additions and 78 deletions
#!/bin/bash
#王庭威
#ansibe hosts中 master是etcd角色,node是node角色
master1_ip=192.168.1.32
ansible all -m shell -a "mkdir /opt/kubernetes/{cfg,ssl,bin,log} -pv"
ansible all -m copy -a "src=/root/k8s/ssl/ca.pem dest=/opt/kubernetes/ssl/"
ansible all -m copy -a "src=/root/k8s/ssl/ca-key.pem dest=/opt/kubernetes/ssl/"
ansible all -m copy -a "src=/root/k8s/ssl/ca.csr dest=/opt/kubernetes/ssl/"
cat >>etcd-csr.json<<EOF
{
"CN": "etcd",
"hosts": [
"127.0.0.1",
"$master1_ip"
],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"ST": "BeiJing",
"L": "BeiJing",
"O": "k8s",
"OU": "System"
}
]
}
EOF
cp /root/k8s/bin/* /usr/bin/
cfssl gencert \
-ca=/root/k8s/ssl/ca.pem \
-ca-key=/root/k8s/ssl/ca-key.pem \
-config=/root/k8s/ssl/ca-config.json \
-profile=kubernetes \
etcd-csr.json | cfssljson -bare etcd
cp etcd*.pem /opt/kubernetes/ssl/
ansible master -m copy -a "src=/root/k8s/script/etcd.pem dest=/opt/kubernetes/ssl/"
ansible master -m copy -a "src=/root/k8s/script/etcd-key.pem dest=/opt/kubernetes/ssl/"
cp /root/k8s/bin/etcd /opt/kubernetes/bin/
cp /root/k8s/bin/etcdctl /opt/kubernetes/bin/
cp /root/k8s/bin/* /usr/bin/
ansible master -m copy -a "src=/root/k8s/bin/etcd dest=/opt/kubernetes/bin/ mode=755"
ansible master -m copy -a "src=/root/k8s/bin/etcdctl dest=/opt/kubernetes/bin/ mode=755"
ansible master -m shell -a "mkdir /var/lib/etcd/ -pv"
echo "++++++++++++++++++++++++++++++++++"
cat >>etcd.conf<<EOF
#[member]
ETCD_NAME="etcd-node1"
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="https://$master1_ip:2380"
ETCD_LISTEN_CLIENT_URLS="https://$master1_ip:2379,https://127.0.0.1:2379"
#[cluster]
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://$master1_ip:2380"
ETCD_INITIAL_CLUSTER="etcd-node1=https://$master1_ip:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="k8s-etcd-cluster"
ETCD_ADVERTISE_CLIENT_URLS="https://$master1_ip:2379"
#[security]
CLIENT_CERT_AUTH="true"
ETCD_CA_FILE="/opt/kubernetes/ssl/ca.pem"
ETCD_CERT_FILE="/opt/kubernetes/ssl/etcd.pem"
ETCD_KEY_FILE="/opt/kubernetes/ssl/etcd-key.pem"
PEER_CLIENT_CERT_AUTH="true"
ETCD_PEER_CA_FILE="/opt/kubernetes/ssl/ca.pem"
ETCD_PEER_CERT_FILE="/opt/kubernetes/ssl/etcd.pem"
ETCD_PEER_KEY_FILE="/opt/kubernetes/ssl/etcd-key.pem"
EOF
echo "+++++++++++++++++++"
ansible master-1 -m copy -a "src=etcd.conf dest=/opt/kubernetes/cfg/"
rm -rf etcd.conf
ansible master -m copy -a "src=/root/k8s//service/etcd.service dest=/lib/systemd/system/ mode=755"
ansible master -m shell -a "systemctl daemon-reload"
ansible master -m shell -a "service etcd restart && service etcd status && systemctl enable etcd.service"
rm -rf etcd-*
rm -rf etcd.*
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!