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 fbf71e83
authored
Aug 31, 2020
by
tingweiwang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自动创建harbor项目目录
1 parent
b772c199
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
config/create_harbor_project.json
script/k8s/add_node.sh
script/k8s/deploy-gpu-k8s.sh
config/create_harbor_project.json
0 → 100644
View file @
fbf71e8
{
"project_name"
:
"k8s"
,
"public"
:
1
}
script/k8s/add_node.sh
View file @
fbf71e8
...
...
@@ -169,3 +169,10 @@ kubectl get csr|grep 'Pending' | awk 'NR>0{print $1}'| xargs kubectl certificate
#######################开机启动#############################################################
ansible new_node -m shell -a
"systemctl enable kubelet.service"
ansible new_node -m shell -a
"systemctl enable kube-proxy.service"
######################为新添加节点设置lable#################################################
echo
"分发kubectl以及kubeconfig,使node节点可以执行kubectl命令"
ansible new_node -m copy -a
"src=/usr/bin/kubectl dest=/usr/bin/kubectl mode-777"
ansible new_node -m shell -a
"mkdir /root/.kube/ -pv"
ansible new_node -m copy -a
"src=/root/.kube/config dest=/root/.kube/config mode=777"
echo
"根据自己的节点类型通过kubectl打标签"
ansible new_node -m shell -a
'if [ `lspci |grep -i nvidia|wc -l` -gt 0 ]; then echo "本机是gpu节点,开始打标签" && kubectl label node `hostname`; else echo "cpu节点安装docker"&& apt install docker-ce --allow-unauthenticated -y ; fi'
script/k8s/deploy-gpu-k8s.sh
View file @
fbf71e8
...
...
@@ -13,6 +13,17 @@ interface=eno1 #本机内网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_passwd
=
admin
harbor_auth_token
=
$(
echo
-n
"
${
harbor_user_name
}
:
${
harbor_passwd
}
"
| base64
harbor_project_list
=(
k8s
kpl_k8s
core
seetaas
autodl
autodl_workspace
)
#############################单节点nfs,则nfs server和nfs path配置一致,如果是三节点nfs,则配置nfs真实信息################
NFS_SERVER
=
192.168.1.53
NFS_PATH
=
/opt/registry/
...
...
@@ -427,8 +438,13 @@ ansible master -m shell -a "service docker restart"
echo
"解压harbor到/usr/local/目录"
tar -xvzf /root/k8s/package/harbor_aly.tar.gz -C /usr/local/
cd
/usr/local/harbor/
&&
sed -i s/harbor_host/
$harbor_host
/g harbor.cfg
&&
./prepare
&&
./install.sh
&&
echo
"harbor安装成功"
echo
"您的harbor服务器访问地址为:
$harbor_host
,请创建harbor所项目目录:k8s kpl_k8s core autodl seetaas autodl-workspace 您有90s的时间"
sleep 90
echo
"自动创建harbor项目目录"
&&
sleep 3
for
project
in
${
harbor_project_list
[@]
}
do
curl -k -X POST -H
"Authorization: Basic
${
harbor_auth_token
}
"
"http://
${
harbor_host
}
/api/projects"
-H
"accept: application/json"
-H
"Content-Type: application/json"
-d
'{"project_name": "'
${
project
}
'" ,"public": 1}'
done
echo
"您的harbor服务器访问地址为:
$harbor_host
,已经自动创建harbor所项目目录:k8s 、kpl_k8s 、core 、autodl、seetaas、autodl-workspace"
sleep 4
docker login
$harbor_host
-uadmin -p
$harbor_passwd
###########################推送私有镜像到harbor仓库#######
echo
"####################开始执行镜像导入###########################"
...
...
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