55DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
66
77source /etc/kubernetes.env
8+ source $DIR /functions.sh
89
9- start () {
10- systemctl daemon-reload
11- systemctl enable ${1} .service
12- systemctl start ${1} .service
13- }
10+ setup-install-etcd
11+ setup-install-kubernetes
12+ setup-wupiao
13+
14+ cat << 'EOF ' > /etc/systemd/system/etcd.service
15+ [Unit]
16+ Description=etcd
1417
15- mkdir -p /etc/systemd/system/etcd2.service.d
16- cat << 'EOF ' > /etc/systemd/system/etcd2.service.d/50-etcd.conf
1718[Service]
1819Environment=ETCD_PROXY=on
1920EnvironmentFile=/etc/kubernetes.env
20- EOF
21-
22- start etcd2
23-
24- mkdir -p /opt/bin
25-
26- cp $DIR /install-kubernetes /opt/bin/install-kubernetes
27- chmod +x /opt/bin/install-kubernetes
28-
29- cp $DIR /wupiao /opt/bin/wupiao
30- chmod +x /opt/bin/wupiao
21+ ExecStartPre=/opt/bin/install-etcd
22+ ExecStart=/opt/bin/etcd
23+ Restart=always
24+ RestartSec=10s
25+ LimitNOFILE=40000
3126
32- /opt/bin/wupiao http://127.0.0.1:2379/v2/members
27+ [Install]
28+ WantedBy=multi-user.target
29+ EOF
3330
3431mkdir -p /etc/systemd/system/flanneld.service.d
3532cat << 'EOF ' > /etc/systemd/system/flanneld.service.d/50-network-config.conf
3633[Unit]
37- Requires=etcd2 .service
38- After=etcd2 .service
34+ Requires=etcd .service
35+ After=etcd .service
3936
4037[Service]
4138ExecStartPre=/opt/bin/wupiao http://127.0.0.1:2379/v2/members
@@ -44,9 +41,6 @@ ExecStartPre=/opt/bin/wupiao http://127.0.0.1:2379/v2/members
4441WantedBy=multi-user.target
4542EOF
4643
47- start flanneld
48- start docker
49-
5044cat << 'EOF ' > /etc/systemd/system/install-kubernetes.service
5145[Unit]
5246Description=Install Kubernetes
@@ -87,7 +81,26 @@ RestartSec=10
8781WantedBy=multi-user.target
8882EOF
8983
90- start kube-kubelet
84+ cat << 'EOF ' > /etc/systemd/system/kube-proxy.service
85+ [Unit]
86+ Description=Kubernetes Proxy Server
87+ Documentation=https://github.com/GoogleCloudPlatform/kubernetes
88+ After=install-kubernetes.service
89+ Requires=install-kubernetes.service
90+
91+ [Service]
92+ EnvironmentFile=/etc/kubernetes.env
93+ ExecStartPre=/opt/bin/wupiao ${KUBERNETES_MASTER}/api/v1beta3/nodes
94+ ExecStart=/opt/bin/kubelet \
95+ --master==${KUBERNETES_MASTER}
96+ --logtostderr=true \
97+ --v=2
98+ Restart=on-failure
99+ RestartSec=10
100+
101+ [Install]
102+ WantedBy=multi-user.target
103+ EOF
91104
92105H=` hostname -f`
93106cat << EOF > /tmp/node.json
@@ -100,6 +113,11 @@ cat <<EOF > /tmp/node.json
100113}
101114EOF
102115
116+
117+ for S in etcd flanneld docker kube-kubelet kube-proxy; do
118+ start $S
119+ done
120+
103121/opt/bin/wupiao ${KUBERNETES_MASTER} /api/v1beta3/nodes
104122kubectl --server=${KUBERNETES_MASTER} create -f /tmp/node.json
105123
0 commit comments