Quick Start Kubernetes (K8S)-deploy Harbor (enterprise-level Docker private warehouse)

         The last article introduced you to the installation of k8s and clusters ( Quick Start Kubernetes (K8S)-Introduction and Installation ). This article mainly explains Harbor and the deployment of private Harbor warehouses .
Insert picture description here

1. What is Harbor

         The first time I heard the name should be the 2016 beginning of the year, it was in container technology has been the rise of the individual container management platform is at times crowded, mesos , Kubernetes , the Swarm and other various domestic and foreign manufacturers are used as a container Management system. At this time, a word " harbor" suddenly appeared , and my colleague introduced it like this: Several people from VMware China have built a container mirror warehouse. So became the first batch of users of harbor, and later also had the honor to become a contributor. After talking for a long time, what is harbor? Simply put, a container is a container. Where should the container be placed ? Yes, harbor! The official statement is: Harbor is an enterprise-level Registry server for storing and distributing Docker images.

Second, Harbor's architecture

Insert picture description here

Three, installation and deployment

Possess the environment:

  1. Docker must be installed successfully ( Quick Start Docker (1)-Introduction and Installation )
  2. Install docker-compose

1. Upload the jar package to the designated server, divided into harbor-offline-installer-v1.2.0.tgz and docker-compose
2. Decompress the uploaded jar package

tar -zxvf harbor-offline-installer-v1.2.0.tgz

3. Enter the directory to modify the configuration file

 cd harbor 
 vim harbor.cfg
# 修改的内容
# hostname  设置名称
hostname = hub.dashujulaoge.com
# 设置请求方式 默认是http 改为 https
ui_url_protocol = https

4. Set up https certificate

mkdir -p /data/cert
cd /data/cert
openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
# 设置 权限
chmod a+x *

5. Perform initialization

# 切换到 Harbor 工作目录
cd - 
./install.sh 
#看到以下内容说明执行成功
[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-adminserver ... done
Creating registry           ... done
Creating harbor-db          ... done
Creating harbor-ui          ... done
Creating nginx              ... done
Creating harbor-jobservice  ... done
✔ ----Harbor has been installed and started successfully.----

6. Page access for testing

Address: This is the IP of your virtual machine: The default port is 80. Here is 192.168.100.150
Account: admin Password (default): Harbor12345
Modify password: harbor.cfg Corresponding harbor_admin_password
Insert picture description here
extension: the docker file will be modified

 vim /etc/docker/daemon.json 
 # 添加一下内容
  "insecure-registries": ["https://hub.dashujulaoge.com"]

Four, test

4.1 Use docker to pull an image for testing

# 登录镜像
docker	 login https://hub.dashujulaoge.com 
#输入用户密码
# 拉去镜像进行测试
docker pull wangyanglinux/myapp:v1
# 将拉取的镜像文件推送上去
docker pull hub.dashujulaoge.com/library/myapp:v1

Insert picture description here

4.2 Use k8s to test whether the image is available

# nginx-deployment 任务名称
# image 私有仓库地址
# port 暴露端口
# replicas 副本数
kubectl  run nginx-deployment --image  hub.dashujulaoge.com/library/myapp:v1  --port=80 --replicas=3 
# 查看 运行情况
 get pod -o wide   

Seeing the following content shows that there is no problem when we create a private warehouse
Insert picture description here

Five, summary

         Well, here we have successfully built an enterprise-level Docker private warehouse. This article is over. If you need software, you can search the public account on WeChat [Big Data Brother] Reply: [k8s package ] Get the accessory package~~~ See you in the next issue.

6. Fan benefits and software acquisition

         Some friends who just started learning k8s have no goals, do not know how to learn, and how to learn what is in k8s . I’m here to prepare a learning flow chart for everyone who is interested in. You can get it by searching on WeChat [ big data brother ] and replying to [ k8s learning flow chart ].
Insert picture description here

Software acquisition

After the installation, you may need a lot of mirror files to download, which is very long. Big data brother is here to prepare for you. Wechat search the public account [big data brother] and reply [k8s package] to get it

Other benefits

You can get 200 customized resume templates, big data interview questions, corporate interview questions... and so on by searching on the WeChat public account [Big Data Brother].
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43791724/article/details/110721007