准备环境
- 设置主机名与时区
timedatectl set-timezone Asia/Shanghai
hostnamectl set-hostname master
- 配置hosts文件
vim /etc/hosts
- 关闭防火墙
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl disable firewalld
systemctl stop firewalld
安装k8s
mkdir /usr/local/k8s-install && cd /usr/local/k8s-install
rz 上传 kubernetes-1.14.zip 包含以下的文件
admin-role.yaml
daemon.json
docker-ce-18.09.tar.gz
flannel-dashboard.tar.gz
init.sh
k8s-114-images.tar.gz
k8s.conf
kube-flannel.yml
kube114-rpm.tar.gz
kubernetes-dashboard-admin.rbac.yaml
kubernetes-dashboard.yaml
worker-node.sh
unzip kubernetes-1.14.zip
cd /usr/local/k8s-install/kubernetes-1.14
tar -zxvf docker-ce-18.09.tar.gz
cd docker
yum localinstall -y *.rpm
systemctl start docker
systemctl enable docker
docker info | grep cgroup
cd /usr/local/k8s-install/kubernetes-1.14
tar -zxvf kube114-rpm.tar.gz
cd kube114-rpm
yum localinstall -y *.rpm
swapoff -a
sed -i '/swap/s/^/#/' /etc/fstab
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
cd /usr/local/k8s-install/kubernetes-1.14
docker load -i k8s-114-images.tar.gz
docker load -i flannel-dashboard.tar.gz
docker images
docker images | grep -v REPOSITORY | wc -l
配置k8s
kubeadm init --kubernetes-version=v1.14.1 --pod-network-cidr=10.244.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
systemctl enable kubelet.service
kubectl get nodes
kubectl get pod --all-namespaces
kubectl create -f kube-flannel.yml
kubeadm join 192.168.4.130:6443 --token 911xit.xkp2gfxbvf5wuqz7 \
--discovery-token-ca-cert-hash sha256:23db3094dc9ae1335b25692717c40e24b1041975f6a43da9f43568f8d0dbac72
kubeadm join 192.168.163.132:6443 --token aoeout.9k0ybvrfy09q1jf6 --discovery-token-unsafe-skip-ca-verification
- kubeadm 是kubernetes集群快速构建工具
- kubelet 运行在所有节点上,负责启动POD和容器,以系统服务形式出现
- kubectl 是 kubernetes命令行工具,提供指令
master开启仪表盘
kubectl apply -f kubernetes-dashboard.yaml
kubectl apply -f admin-role.yaml
kubectl apply -f kubernetes-dashboard-admin.rbac.yaml
kubectl -n kube-system get svc