***********离线部署安装k8s集群环境***********
1.机器配置
master 192.168.245.201 4核4g
node1 192.168.245.202 4核4g
node2 192.168.245.203 4核4g
系统内核:3.10.0-957.el7.x86_64
2.添加颜色
echo "PS1='\[\033[35m\][\[\033[00m\]\[\033[31m\]\u\[\033[33m\]\[\033[33m\]@\[\033[03m\]\[\033[35m\]\h\[\033[00m\] \[\033[5;32m\]\w\[\033[00m\]\[\033[35m\]]\[\033[00m\]\[\033[5;31m\]\\$\[\033[00m\] '" >> ~/.bashrc && source ~/.bashrc
3.设置主机名:
hostnamectl set-hostname master
hostnamectl set-hostname node1
hostnamectl set-hostname node2
4.添加hosts解析:
cat >> /etc/hosts << EOF
192.168.245.201 master
192.168.245.202 node1
192.168.245.203 node2
EOF
5.永久关闭seLinux(需重启系统生效)
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
6.永久关闭swap(需重启系统生效)
sed -i 's/.*swap.*/#&/g' /etc/fstab # 永久关闭
7.服务器时间同步
timedatectl set-timezone Asia/Shanghai
8.网桥设置
echo -e “net.bridge.bridge-nf-call-ip6tables = 1\nnet.bridge.bridge-nf-call-iptables = 1” >> /etc/sysctl.d/k8s.conf
sysctl --system #使其生效
9.部署docker(3台操作相同)
9.1解压安装docker
tar -zxvf docker-ce-18.09.tar.gz
cd docker && yum localinstall *.rpm -y #yum安装相关依赖
9.2启动docker
systemctl start docker
systemctl enable docker #开机启动
docker version
9.3docker加速器
vim /etc/docker/daemon.json #添加
{
“registry-mirrors”: [“https://fskvstob.mirror.aliyuncs.com/”]
}
systemctl daemon-reload #重新加载
10.部署k8s集群
10.1解压安装k8s
cd …/
tar -zxvf kube114-rpm.tar.gz
cd kube114-rpm && yum localinstall *.rpm -y #yum解决依赖
10.2导入k8s镜像
cd …/
docker load -i k8s-114-images.tar.gz
docker load -i flannel-dashboard.tar.gz
10.3查看k8s镜像 --只在master上操作
docker images #共9个镜像
10.4maseter初始化
kubeadm init --kubernetes-version=v1.14.1 --pod-network-cidr=10.244.0.0/16
说明:
kubeadm join 192.168.245.201:6443 --token uyq50w.tq7eetftqojmru7u \
--discovery-token-ca-cert-hash sha256:fabb34d941cc47ed9e9fbecfea7cb6763d85305b97891ac43d1fd8e473fb2420
10.5查看节点
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
kubectl get node
kubectl get pod --all-namespaces
10.6配置KUBECONFIG变量
echo “export KUBECONFIG=/etc/kubernetes/admin.conf” >> /etc/profile
source /etc/profile
echo $KUBECONFIG #应该返回/etc/kubernetes/admin.conf
10.7部署flannel网络 --在node节点操作
kubectl create -f kube-flannel.yml
kubectl get node
10.8kubeadm join 加入node节点
systemctl enable kubelet #添加开机启动k8s
kubeadm join 192.168.0.110:6443 --token 2vjmyw.9p6cbn8m8oqs41ta
–discovery-token-ca-cert-hash sha256:e4c1d3e9da26e2f488dec621122a30d8725762c20bf281519376ed0ae8c7204b #不要复制这个,要拷贝系统生成的token才行!
10.9在master上面查看
kubectl get node
10.10部署k8s UI界面(dashboard), 只在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
11网页验证
访问地址 :?http://ip:32000
标签:--,离线,192.168,etc,Linux,033,docker,k8s From: https://www.cnblogs.com/weixj/p/17591743.html