Commit 3080f4fa by tingweiwang

gpu判断条件修复,修复预处理器推送镜像到kpl_k8s问题。

1 parent 9c938687
Showing with 15 additions and 26 deletions
......@@ -10,10 +10,8 @@ new_harbor_ip=192.168.1.32
harbor_host=192.168.1.32:5000
harbor_passwd=admin #写死的不能改,harbor配置文件中password写死了,当前只能是admin
harbor_user=admin
image_path=/root/images #写死的不能改
image_file=/root/images.tar.gz #写死的不能改
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`
harbor_user_name=admin
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
###################################根据不同节点类型,安装设置docker#####################################
echo "判断当前节点是gpu,还是cpu节点,根据节点不同,完成不同操作&& sleep 2"
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 "当前harbor仓库地址为$harbor_host"
sed -i s/harbor_host/$harbor_host/g /root/k8s/config/daemon.json_gpu
......@@ -447,27 +445,18 @@ echo "您的harbor服务器访问地址为:$harbor_host,已经自动创建harbor
sleep 4
docker login $harbor_host -uadmin -p$harbor_passwd
###########################推送私有镜像到harbor仓库#######
echo "####################开始执行镜像导入###########################"
for image in `ls $image_path|grep -Ev "*.sh"|grep -Ev "*.txt"|grep -Ev "images.tar.gz"`
do
echo "开始导入$image 镜像"
docker load -i $image_path/$image
done
echo "#####################开始执行镜像推送############################"
for i in ${image_list[@]}
do
image_name=`echo $i |awk -F "/" '{print $3}'`
docker tag $i $harbor_host/k8s/$image_name
echo "开始push $harbor_host/k8s/$image_name 镜像"
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
echo "####################判断私有镜像文件是否存在###########################"
test -f $image_file
if [ $? -eq 0 ]; then
echo "私有镜像文件存在,开始解压压缩包" && sleep 2 && tar -xvzf $image_file -C /root/ && \
cp -a /root/images/push-set.sh /root/images/push-set-`date +%F-%H-%M`.sh && \
sed -i s/harbor_host/$harbor_host/g /root/images/push-set-`date +%F-%H-%M`.sh && \
sh /root/images/push-set-`date +%F-%H-%M`.sh && \
mv /root/images/push-set-`date +%F-%H-%M`.sh /tmp
else
echo "不存在/root/images.tar.gz,退出脚本"
exit 466
################################安装coredns以及nvidia-kubernetes插件##########
sed -i s/harbor_host/$harbor_host/g /root/k8s/config/coredns.yaml
kubectl create -f /root/k8s/config/coredns.yaml
......@@ -484,7 +473,7 @@ echo "alias kp='kubectl -n kpl'" >> ~/.bashrc
sleep 5
##############################################################################
test=`lspci |grep -i nvidia |wc -l`
if [ $test -gt 0 ];then
if [ $test -gt 3 ];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
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!