In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Original articles, welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!
Original link address: "Intermediate" CI/CD continuous Integration of docker-Project Generation Image (76)
At first, I wanted to use docker registry as a private mirror library, but then I gave up. People who know it should know that it doesn't have an interface. Later, I chose Harbor or created a virtual server through vagrant. In this way, a total of 3 servers were created. It is estimated that more than 3 are needed in the production environment to complete the continuous integration of CICD. The previous three requirements are all 4G dual-core, which is the requirement of gitlab,gitlabci,Harbor. My computer i7 processor, 16g memory, let the old man see the effect after running. Source code: https://github.com/limingios/docker/tree/master/No.11
Install vagrant reload through vagrant
Download Harbor to select the latest version 1.5.2
Https://github.com/vmware/harbor/releases
I chose the online version, and the two versions are basically the same. Sudo yum-y install lrzsz# uploads to rz at 1.5.2 online downloaded by windows
Decompress harbor
Tar xvf harbor-online-installer-v1.5.2.tgz
Installation
Cd harborsudo. / install.sh
It needs to be replaced with another installation method.
Sudo. / prepare
Real installation of sudo docker-compose up-d
Installation succeeded
Access to the machine: 172.28.128.6 I obtained the ip automatically
Normal access
User name: admin
Password: Harbor12345
You can execute the following command to stop and start
Stop it
Sudo docker-compose stop
Start
Sudo docker-compose start
Test harbor
Start the service
Sudo serivce docker restartcd harborsudo docker-compose start
Modify parameters
Docker pulls the image from the official by default, and since version 1.12, the default private repository is to use https for connection, so we need to make some changes here:
Sudo vi / etc/docker/daemon.json# writes {"insecure-registries": ["172.28.128.6"]} sudo systemctl restart docker
At present, many articles solve this problem by modifying the docker configuration file "etc/systemconfig/docker" and restarting docker. But found that the docker1.12.3 version does not have this file, according to the Internet to create this file, and fill in the corresponding content, restart docker has no effect, still report this error.
Solution: in the "/ etc/docker/" directory, create a "daemon.json" file. Write in a file
Harbor is the use of port 80, there is no need to configure port 5000 in docker-compose.yml.
# because http filtering is not configured, someone uses https and rejects it. Connect: connection refused# is configured with insecure-registriesserver gave HTTP response to HTTPS client above
Finally, log in and directly sudo docker login the private server address without any port number.
User name: admin
Password: Harbor12345
Try to create a new user in push image
New project
# this error is that the project has not been created. F9d9e4e6e2f0: Preparing denied: requested access to the resource is deniedpush Project sudo docker pull busyboxsudo docker tag busybox 172.28.128.6/idig8/busyboxsudo docker login 172.28.128.6-u idig8-p 123456789sudo docker push 172.28.128.6/idig8/busybox! [] (https://upload-images.jianshu.io/upload_images/11223715-32e7643aa5456e78.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)! [] (https://upload-images.jianshu.io/upload_images/11223715-c64af22cd5f5b5fb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)> finally succeeded It lasted for more than three hours, from 10:00 to 1 am. Smoking, Baidu inside too many tricks, many people write articles is directly copied, reprint I do not know whether he practiced or not, my side is to help you practice to tell you how to use. I feel that harbor is really much better than docker warehouse. The moment I saw Chinese, I felt that I had to use this to give up docker warehouse. # remote connection to harbor* to find the service file of Docker: log in to the server where Docker is installed, and enter systemctl status docker to view the service file of Docker. ```bashsudo systemctl status docker
Edit the docker.service file: add the-insecure-registry parameter at ExecStart.
Sudo vi / usr/lib/systemd/system/docker.service
Reload the service file and restart the docker service. Sudo systemctl daemon-reloadsudo systemctl restart docker
Try logging in to sudo docker login http://172.28.128.6-u admin-p Harbor12345 remotely
Gitlab gitlab-ci harbor
Type the corresponding image package to harbor via gitlab-ci
Modify. Gitlab-ci.yml
Add release to generate a mirror when packaging and send it to a remote harbor server.
In addition, although we need to add sudo before we connect to linux in the crt editor, we are not allowed to join sudo in script scripts, and an error will be reported if we add it.
Stages:-style-test- deploy-releasepep8: stage: style script:-pip install tox-tox-epep8 tags:-python2.7unittest-py27: stage: test script:-pip install tox-tox-ep y27 tags:-python2.7unittest-py34: stage: test script:-pip install tox-tox-e py34 tags:-python3/4docker-deploy: stage: deploy script:-docker build-t flask-demo. -if [$(docker ps-aq-- filter name=web)]; then docker rm-f web;fi-docker run-d-p 5000 then docker rm-name web flask-demo tags:-test1 only:-masterdocker-image-release: stage: release script:-docker login 172.28.128.6-u idig8-p 123456789-docker build-t 172.28.128.6/idig8/flask-demo:$CI_COMMIT_TAG. -docker login 172.28.128.6-u idig8-p 1qaz@WSX3edc-docker push 172.28.128.6/idig8/flask-demo:$CI_COMMIT_TAG tags:-test1 only:-tags
After this is executed, the pipline operation is performed automatically, and then branch from merge to master
.
After the pipline execution is passed, you can branch from merge to master.
Merging into the master branch automatically triggers pipline and performs multiple deploy operations
If we want to get to the master branch, what can we do if we just perform tag packaging to generate an image?
It seems to modify. Gitlab-ci.yml to add except in each task.
Stages:-style-test- deploy-releasepep8: stage: style script:-pip install tox-tox-epep8 tags:-python2.7 except:-tagsunittest-py27: stage: test script:-pip install tox-tox-e py27 tags:-python2.7 except:-tagsunittest-py34: stage: test script:-pip install tox-tox-e py34 tags: -python3/4 except:-tagsdocker-deploy: stage: deploy script:-docker build-t flask-demo. -if [$(docker ps-aq-- filter name=web)]; then docker rm-f web;fi-docker run-d-p 5000 then docker rm-name web flask-demo tags:-test1 only:-masterdocker-image-release: stage: release script:-docker login 172.28.128.6-u idig8-p 123456789-docker build-t 172.28.128.6/idig8/flask-demo:$CI_COMMIT_TAG. -docker login 172.28.128.6-u idig8-p 1qaz@WSX3edc-docker push 172.28.128.6/idig8/flask-demo:$CI_COMMIT_TAG tags:-test1 only:-tags New tag
New tag
Enter harbor and have a look.
PS: actually this example is the generation of a specific version of docker image. The release of a version represents the advent of a stable version of our software, and then we can deploy the stable version, whether the stable version is docker swarm or K8s. The most important thing is that we already have a docker image, which can be upgraded manually or automatically. Update docker image implements uninterrupted service.
Generally speaking, the process of these times is: after the development code is submitted to the branch, the branch verifies pipline, there is no problem, there is no problem in deploy, there is no problem in deploy testing, package tag, and form a stable dockerimage version.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.