Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
tingweiwang
/
k8s
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 67093041
authored
Aug 25, 2020
by
tingweiwang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加deploy-gpu-k8s.sh 判断节点类型做不同动
1 parent
4d75cd73
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
26 deletions
script/k8s/deploy-gpu-k8s.sh
script/k8s/deploy-gpu-k8s.sh
View file @
6709304
...
...
@@ -200,23 +200,40 @@ ansible master -m copy -a "src=/opt/kubernetes/cfg/flanneld dest=/opt/kubernetes
cp /root/k8s/service/flanneld.service /lib/systemd/system/
ansible master -m copy -a
"src=/lib/systemd/system/flanneld.service dest=/lib/systemd/system/ mode=755"
ansible master -m shell -a
"systemctl daemon-reload && service flanneld restart && service flanneld status && systemctl enable flanneld.service"
#ansible master -m copy -a "src=/root/k8s/service/docker.service dest=/lib/systemd/system/docker.service mode=755"
####################################安装nvidia-docker2#####################################
apt install nvidia-docker2 --allow-unauthenticated -y
###############################安装docker###############################################
echo
"当前harbor仓库地址为
$harbor_host
,"
sed -i s/harbor_host/
$harbor_host
/g /root/k8s/config/daemon.json_gpu
echo
"开始安装docker"
ansible master -m shell -a
"apt update --allow-insecure-repositories"
ansible master -m shell -a
"apt install docker-ce -y --allow-unauthenticated"
echo
"分发已修改的daemon.json文件"
ansible master -m copy -a
"src=/root/k8s/config/daemon.json_gpu dest=/etc/docker/daemon.json"
ansible master -m copy -a
"src=/root/k8s/service/docker.service dest=/lib/systemd/system/docker.service mode=755"
ansible master -m shell -a
"service docker restart"
ansible master -m shell -a
"service docker status"
ansible master -m shell -a
"cat /etc/docker/daemon.json"
echo
"还原daemon.json模板文件"
sed -i s/
$harbor_host
/harbor_host/g /root/k8s/config/daemon.json_gpu
###################################根据不同节点类型,安装设置docker#####################################
echo
"判断当前节点是gpu,还是cpu节点,根据节点不同,完成不同操作&& sleep 2"
lspci |grep -i vga |grep -v ASPEED >/dev/null
if
[
$?
-eq 0];then
echo
"当前节点是GPU节点,开始按照docker"
&&
sleep 2
&&
apt install nvidia-docker2 --allow-unauthenticated -y
echo
"当前harbor仓库地址为
$harbor_host
"
sed -i s/harbor_host/
$harbor_host
/g /root/k8s/config/daemon.json_gpu
echo
"开始安装docker"
ansible master -m shell -a
"apt update --allow-insecure-repositories"
ansible master -m shell -a
"apt install docker-ce -y --allow-unauthenticated"
echo
"分发已修改的gpu daemon.json文件"
ansible master -m copy -a
"src=/root/k8s/config/daemon.json_gpu dest=/etc/docker/daemon.json"
ansible master -m copy -a
"src=/root/k8s/service/docker.service dest=/lib/systemd/system/docker.service mode=755"
ansible master -m shell -a
"service docker restart"
ansible master -m shell -a
"service docker status"
ansible master -m shell -a
"cat /etc/docker/daemon.json"
echo
"还原daemon.json模板文件"
sed -i s/
$harbor_host
/harbor_host/g /root/k8s/config/daemon.json_gpu
else
echo
"当前节点是CPU节点,开始安装配置docker && sleep 2"
echo
"当前harbor仓库地址为
$harbor_host
,"
sed -i s/harbor_host/
$harbor_host
/g /root/k8s/config/daemon.json_cpu
echo
"开始安装docker"
ansible master -m shell -a
"apt update --allow-insecure-repositories"
ansible master -m shell -a
"apt install docker-ce -y --allow-unauthenticated"
echo
"分发已修改的daemon.json文件"
ansible master -m copy -a
"src=/root/k8s/config/daemon.json_cpu dest=/etc/docker/daemon.json"
ansible master -m copy -a
"src=/root/k8s/service/docker.service dest=/lib/systemd/system/docker.service mode=755"
ansible master -m shell -a
"service docker restart"
ansible master -m shell -a
"service docker status"
ansible master -m shell -a
"cat /etc/docker/daemon.json"
echo
"还原daemon.json模板文件"
sed -i s/
$harbor_host
/harbor_host/g /root/k8s/config/daemon.json_cpu
fi
###############################安装master节点###############################################
cat >>kubernetes-csr.json
<<EOF
{
...
...
@@ -455,8 +472,14 @@ sleep 5
echo
"请手动在master节点 设置命令自动补全,命令在脚本最后一行注释"
#source <(kubectl completion bash) && echo "source <(kubectl completion bash)" >> ~/.bashrc"
##############################################################################
echo
"为gpu节点打标签"
kubectl label node
$host_name
autodl
=
true
kpl
=
true
gpu
=
true
cpu
=
true
user_job_node
=
true
internal_service_node
=
true
lspci |grep -i vga |grep -v ASPEED
if
[
$?
-eq 0];then
echo
"为gpu节点打lable"
&&
sleep 1
kubectl label node
$host_name
autodl
=
true
kpl
=
true
gpu
=
true
cpu
=
true
user_job_node
=
true
internal_service_node
=
true
else
echo
"为cpu节点打lable"
kubectl label node
$host_name
autodl
=
true
kpl
=
true
cpu
=
true
user_job_node
=
true
internal_service_node
=
true
fi
echo
"###################创建pv pvc#############"
cp -arf /root/k8s/autodl_kpl_base/ /tmp/
echo
"########################修改pv模板#######################"
&&
sleep 3
...
...
@@ -468,12 +491,5 @@ sed -i s@NFS_2_SERVER@$NFS_2_SERVER@g `find /tmp/autodl_kpl_base/ -maxdepth 2 -n
sed -i s@NFS_3_SERVER@
$NFS_3_SERVER
@g
`
find /tmp/autodl_kpl_base/ -maxdepth 2 -name
"*.yaml"
-type f
`
kubectl apply -f /tmp/autodl_kpl_base/autodl-nfs
kubectl apply -f /tmp/autodl_kpl_base/kpl-nfs
#echo "###################还原pv pvc模板配置#############" && sleep 2
#sed -i s@$NFS_PATH@NFS_PATH@g `find /root/k8s/autodl_kpl_base/ -maxdepth 2 -name "*.yaml" -type f`
#sed -i s@$NFS_2_PATH@NFS_2_PATH@g `find /root/k8s/autodl_kpl_base/ -maxdepth 2 -name "*.yaml" -type f`
#sed -i s@$NFS_3_PATH@NFS_3_PATH@g `find /root/k8s/autodl_kpl_base/ -maxdepth 2 -name "*.yaml" -type f`
#sed -i s@$NFS_SERVER@NFS_SERVER@g `find /root/k8s/autodl_kpl_base/ -maxdepth 2 -name "*.yaml" -type f`
#sed -i s@$NFS_2_SERVER@NFS_2_SERVER@g `find /root/k8s/autodl_kpl_base/ -maxdepth 2 -name "*.yaml" -type f`
#sed -i s@$NFS_3_SERVER@NFS_3_SERVER@g `find /root/k8s/autodl_kpl_base/ -maxdepth 2 -name "*.yaml" -type f`
echo
"创建autodl push 镜像所需secret证书,用于configmap"
sh /root/k8s/autodl_kpl_base/create-harbor-secret.sh
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment