当前位置: 代码迷 >> 综合 >> Harbor 调用API批量创建project
  详细解决方案

Harbor 调用API批量创建project

热度:100   发布时间:2023-09-30 13:16:45.0

Harbor创建项目的脚本 

curl -u "admin:Zhu88jie" -X POST -H "Content-Type: application/json" "http://139.198.170.122:7777/api/v2.0/projects" -d "{\"project_name\": \"test\", \"metadata\": {\"public\": \"true\"}, \"storage_limit\": -1}"

Harbor 调用API批量创建project

[root@k8s-master ~]# cat test1.sh 
#!/bin/bashurl="http://xxx:7777"
user="admin"
passwd="xxx"harbor_projects=(
calico \
coredns \
csiplugin \
elastic \
fluent \
grafana \
istio \
jaegertracing \
jenkins \
jimmidyson \
joosthofman \
kubeedge \
kubesphere \
kubespheredev \
library \
minio \
mirrorgooglecontainers \
nginxdemos \
openebs \
osixia \
prom \
thanosio \
weaveworks \
)for project in ${harbor_projects[@]} ; do curl -u "${user}:${passwd}" -X POST -H "Content-Type: application/json" "${url}/api/v2.0/projects" -d "{\"project_name\": \"${project}\", \"metadata\": {\"public\": \"true\"}, \"storage_limit\": -1}"; done
[root@k8s-master ~]# ./test1.sh 
{"errors":[{"code":"CONFLICT","message":"The project named calico already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named coredns already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named csiplugin already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named elastic already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named fluent already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named grafana already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named istio already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named jaegertracing already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named jenkins already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named jimmidyson already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named joosthofman already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named kubeedge already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named kubesphere already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named kubespheredev already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named library already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named minio already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named mirrorgooglecontainers already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named nginxdemos already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named openebs already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named osixia already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named prom already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named thanosio already exists"}]}
{"errors":[{"code":"CONFLICT","message":"The project named weaveworks already exists"}]}

Harbor 调用API批量创建project

[root@master01 harbor]# cp harbor.yml.tmpl  harbor.yaml
You have new mail in /var/spool/mail/root
[root@master01 harbor]# cp harbor.yaml  harbor.yaml.bakhostname: 192.168.0.8
harbor_admin_password: Zhu88jie
data_volume: /data/harbor_data:/data/harbor_data./install.sh  --with-chartmuseum[root@localhost ~]# vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd  -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry=192.168.0.8
[root@localhost ~]# systemctl daemon-reload 
[root@localhost ~]# systemctl restart docker 用户名admin vim /etc/docker/daemon.json[root@master02 ~]# cat /etc/docker/daemon.json
{"registry-mirrors": [ ],"insecure-registries": ["192.168.0.8"],"log-driver":"json-file","log-opts":{"max-size":"300m", "max-file":"3"}
}./offline-installation-tool.sh -l images-list.txt -d ./kubesphere-images -r 192.168.0.8[root@master1 ~]# docker images
REPOSITORY                                                TAG                            IMAGE ID       CREATED         SIZE
192.168.0.8/kubesphere/ks-installer                       v3.1.1                         a2516d950ca9   7 weeks ago     504MB
kubesphere/ks-installer                                   v3.1.1                         a2516d950ca9   7 weeks ago     504MB
192.168.0.8/kubesphere/kubectl                            v1.19.1                        104dfef9bb9f   7 weeks ago     79.9MB
kubesphere/kubectl                                        v1.19.1                        104dfef9bb9f   7 weeks ago     79.9MB
kubesphere/ks-controller-manager                          v3.1.1                         acc607b5666a   7 weeks ago     141MB
192.168.0.8/kubesphere/ks-controller-manager              v3.1.1                         acc607b5666a   7 weeks ago     141MB

确保每台上面docker都是启动,并且可以正常拉取镜像,才能使用kk 

  相关解决方案