Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to pull image creation service from Harbor by Kubernates

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how Kubernates pulls the image creation service from Harbor. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

1. Add Harbor to the insecure-registries of k8s host Docker

Modify the master of k8s and the / etc/docker/daemon.json of two node to put 192.168.33.5 into the insecure-registries, as follows:

List-1.1

[root@localhost data] # more / etc/docker/daemon.json {"bip": "172.172.172.1 24", "insecure-registries": ["10.221.128.52", "192.168.33.5"]}

Restart the Docker service, as shown in List-1.2

List-1.2

[root@localhost data] # systemctl daemon-reload [root@localhost data] # systemctl restart Docker

See if you can login to 192.168.33.5 on each node, as follows List-1.3

List-1.3

[root@localhost data] # docker login 192.168.33.5Username (mjduan): Password: Login Succeeded2, create a service on k8s with yaml

Execute the following List-2.1 on the master node to create the secret, where registry-harbor2 is the name, the value of namespace using the value of default,docker-server is the value of IP,docker-username of Harbor and the value of docker-password is the user created on Harbor.

List-2.1

Kubectl create secret docker-registry registry-harbor2-- namespace=default\-- docker-server= http://192.168.33.5-- docker-username=mjduan\-- docker-password=*-- docker-email=dmj1161859184@126.com

List-2.2 to view the created secret

[root@localhost data] # kubectl get secretNAME TYPE DATA AGEdefault-token-dqvqc kubernetes.io/service-account-token 3 12hregistry-harbor2 kubernetes.io/dockerconfigjson 1 5h

Create the nginx.yaml shown in the following List-2.3, and notice that the value of imagePullSecrets is registry-harbor2

List-2.3

ApiVersion: extensions/v1beta1kind: Deploymentmetadata: name: nginx-deployment labels: app: nginxspec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginxspec: containers:-name: nginx image: 192.168.33.5/project/nginx:1.0 imagePullPolicy: Always ports:-containerPort: 80 imagePullSecrets:-name: Registry-harbor2---apiVersion: v1kind: Servicemetadata: name: nginx-servicespec: type: NodePort sessionAffinity: ClientIP selector: app: nginx ports:-port: 80 nodePort: 30180

Then create the service with kubectl, as follows: List-2.4

List-2.4

[root@localhost data] # create-f deploy-nginx.yaml

View the results as follows: List-2.5

List-2.5

[root@localhost data] # kubectl get servicesNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes ClusterIP 10.96.0.1 443/TCP 12hnginx-service NodePort 10.103.100.169 80:30180/TCP 5h [root@localhost data] # kubectl get podsNAME READY STATUS RESTARTS AGEnginx -deployment-789794d957-m7wjv 1 Running 0 5h [root@localhost data] # this is the end of the article on "how Kubernates pulls the image creation service from Harbor". Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

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: 218

*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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report