K8s – Tutorial – Build Harbor private server for enterprise Image
January 27, 2024
by Amelia Jackson
No Comments
Write Dockerfile and upload DockerHub
Empty your cup so that it can be filled again. —— Bruce Lee
This paper introduces
P2 Build a production-level Linux system
P3 Learn Docker in half an hour
P4 Write Dockerfile and upload DockerHub
P5 Docker SpringCloud – compose deployment
P6 Build Harbor private server for enterprise mirror
P7 K8S & Rancher is coming! Theory & Preparation
P8 Rancher2.3 built K8S 1.16 cluster
P9 Deploy Spring Cloud to Kubernetes
P10 Deploy Vue to Kubernetes config ingress
P11 Ha01-rke install Kubernetes cluster
P12 HA02-Helm deploys the Rancher cluster
Build Harbor private server for enterprise mirror
According to Teacher Leng in the last course, Docker-compose has been installed. Again, for the record:
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose version
Copy the code
Version View:
docker version
docker-compose version
Copy the code
Install the Harbor
Harbor Offline Installer Harbor Online Installer The difference is that the Harbor Offline Installer contains the image file that Harbor needs to use. The file is downloaded successfully and decompressed
Tar - ZXVF harbor - offline installer - v1.9.3..tgz/root /cd harbor
vi harbor.yml
sh install.sh
Copy the code
Normal condition:
Special cases: The configuration needs to be modified, and the Docker version is abnormal
The default access account is admin/Harbor12345You can enter the configuration file to modifyDefault access port: 80Copy the code
Editing a Configuration File
Harbor. yml is the configuration file for this project
Modify the hostname preentry
Change hostname to your local address or IP address
Write a public IP address or domain name for public network access
hostname = A.B.C.D
Copy the code
run
After modifying the configuration file, run sh install.sh
Create a new project, name it Pig4Cloud, and set the access level to public. The project here is a privatized Docker image warehouse.
Upload the image
Modify the Docker configuration
Docker requests by HTTPS by default, so you need to modify the docker configuration. Change the address of the trusted library to “A.B.C.D” and “IP:PORT” to modify the file vim /etc/dock/daemon.json
{
"insecure-registries": [
"IP:PORT"]}Copy the code
Run systemctl daemon-reload and restart docker systemctl restart docker
To make the mirror
Make hello-k8s a private image. Hello-k8s is the image I pulled from the DockerHub.
# docker tag IP: PORT/pig4cloud/hello - k8s: 0.0.1Docker tag pig A.B.C.D/pig4cloud/hello - k8s: 0.0.1Copy the code
upload
Log in to the private library first
docker login IP:PORT
Copy the code
PUSH
Docker push IP: PORT/pig4cloud/hello - k8s: 0.0.1Copy the code
The image is already visible in the background
Problem of aggregation
The login problem
[root@blockgo k8s-nginx]# docker login IP:PORT
Username: huangbosbos
Password:
Error response from daemon: Get https://IP:PORT/v2/: http: server gave HTTP response to HTTPS client
Copy the code
Modify /etc/docker-daemon. json address to IP:PROT:
[root@blockgo ~]# docker login IP:PORT
Username: huangbosbos
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Copy the code
Upload problem
[root@blockgo k8s-nginx]# docker push IP:PORT/pig4cloud/hello-k8s
The push refers to repository [IP:PORT/pig4cloud/hello-k8s]
7c2f050e271f: Pushing 4.096kB
4fc1aa8003a3: Retrying in 1 second
5fb987d2e54d: Retrying in 1 second
831c5620387f: Retrying in 1 second
EOF
Copy the code
TODO may be a problem with nginx file upload restriction configuration.
Form a complete set of data
Please pay attention to wechat (Java-note), message: K8S for supporting information