forked from hechuan73/train_ticket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s-cluster.txt
76 lines (53 loc) · 2.04 KB
/
k8s-cluster.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
system:
centos7
docker:
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm
yum install docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm
yum install docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm
-----------Docker version 17.03.2-ce-------------
cat << EOF > /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors": ["http://c32b78eb.m.daocloud.io"],
"insecure-registries":["10.141.212.25:5555"]
}
EOF
service docker restart
kubeadm setup: (master)
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
setenforce 0
yum install -y kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
### export KUBECONFIG=/etc/kubernetes/admin.conf
### sysctl net.bridge.bridge-nf-call-iptables=1
sudo swapoff -a
cat <<EOF > /root/.bash_profile
export KUBECONFIG=/etc/kubernetes/admin.conf
EOF
source /root/.bash_profile
-----------------------------------------------
kubeadm init --pod-network-cidr=10.244.0.0/16
kubeadm reset
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml
kubectl get pods --all-namespaces
kubectl get nodes
------------- leave --------------
kubectl drain centos-minion-2 --delete-local-data --force --ignore-daemonsets
kubectl delete node centos-minion-2
join: (slave)
kubeadm join --token 58c15f.e98c48fa25e26132 10.141.211.171:6443 --discovery-token-ca-cert-hash sha256:46448ae9369e3a803ef7078bc4b9de9f0855d84f309f9cf25ff76fdef8538ce2
kubeadm reset