优化
This commit is contained in:
@ -31,3 +31,5 @@ rm -f calico.yaml
|
||||
wget https://docs.projectcalico.org/v3.8/manifests/calico.yaml
|
||||
sed -i "s#192\.168\.0\.0/16#${POD_SUBNET}#" calico.yaml
|
||||
kubectl apply -f calico.yaml
|
||||
|
||||
echo -e "\033[31;1m请确保您正在使用 https://kuboard.cn/install/install-k8s.html 上的最新K8S安装文档,并加入了在线答疑QQ群,以避免碰到问题时无人解答\033[0m"
|
||||
|
||||
33
.vuepress/public/install-script/v1.16.0/init_master.sh
Normal file
33
.vuepress/public/install-script/v1.16.0/init_master.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 只在 master 节点执行
|
||||
|
||||
# 查看完整配置选项 https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2
|
||||
rm -f ./kubeadm-config.yaml
|
||||
cat <<EOF > ./kubeadm-config.yaml
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: ClusterConfiguration
|
||||
kubernetesVersion: v1.16.0
|
||||
imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers
|
||||
controlPlaneEndpoint: "${APISERVER_NAME}:6443"
|
||||
networking:
|
||||
serviceSubnet: "10.96.0.0/12"
|
||||
podSubnet: "${POD_SUBNET}"
|
||||
dnsDomain: "cluster.local"
|
||||
EOF
|
||||
|
||||
# kubeadm init
|
||||
# 根据您服务器网速的情况,您需要等候 3 - 10 分钟
|
||||
kubeadm init --config=kubeadm-config.yaml --upload-certs
|
||||
|
||||
# 配置 kubectl
|
||||
rm -rf /root/.kube/
|
||||
mkdir /root/.kube/
|
||||
cp -i /etc/kubernetes/admin.conf /root/.kube/config
|
||||
|
||||
# 安装 calico 网络插件
|
||||
# 参考文档 https://docs.projectcalico.org/v3.8/getting-started/kubernetes/
|
||||
rm -f calico.yaml
|
||||
wget https://docs.projectcalico.org/v3.8/manifests/calico.yaml
|
||||
sed -i "s#192\.168\.0\.0/16#${POD_SUBNET}#" calico.yaml
|
||||
kubectl apply -f calico.yaml
|
||||
@ -95,3 +95,5 @@ systemctl restart docker
|
||||
systemctl enable kubelet && systemctl start kubelet
|
||||
|
||||
docker version
|
||||
|
||||
echo -e "\033[31;1m请确保您正在使用 https://kuboard.cn/install/install-k8s.html 上的最新文档,并加入了在线答疑QQ群,以避免碰到问题时无人解答\033[0m"
|
||||
|
||||
97
.vuepress/public/install-script/v1.16.0/install_kubelet.sh
Normal file
97
.vuepress/public/install-script/v1.16.0/install_kubelet.sh
Normal file
@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 在 master 节点和 worker 节点都要执行
|
||||
|
||||
# 安装 docker
|
||||
# 参考文档如下
|
||||
# https://docs.docker.com/install/linux/docker-ce/centos/
|
||||
# https://docs.docker.com/install/linux/linux-postinstall/
|
||||
|
||||
# 卸载旧版本
|
||||
yum remove -y docker \
|
||||
docker-client \
|
||||
docker-client-latest \
|
||||
docker-common \
|
||||
docker-latest \
|
||||
docker-latest-logrotate \
|
||||
docker-logrotate \
|
||||
docker-selinux \
|
||||
docker-engine-selinux \
|
||||
docker-engine
|
||||
|
||||
# 设置 yum repository
|
||||
yum install -y yum-utils \
|
||||
device-mapper-persistent-data \
|
||||
lvm2
|
||||
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
|
||||
|
||||
# 安装并启动 docker
|
||||
yum install -y docker-ce-18.09.7 docker-ce-cli-18.09.7 containerd.io
|
||||
systemctl enable docker
|
||||
systemctl start docker
|
||||
|
||||
# 安装 nfs-utils
|
||||
# 必须先安装 nfs-utils 才能挂载 nfs 网络存储
|
||||
yum install -y nfs-utils
|
||||
|
||||
# 关闭 防火墙
|
||||
systemctl stop firewalld
|
||||
systemctl disable firewalld
|
||||
|
||||
# 关闭 SeLinux
|
||||
setenforce 0
|
||||
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
|
||||
|
||||
# 关闭 swap
|
||||
swapoff -a
|
||||
yes | cp /etc/fstab /etc/fstab_bak
|
||||
cat /etc/fstab_bak |grep -v swap > /etc/fstab
|
||||
|
||||
# 修改 /etc/sysctl.conf
|
||||
# 如果有配置,则修改
|
||||
sed -i "s#^net.ipv4.ip_forward.*#net.ipv4.ip_forward=1#g" /etc/sysctl.conf
|
||||
sed -i "s#^net.bridge.bridge-nf-call-ip6tables.*#net.bridge.bridge-nf-call-ip6tables=1#g" /etc/sysctl.conf
|
||||
sed -i "s#^net.bridge.bridge-nf-call-iptables.*#net.bridge.bridge-nf-call-iptables=1#g" /etc/sysctl.conf
|
||||
# 可能没有,追加
|
||||
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
|
||||
echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
|
||||
echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
|
||||
# 执行命令以应用
|
||||
sysctl -p
|
||||
|
||||
# 配置K8S的yum源
|
||||
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
|
||||
[kubernetes]
|
||||
name=Kubernetes
|
||||
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
|
||||
enabled=1
|
||||
gpgcheck=0
|
||||
repo_gpgcheck=0
|
||||
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
|
||||
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
|
||||
EOF
|
||||
|
||||
# 卸载旧版本
|
||||
yum remove -y kubelet kubeadm kubectl
|
||||
|
||||
# 安装kubelet、kubeadm、kubectl
|
||||
yum install -y kubelet-1.16.0 kubeadm-1.16.0 kubectl-1.16.0
|
||||
|
||||
# 修改docker Cgroup Driver为systemd
|
||||
# # 将/usr/lib/systemd/system/docker.service文件中的这一行 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
|
||||
# # 修改为 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd
|
||||
# 如果不修改,在添加 worker 节点时可能会碰到如下错误
|
||||
# [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd".
|
||||
# Please follow the guide at https://kubernetes.io/docs/setup/cri/
|
||||
sed -i "s#^ExecStart=/usr/bin/dockerd.*#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd#g" /usr/lib/systemd/system/docker.service
|
||||
|
||||
# 设置 docker 镜像,提高 docker 镜像下载速度和稳定性
|
||||
# 如果您访问 https://hub.docker.io 速度非常稳定,亦可以跳过这个步骤
|
||||
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
|
||||
|
||||
# 重启 docker,并启动 kubelet
|
||||
systemctl daemon-reload
|
||||
systemctl restart docker
|
||||
systemctl enable kubelet && systemctl start kubelet
|
||||
|
||||
docker version
|
||||
@ -90,4 +90,10 @@ Kubernetes教程的主要依据是:Kubernetes 官网文档,以及使用 Kubo
|
||||
* [部署Web前端]
|
||||
* [管理多环境]
|
||||
|
||||
在 Kubernetes 上部署 Spring Cloud 微服务:(Open Capacity Platform)
|
||||
|
||||
* [OCP介绍](https://kuboard.cn/leanring/k8s-practice/ocp/)
|
||||
* [准备OCP的构建环境和部署环境](https://kuboard.cn/learning/k8s-practice/ocp/prepare.html)
|
||||
* [构建Docker镜像并推送到仓库](https://kuboard.cn/learning/k8s-practice/ocp/build.html)
|
||||
|
||||
Kuboard官网免费提供 K8S教程,K8S安装文档,学习过程中如有疑问,请加QQ群在线答疑。
|
||||
|
||||
@ -201,9 +201,9 @@ echo "127.0.0.1 $(hostname)" >> /etc/hosts
|
||||
```
|
||||
:::
|
||||
|
||||
<div style="display: inline-block; width: calc(100% - 400px);"></div>
|
||||
<!-- <div style="display: inline-block; width: calc(100% - 400px);"></div> -->
|
||||
<div style="display: inline-block; width: 302px; line-height: 40px; background-color: rgba(255,229,100,0.3); padding: 20px 0 0 20px; margin-bottom: 20px; border: 1px solid #d7dae2;">
|
||||
<el-form :model="form" ref="envForm" :rules="rules" style="text-align: right;">
|
||||
<el-form :model="form" ref="envForm" :rules="rules" style="text-align: left;">
|
||||
<el-form-item prop="checked" class="env-form-item">
|
||||
<el-checkbox-group v-model="form.checked" style="height: 120px;">
|
||||
<li style="height: 40px;"> <el-checkbox style="width: 300px; text-align: left;" label="centos">我的任意节点 centos 版本在兼容列表中</el-checkbox> </li>
|
||||
@ -244,7 +244,7 @@ echo "127.0.0.1 $(hostname)" >> /etc/hosts
|
||||
``` sh
|
||||
# 在 master 节点和 worker 节点都要执行
|
||||
|
||||
curl -sSL https://kuboard.cn/install-script/v1.16.0/install-kubelet.sh | sh
|
||||
curl -sSL https://kuboard.cn/install-script/v1.16.0/install_kubelet.sh | sh
|
||||
|
||||
```
|
||||
|
||||
@ -254,7 +254,7 @@ curl -sSL https://kuboard.cn/install-script/v1.16.0/install-kubelet.sh | sh
|
||||
|
||||
手动执行以下代码,效果与快速安装完全相同。
|
||||
|
||||
<<< @/.vuepress/public/install-script/v1.16.0/install-kubelet.sh
|
||||
<<< @/.vuepress/public/install-script/v1.16.0/install_kubelet.sh
|
||||
|
||||
::: warning
|
||||
如果此时执行 `service status kubelet` 命令,将得到 kubelet 启动失败的错误提示,请忽略此错误,因为必须完成后续步骤中 kubeadm init 的操作,kubelet 才能正常启动
|
||||
@ -294,7 +294,7 @@ export APISERVER_NAME=apiserver.demo
|
||||
# Kubernetes 容器组所在的网段,该网段安装完成后,由 kubernetes 创建,事先并不存在于您的物理网络中
|
||||
export POD_SUBNET=10.100.0.1/20
|
||||
echo "${MASTER_IP} ${APISERVER_NAME}" >> /etc/hosts
|
||||
curl -sSL https://kuboard.cn/install-script/v1.16.0/init-master.sh | sh
|
||||
curl -sSL https://kuboard.cn/install-script/v1.16.0/init_master.sh | sh
|
||||
```
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="手工初始化">
|
||||
@ -311,7 +311,7 @@ export POD_SUBNET=10.100.0.1/20
|
||||
echo "${MASTER_IP} ${APISERVER_NAME}" >> /etc/hosts
|
||||
```
|
||||
|
||||
<<< @/.vuepress/public/install-script/v1.16.0/init-master.sh
|
||||
<<< @/.vuepress/public/install-script/v1.16.0/init_master.sh
|
||||
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
@ -6,6 +6,7 @@ description: Kubernetes免费中文教程目录
|
||||
|
||||
# Kubernetes免费中文教程
|
||||
|
||||
|
||||
本教程的主要依据是:Kubernetes 官网文档,以及使用 Kubernetes 落地 Spring Cloud 微服务并投产的实战经验。适用人群:
|
||||
* Kubernetes 初学者
|
||||
* 学习过 Kubernetes,但未能将其投产的技术爱好者
|
||||
@ -80,3 +81,9 @@ description: Kubernetes免费中文教程目录
|
||||
* [部署服务网关]
|
||||
* [部署Web前端]
|
||||
* [管理多环境]
|
||||
|
||||
在 Kubernetes 上部署 Spring Cloud 微服务:(Open Capacity Platform)
|
||||
|
||||
* [OCP介绍](/leanring/k8s-practice/ocp/)
|
||||
* [准备OCP的构建环境和部署环境](/learning/k8s-practice/ocp/prepare.html)
|
||||
* [构建Docker镜像并推送到仓库](/learning/k8s-practice/ocp/build.html)
|
||||
|
||||
@ -174,6 +174,11 @@ Kuboard 为 Kubernetes 初学者设计了如下学习路径:
|
||||
* [部署Web前端]
|
||||
* [管理多环境]
|
||||
|
||||
在 Kubernetes 上部署 Spring Cloud 微服务:(Open Capacity Platform)
|
||||
|
||||
* [OCP介绍](/leanring/k8s-practice/ocp/)
|
||||
* [准备OCP的构建环境和部署环境](/learning/k8s-practice/ocp/prepare.html)
|
||||
* [构建Docker镜像并推送到仓库](/learning/k8s-practice/ocp/build.html)
|
||||
|
||||
### Kubernetes 有经验者
|
||||
|
||||
|
||||
Reference in New Issue
Block a user