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 3080f4fa
authored
Dec 16, 2020
by
tingweiwang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gpu判断条件修复,修复预处理器推送镜像到kpl_k8s问题。
1 parent
9c938687
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
26 deletions
script/k8s/deploy-gpu-k8s.sh
script/k8s/deploy-gpu-k8s.sh
View file @
3080f4f
...
@@ -10,10 +10,8 @@ new_harbor_ip=192.168.1.32
...
@@ -10,10 +10,8 @@ new_harbor_ip=192.168.1.32
harbor_host
=
192.168.1.32:5000
harbor_host
=
192.168.1.32:5000
harbor_passwd
=
admin
#写死的不能改,harbor配置文件中password写死了,当前只能是admin
harbor_passwd
=
admin
#写死的不能改,harbor配置文件中password写死了,当前只能是admin
harbor_user
=
admin
harbor_user
=
admin
image_
path
=
/root/images
#写死的不能改
image_
file
=
/root/images.tar.gz
#写死的不能改
interface
=
'eth*|enp*|eno*|ens*'
#本机内网IP的物理网卡名称,用于flannel的配置。
interface
=
'eth*|enp*|eno*|ens*'
#本机内网IP的物理网卡名称,用于flannel的配置。
image_list
=
`
cat
$image_path
/image_list.txt
`
image_list_ksy
=
`
cat
$image_path
/image_list_ksy.txt
`
host_name
=
`
hostname
`
host_name
=
`
hostname
`
harbor_user_name
=
admin
harbor_user_name
=
admin
harbor_auth_token
=
$(
echo
-n
"
${
harbor_user
}
:
${
harbor_passwd
}
"
| base64
)
harbor_auth_token
=
$(
echo
-n
"
${
harbor_user
}
:
${
harbor_passwd
}
"
| base64
)
...
@@ -213,7 +211,7 @@ ansible master -m shell -a "systemctl daemon-reload && service flanneld restart
...
@@ -213,7 +211,7 @@ ansible master -m shell -a "systemctl daemon-reload && service flanneld restart
###################################根据不同节点类型,安装设置docker#####################################
###################################根据不同节点类型,安装设置docker#####################################
echo
"判断当前节点是gpu,还是cpu节点,根据节点不同,完成不同操作&& sleep 2"
echo
"判断当前节点是gpu,还是cpu节点,根据节点不同,完成不同操作&& sleep 2"
test
=
`
lspci |grep -i nvidia|wc -l
`
test
=
`
lspci |grep -i nvidia|wc -l
`
if
[
$test
-gt
0
]
;
then
if
[
$test
-gt
3
]
;
then
echo
"当前节点是GPU节点,开始安装gpu docker"
&&
sleep 2
&&
apt install nvidia-docker2 --allow-unauthenticated -y
echo
"当前节点是GPU节点,开始安装gpu docker"
&&
sleep 2
&&
apt install nvidia-docker2 --allow-unauthenticated -y
echo
"当前harbor仓库地址为
$harbor_host
"
echo
"当前harbor仓库地址为
$harbor_host
"
sed -i s/harbor_host/
$harbor_host
/g /root/k8s/config/daemon.json_gpu
sed -i s/harbor_host/
$harbor_host
/g /root/k8s/config/daemon.json_gpu
...
@@ -447,27 +445,18 @@ echo "您的harbor服务器访问地址为:$harbor_host,已经自动创建harbor
...
@@ -447,27 +445,18 @@ echo "您的harbor服务器访问地址为:$harbor_host,已经自动创建harbor
sleep 4
sleep 4
docker login
$harbor_host
-uadmin -p
$harbor_passwd
docker login
$harbor_host
-uadmin -p
$harbor_passwd
###########################推送私有镜像到harbor仓库#######
###########################推送私有镜像到harbor仓库#######
echo
"####################开始执行镜像导入###########################"
echo
"####################判断私有镜像文件是否存在###########################"
for
image
in
`
ls
$image_path
|grep -Ev
"*.sh"
|grep -Ev
"*.txt"
|grep -Ev
"images.tar.gz"
`
test
-f
$image_file
do
if
[
$?
-eq 0
]
;
then
echo
"开始导入
$image
镜像"
echo
"私有镜像文件存在,开始解压压缩包"
&&
sleep 2
&&
tar -xvzf
$image_file
-C /root/
&&
\
docker load -i
$image_path
/
$image
cp -a /root/images/push-set.sh /root/images/push-set-
`
date +%F-%H-%M
`
.sh
&&
\
done
sed -i s/harbor_host/
$harbor_host
/g /root/images/push-set-
`
date +%F-%H-%M
`
.sh
&&
\
echo
"#####################开始执行镜像推送############################"
sh /root/images/push-set-
`
date +%F-%H-%M
`
.sh
&&
\
for
i
in
${
image_list
[@]
}
mv /root/images/push-set-
`
date +%F-%H-%M
`
.sh /tmp
do
else
image_name
=
`
echo
$i
|awk -F
"/"
'{print $3}'
`
docker tag
$i
$harbor_host
/k8s/
$image_name
echo
"不存在/root/images.tar.gz,退出脚本"
echo
"开始push
$harbor_host
/k8s/
$image_name
镜像"
exit
466
docker push
$harbor_host
/k8s/
$image_name
done
for
j
in
${
image_list_ksy
[@]
}
do
image_name
=
`
echo
$j
|awk -F
"/"
'{print $4}'
`
docker tag
$j
$harbor_host
/k8s/
$image_name
echo
"开始push
$harbor_host
/k8s/
$image_name
镜像"
docker push
$harbor_host
/k8s/
$image_name
done
################################安装coredns以及nvidia-kubernetes插件##########
################################安装coredns以及nvidia-kubernetes插件##########
sed -i s/harbor_host/
$harbor_host
/g /root/k8s/config/coredns.yaml
sed -i s/harbor_host/
$harbor_host
/g /root/k8s/config/coredns.yaml
kubectl create -f /root/k8s/config/coredns.yaml
kubectl create -f /root/k8s/config/coredns.yaml
...
@@ -484,7 +473,7 @@ echo "alias kp='kubectl -n kpl'" >> ~/.bashrc
...
@@ -484,7 +473,7 @@ echo "alias kp='kubectl -n kpl'" >> ~/.bashrc
sleep 5
sleep 5
##############################################################################
##############################################################################
test
=
`
lspci |grep -i nvidia |wc -l
`
test
=
`
lspci |grep -i nvidia |wc -l
`
if
[
$test
-gt
0
]
;
then
if
[
$test
-gt
3
]
;
then
echo
"为gpu节点打lable"
&&
sleep 1
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
kubectl label node
$host_name
autodl
=
true
kpl
=
true
gpu
=
true
cpu
=
true
user_job_node
=
true
internal_service_node
=
true
else
else
...
...
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