Kubernetes certification exam self-study series | Use harbor to build a private warehouse

Book source: "CKA/CKAD Test Guide: From Docker to Kubernetes Complete Raiders"

Organize the reading notes while studying, and share them with everyone. If the copyright is violated, it will be deleted. Thank you for your support!

Attach a summary post: Kubernetes certification exam self-study series | Summary_COCOgsta's Blog-CSDN Blog


2.3.1 install compose

In this experiment, the harbor is going to be built on vms101, so the following operations are performed on vms101.

Step 1: Install docker-compose using yum.

[root@vms101 ~]# yum install docker-compose -y
已加载插件: fastestmirror
base    | 3.6 kB  00:00:00
epel     | 5.4 kB  00:00:00
extras   | 3.4 kB  00:00:00
kubernetes/signature
...

已安装:
  docker-compose.noarch0:1.18.0-4.el7

作为依赖被安装:
  libtirpc.x86_64 0:0.2.4-0.16.el7        python3.x86_64 0:3.6.8-10.el7
  python3-libs.x86_64 0:3.6.8-10.el7      python3-pip.noarch
  python36-urllib3.noarch 0:1.25.6-1.el7  python36-websocket-client.noarch 0:0.47.0-2.el7

完毕!
[root@vms101 ~]#
复制代码

Step 2: Check the compose version.

[root@vms101 ~]# docker-compose -v
docker-compose version 1.18.0, build 8dd22a9
[root@vms101 ~]#
复制代码

2.3.2 install harbor

Step 1: Modify /etc/docker/daemon.json on vms101 and restart docker.

{
  "insecure-registries": ["192.168.26.101"]
}
复制代码

Restart docker.

[root@vms101 ~]# systemctl daemon-reload ; systemctl restart docker
[root@vms101 ~]#
复制代码

Step 2: Go to github.com/goharbor/ha ... to download the latest version of the harbor offline package and decompress it. After decompression, enter the directory harbor.

[root@vms101 ~]# tar zxvf harbor-offline-installer-v2.0.6.tgz
harbor/common/templates/
...
harbor/common.sh
harbor/harbor.yml.tmpl
[root@vms101 ~]#
[root@vms101 ~]# cd harbor/
[root@vms101 harbor]# ls
common.sh  harbor.v2.0.6.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare
[root@vms101 harbor]#
复制代码

Step 3: Import the images required by harbor.

[root@vms101 harbor]# docker load -i harbor.v2.0.6.tar.gz
16c66899afe2: Loading layer [=============>] 34.51MB/34.51MB
140ffb3df060: Loading layer [==============>] 9.639MB/9.639MB
...大量输出...
Loaded image: goharbor/registry-photon:v2.0.6
[root@vms101 harbor]#
复制代码

Step 4: Run the script ./prepare to perform some preparatory work.

[root@vms101 harbor]# ./prepare
prepare based iris set to/root/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http
protocol in the future. Please make sure to upgrade to https
   ...输出...
Clean up the input dir
[root@vms101 harbor]#
复制代码

Step 5: Generate the harbor.yml file.

[root@vms101 harbor]# cp harbor.yml.tmpl harbor.yml
[root@vms101 harbor]# 
复制代码

Edit the harbor.yml file, and modify the value of hostname to be the hostname.

5 hostname: vms101.rhce.cc
复制代码

Comment out the following lines. You can add "#" before the code, and the code with "#" will be commented out and will no longer take effect.

13 #https:
15 #  port: 443
17 #  certifcate: /your/certificate/path
18 #  private_key: /your/private/key/path
复制代码

Note that the preceding number is the line number.

harbor_admin_password is the password to log in to harbor, about line 34, here the default is Harbor12345, you can modify the administrator password here.

34 harbor_admin_password: Harbor12345
复制代码

Step 6: Run ./install.sh.

[root@vms101 harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.3
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 1.18.0
...
Creating nginx ...
Creating harbor-jobservice ...
√ ----Harbor has been installed and started successfully.----
[root@vms101 harbor]#
复制代码

Step 7: Enter 192.168.26.101 in the browser, as shown in Figure 2-4.

Enter admin as the user name, harbor12345 as the password, and click Login, as shown in Figure 2-5.

Note: Click "Light Theme" in the lower left corner, and the color of the entire panel is displayed in a light color.

Step 8: Click Project→New Project, as shown in Figure 2-6.

Enter cka for the project name, select public for the access level, and click the "OK" button.

Step 9: Select System Management→User Management→Create User, as shown in Figure 2-7.

Set the information of the newly created user and click the "OK" button.

Step 10: Add users to the project.

Click Project→cka, as shown in Figure 2-8.

Click +User, as shown in Figure 2-9 and Figure 2-10.

Enter tom in the name, select the project administrator for the role, and click the "OK" button.

Click the mirror warehouse, and you can see that there is no mirror, as shown in Figure 2-11.

The following operates on the client vms100.

Step 11: Because the private warehouse has been replaced, /etc/docker/daemon.json needs to be modified, as shown below.

[root@vms100 ~]# cat/etc/docker/daemon.json
{
  "registry-mirrors": ["https://frz7i079.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.26.101"]
}
[root@vms100 ~]#
复制代码

Step 12: Restart docker.

[root@vms100 ~]# systemctl restart docker 
[root@vms100 ~]# 
复制代码

Step 13: Log in to the private repository.

[root@vms100 ~]# docker login 192.168.26.101
Username:tom
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/confg.json.Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store 

Login Succeeded
[root@vms100 ~]#
复制代码

Step 14: Test push image.

[root@vms100 ~]# docker tag centos:v1 192.168.26.101/cka/centos:v1
[root@vms100 ~]# 
[root@vms100 ~]# docker push 192.168.26.101/cka/centos:v1
The push refers to a repository [192.168.26.101/cka/centos]
589830c63604: Pushed
b362758f4793: Pushing[=================>
...
v1: digest: sha256:441d92a9bcead3118b4be261497af size: 741
[root@vms100 ~]#
复制代码

Step 15: Open the harbor management page, as shown in Figure 2-12.

You can already see the image that was just pushed here.

Guess you like

Origin blog.csdn.net/guolianggsta/article/details/130461207