yum -y update
reboot
192.168.172.132 node01.example.com
192.168.172.133 node02.example.com
ssh-keygen
ssh-copy-id node01.example.com
ssh-copy-id node02.example.com
scp /etc/hosts node02.example.com:/etc
systemctl stop firewalld && systemctl disable firewalld
sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
setenforce 0
#关闭swap
swapoff -a && sed -i 's/.*swap.*/#&/' /etc/fstab
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum install -y docker-ce-18.06.1.ce-3.el7
systemctl enable docker && systemctl start docker
docker version
yum install -y kubelet kubeadm kubectl
kubeadm init --kubernetes-version=1.15.3 \
--apiserver-advertise-address=192.168.172.132 \
--image-repository registry.aliyuncs.com/google_containers \
--service-cidr=10.1.0.0/16 \
--pod-network-cidr=10.244.0.0/16
systemctl start kubelet && systemctl enable kubelet
mkdir -p /root/.kube
cp /etc/kubernetes/admin.conf /root/.kube/config
kubectl get nodes
#检查对应版本
https://quay.io/repository/coreos/flannel
docker pull quay.io/coreos/flannel:v0.11.0-amd64
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl get nodes
kubeadm join 192.168.172.132:6443 --token pk96e8.6irwnsmmf8kt8ncz --discovery-token-ca-cert-hash sha2
56:dfb7749305372a51578578983ba628453732aa7655bdd763f43f707359e0d88d
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
#更改内容
image: registry.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.10.1
type: NodePort
docker pull registry.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.10.1
kubectl create -f kubernetes-dashboard.yaml
kubectl create serviceaccount dashboard-admin -n kube-system
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin
kubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk '/dashboard-admin/{print $1}')