<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://blog.kali-team.cn/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https://blog.kali-team.cn</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>
            这是Web Feed，又称为Atom Feed，把现在的网址复制到新闻阅读器即可订阅本站文章。造访「About Feeds」来了解更多资讯。
        </tabi:about_feeds>
        <tabi:visit_the_site>
            造访网站
        </tabi:visit_the_site>
        <tabi:recent_posts>
            近期文章
        </tabi:recent_posts>
        <tabi:last_updated_on>
            更新于 $DATE
        </tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>harbor</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://blog.kali-team.cn/skins/arch.css?h=8b651815fde702215b07" /><title>Kali-Team - harbor</title>
        <subtitle>三米前有蕉皮的博客</subtitle>
    <link href="https://blog.kali-team.cn/tags/harbor/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://blog.kali-team.cn/tags/harbor/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2026-10-18T00:00:00+00:00</updated><id>https://blog.kali-team.cn/tags/harbor/atom.xml</id><entry xml:lang="en">
        <title>安全开发-Harbor</title>
        <published>2026-10-18T00:00:00+00:00</published>
        <updated>2026-10-18T00:00:00+00:00</updated>
        <author>
            <name>三米前有蕉皮</name>
        </author>
        <link rel="alternate" href="https://blog.kali-team.cn/blog/2026/09/安全开发-Harbor/" type="text/html"/>
        <id>https://blog.kali-team.cn/blog/2026/09/安全开发-Harbor/</id>
        
            <content type="html">&lt;h2 id=&quot;qian-yan&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#qian-yan&quot; aria-label=&quot;Anchor link for: qian-yan&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
前言&lt;/h2&gt;
&lt;p&gt;Rancher 集群、Gitea 代码与流水线、Nexus 制品源就位之后，还差一环：CI/CD 的最终产物——容器镜像放哪？内部镜像不宜公开，本文在内网自建私有镜像仓库 &lt;strong&gt;Harbor&lt;/strong&gt;（CNCF 毕业项目，可理解为“自托管 Docker Hub“，多权限管理、robot 账号、内置 Trivy 扫描、pull-through 镜像代理）。&lt;/p&gt;
&lt;p&gt;本文做三件事：搭建（Rancher chart + Gitea OIDC 登录）、使用（仓库管理、pull-through 缓存、项目权限、&lt;code&gt;docker login/pull/push&lt;/code&gt;）、CI/CD 联动（robot 账号推镜像 + Trivy 扫描结果）。&lt;/p&gt;
&lt;h2 id=&quot;1-bei-jing-gai-nian&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#1-bei-jing-gai-nian&quot; aria-label=&quot;Anchor link for: 1-bei-jing-gai-nian&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
1 背景概念&lt;/h2&gt;
&lt;h3 id=&quot;1-1-jing-xiang-ming-tag-yu-digest&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#1-1-jing-xiang-ming-tag-yu-digest&quot; aria-label=&quot;Anchor link for: 1-1-jing-xiang-ming-tag-yu-digest&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
1.1 镜像名、tag 与 digest&lt;/h3&gt;
&lt;p&gt;镜像名完整写法分三段：&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;registry 域名 / 项目名 / 镜像名 : tag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mirror.kali-team.internal / dev-sec-ops / example-server : 1.0.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;└─ 从哪取（registry）┘  └── 分组 ──┘ └── 哪个镜像 ──┘ └─ 版本标签&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;tag&lt;/strong&gt; 是版本标签（&lt;code&gt;1.0.0&lt;/code&gt;、&lt;code&gt;latest&lt;/code&gt;）；&lt;strong&gt;digest&lt;/strong&gt;（&lt;code&gt;sha256:...&lt;/code&gt;）是内容指纹，内容相同则指纹相同。流水线给同一镜像推 &lt;code&gt;1.0.0&lt;/code&gt; 和 &lt;code&gt;latest&lt;/code&gt; 两个 tag、指向同一 digest，即“版本号与最新版指向同一份内容“。&lt;/p&gt;
&lt;h3 id=&quot;1-2-project-yu-ke-jian-xing&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#1-2-project-yu-ke-jian-xing&quot; aria-label=&quot;Anchor link for: 1-2-project-yu-ke-jian-xing&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
1.2 project 与可见性&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;project&lt;/strong&gt; 是镜像的分组，有可见性：&lt;strong&gt;公开&lt;/strong&gt;（登录即可拉，配置允许时匿名也可）/ &lt;strong&gt;私有&lt;/strong&gt;（仅授权用户、组可拉）。本环境约定：构建产物一律进私有 project；&lt;code&gt;library&lt;/code&gt; 是 Harbor 自动建的默认公开 project。&lt;/p&gt;
&lt;h3 id=&quot;1-3-pull-through-huan-cun&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#1-3-pull-through-huan-cun&quot; aria-label=&quot;Anchor link for: 1-3-pull-through-huan-cun&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
1.3 pull-through 缓存&lt;/h3&gt;
&lt;p&gt;内网到不了公网，Harbor 的 &lt;strong&gt;pull-through cache&lt;/strong&gt;（镜像代理）解决拉取问题：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;拉 &lt;code&gt;mirror.kali-team.internal/docker.io/nats:latest&lt;/code&gt; 时，Harbor 本地没有就替你去上游取一份、缓存本地再给你，下次命中本地缓存。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;上游源在 4.1 登记。设计约束：代理项目&lt;strong&gt;只读&lt;/strong&gt;，不能往里 push。&lt;/p&gt;
&lt;h3 id=&quot;1-4-zui-xiao-quan-xian&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#1-4-zui-xiao-quan-xian&quot; aria-label=&quot;Anchor link for: 1-4-zui-xiao-quan-xian&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
1.4 最小权限&lt;/h3&gt;
&lt;p&gt;人走 OIDC + CLI 密码，组只给只读，robot 只给最小写权限。&lt;/p&gt;
&lt;h2 id=&quot;2-da-jian-rancher-chart-bu-shu-harbor&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#2-da-jian-rancher-chart-bu-shu-harbor&quot; aria-label=&quot;Anchor link for: 2-da-jian-rancher-chart-bu-shu-harbor&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
2 搭建：Rancher chart 部署 Harbor&lt;/h2&gt;
&lt;h3 id=&quot;2-1-chart-ban-ben&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#2-1-chart-ban-ben&quot; aria-label=&quot;Anchor link for: 2-1-chart-ban-ben&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
2.1 chart 版本&lt;/h3&gt;
&lt;p&gt;Harbor chart 版本 1.19.2，对应应用版本 2.15.2，部署在 &lt;code&gt;mirror&lt;/code&gt; 命名空间。&lt;/p&gt;
&lt;h3 id=&quot;2-2-tian-jia-chart-cang-ku-bing-chuang-jian-ying-yong&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#2-2-tian-jia-chart-cang-ku-bing-chuang-jian-ying-yong&quot; aria-label=&quot;Anchor link for: 2-2-tian-jia-chart-cang-ku-bing-chuang-jian-ying-yong&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
2.2 添加 chart 仓库并创建应用&lt;/h3&gt;
&lt;p&gt;在 Rancher 的 &lt;strong&gt;Chart 仓库&lt;/strong&gt;里添加 Harbor 官方 chart 仓库 &lt;code&gt;https://helm.goharbor.io/&lt;/code&gt; 并更新，然后从目录创建应用：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-rancher-chart.png&quot; alt=&quot;Rancher 里的 harbor chart 页面&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 1：Rancher Chart 目录中的 harbor chart（1.19.2，应用版本 2.15.2）&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;2-3-helm-values-gai-dong&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#2-3-helm-values-gai-dong&quot; aria-label=&quot;Anchor link for: 2-3-helm-values-gai-dong&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
2.3 Helm values 改动&lt;/h3&gt;
&lt;p&gt;安装的时候基本不需要修改配置，我只改了 ingress 的域名。相对 chart 默认值的 diff 如下：&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;diff&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;@@&lt;/span&gt;&lt;span&gt; ingress annotations&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt; @@&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       ingress.kubernetes.io/ssl-redirect: &amp;#39;true&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       nginx.ingress.kubernetes.io/proxy-body-size: &amp;#39;0&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       nginx.ingress.kubernetes.io/ssl-redirect: &amp;#39;true&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-11&quot;&gt;    className: &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;      traefik.ingress.kubernetes.io/request-buffering: &amp;#39;off&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;      traefik.ingress.kubernetes.io/response-buffering: &amp;#39;off&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;    className: traefik&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     controller: default&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     hosts:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-11&quot;&gt;      core: core.harbor.domain&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;      core: mirror.kali-team.internal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     kubeVersionOverride: &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     labels: {}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;@@&lt;/span&gt;&lt;span&gt; ingress tls&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt; @@&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     auto:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       commonName: &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     certSource: auto&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-11&quot;&gt;    enabled: true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;    enabled: false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     secret:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       secretName: &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   type: ingress&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-11&quot;&gt;externalURL: https://core.harbor.domain&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;externalURL: https://mirror.kali-team.internal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   harborAdminPassword: &amp;lt;HARBOR_INITIAL_ADMIN_PASSWORD&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   imagePullPolicy: IfNotPresent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   imagePullSecrets: null&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;逐项说明：&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;配置&lt;/th&gt;&lt;th&gt;原因&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;hosts.core: mirror.kali-team.internal&lt;/code&gt;&lt;/td&gt;&lt;td&gt;核心改动：chart 默认占位域名 &lt;code&gt;core.harbor.domain&lt;/code&gt; 内网不通，换成内网 DNS 域名&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;className&lt;/code&gt; / buffering 两行&lt;/td&gt;&lt;td&gt;ingress 走集群现有的 Traefik 网关，顺手关掉缓冲（镜像层可能上百 MB，流式通过更稳）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;tls.enabled: false&lt;/code&gt;&lt;/td&gt;&lt;td&gt;证书由网关统一终结（内网 CA 签发），关 chart 自带 TLS 避免“两套证书“&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;externalURL&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Harbor 用它生成 OIDC 回调 / 跳转地址，必须等于浏览器实际打开的域名&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;harborAdminPassword&lt;/code&gt;&lt;/td&gt;&lt;td&gt;初始 admin 密码，全文占位；会写进 K8s Secret，忘了可从 Secret 取回&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;其余 values 保持 chart 默认。&lt;/p&gt;
&lt;h3 id=&quot;2-4-an-zhuang-qu-hui-chu-shi-mi-ma-bing-yan-zheng&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#2-4-an-zhuang-qu-hui-chu-shi-mi-ma-bing-yan-zheng&quot; aria-label=&quot;Anchor link for: 2-4-an-zhuang-qu-hui-chu-shi-mi-ma-bing-yan-zheng&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
2.4 安装、取回初始密码并验证&lt;/h3&gt;
&lt;p&gt;在 chart 页面点部署，很快安装完成。输出里看这几行就够：&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;NAME:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; mirror&lt;/span&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;                  # 应用（release）名：mirror&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;LAST&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; DEPLOYED: Sun Sep&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 13&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; 14:14:15&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 2026&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;NAMESPACE:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; mirror&lt;/span&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;             # 部署到 mirror 命名空间&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;STATUS:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; deployed&lt;/span&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;              # 部署完成&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;REVISION:&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;NOTES:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; wait for several minutes for Harbor deployment to complete.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;Then&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; you should be able to visit the Harbor portal at https://mirror.kali-team.internal&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;初始密码若没记住，从 chart 建的 Secret 里取回：&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 做什么：读 mirror 命名空间里 mirror-harbor-core 这个 secret 的 HARBOR_ADMIN_PASSWORD 字段&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 怎么做：kubectl 按 jsonpath 取出该字段（base64 形式），管道给 base64 -d 解码&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;kubectl&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; get secret mirror-harbor-core -n mirror -o jsonpath=&amp;quot;{.data.HARBOR_ADMIN_PASSWORD}&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 输出：&amp;lt;HARBOR_INITIAL_ADMIN_PASSWORD&amp;gt;（已脱敏）&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;用 &lt;code&gt;admin&lt;/code&gt; + 初始密码登录，首次登录后建议改密码，新密码按凭据规范存放。&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-project-library.png&quot; alt=&quot;Harbor 项目页（admin 登录态）&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 2：Harbor 首次登录后的项目列表：默认公开 project library 已就位（同时验证 ingress 域名、内网 CA 证书、服务本体）&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;3-pei-zhi-oidc-deng-lu-yong-gitea-zhang-hao-jin-harbor&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#3-pei-zhi-oidc-deng-lu-yong-gitea-zhang-hao-jin-harbor&quot; aria-label=&quot;Anchor link for: 3-pei-zhi-oidc-deng-lu-yong-gitea-zhang-hao-jin-harbor&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
3 配置 OIDC 登录：用 Gitea 账号进 Harbor&lt;/h2&gt;
&lt;p&gt;Gitea 是 OIDC 身份提供方（IdP），接入方式与其它平台相同，两侧各一步。&lt;/p&gt;
&lt;h3 id=&quot;3-1-gitea-ce-chuang-jian-oauth2-ying-yong&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#3-1-gitea-ce-chuang-jian-oauth2-ying-yong&quot; aria-label=&quot;Anchor link for: 3-1-gitea-ce-chuang-jian-oauth2-ying-yong&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
3.1 Gitea 侧：创建 OAuth2 应用&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;dev-sec-ops&lt;/code&gt; 组织 → &lt;strong&gt;设置 → 应用 → 创建 OAuth2 应用程序&lt;/strong&gt;：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;应用名称&lt;/strong&gt;：&lt;code&gt;Harbor&lt;/code&gt;；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;重定向 URL&lt;/strong&gt;：&lt;code&gt;https://mirror.kali-team.internal/c/oidc/callback&lt;/code&gt;（Harbor 侧的固定回调地址，在 Harbor 配置管理最下方可见，照着抄即可）；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;客户端类型&lt;/strong&gt;：机密客户端（confidential）。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;创建后 Gitea 颁发 &lt;strong&gt;Client ID&lt;/strong&gt; / &lt;strong&gt;Client Secret&lt;/strong&gt;，占位 &lt;code&gt;&amp;lt;client-id&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;client-secret&amp;gt;&lt;/code&gt;，只写进 Harbor 配置。&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/gitea-oauth-app-harbor.png&quot; alt=&quot;Gitea 组织里的 Harbor OAuth2 应用&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 3：Gitea dev-sec-ops 组织的 OAuth2 应用：应用名 Harbor，重定向 URL 指向 Harbor 的 OIDC 回调，机密客户端（Client ID / Secret 已打码）&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;3-2-harbor-ce-tian-oidc-she-zhi&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#3-2-harbor-ce-tian-oidc-she-zhi&quot; aria-label=&quot;Anchor link for: 3-2-harbor-ce-tian-oidc-she-zhi&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
3.2 Harbor 侧：填 OIDC 设置&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;系统管理 → 配置管理&lt;/strong&gt;，OIDC 一节的关键项：&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;字段&lt;/th&gt;&lt;th&gt;值&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;启用 OIDC&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;开&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;提供方名称&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;Gitea&lt;/code&gt;（登录按钮上显示的名称）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Endpoint（Issuer）&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;https://hub.kali-team.internal&lt;/code&gt;（Harbor 读它的 &lt;code&gt;.well-known/openid-configuration&lt;/code&gt; 发现端点，自动找到授权 / 令牌端点）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Client ID / Client Secret&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;&amp;lt;client-id&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;client-secret&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;组声明（group claim）&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;groups&lt;/code&gt;（Harbor 按它同步用户组成员关系）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Scopes&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;openid,profile,email,groups&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-oidc-settings.png&quot; alt=&quot;Harbor 的 OIDC 配置&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 4：Harbor 配置管理的 OIDC 一节：提供方 Gitea，Endpoint 指向 hub.kali-team.internal，组声明 groups（Client ID 已打码）&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;3-3-yan-zheng&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#3-3-yan-zheng&quot; aria-label=&quot;Anchor link for: 3-3-yan-zheng&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
3.3 验证&lt;/h3&gt;
&lt;p&gt;登出 admin 回到登录页，出现两个入口：“&lt;strong&gt;通过 gitea 登录&lt;/strong&gt;“与”&lt;strong&gt;通过本地数据库登录&lt;/strong&gt;“。点前者，浏览器跳 Gitea 授权同意页后自动回 Harbor，全程无密码登录，右上角显示当前 Gitea 身份。&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/gitea-oidc-consent-harbor.png&quot; alt=&quot;Gitea 授权同意页&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 5：Gitea 授权同意页：授权 Harbor 访问您的帐户，应用由 @dev-sec-ops 创建&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-login-oidc.png&quot; alt=&quot;Harbor 登录页&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 6：启用 OIDC 后的 Harbor 登录页：「通过 gitea 登录」与「通过本地数据库登录」两个入口&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;4-shi-yong-cang-ku-xiang-mu-yu-quan-xian&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#4-shi-yong-cang-ku-xiang-mu-yu-quan-xian&quot; aria-label=&quot;Anchor link for: 4-shi-yong-cang-ku-xiang-mu-yu-quan-xian&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
4 使用：仓库、项目与权限&lt;/h2&gt;
&lt;h3 id=&quot;4-1-cang-ku-guan-li-deng-ji-wu-ge-shang-you-yuan&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#4-1-cang-ku-guan-li-deng-ji-wu-ge-shang-you-yuan&quot; aria-label=&quot;Anchor link for: 4-1-cang-ku-guan-li-deng-ji-wu-ge-shang-you-yuan&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
4.1 仓库管理：登记五个上游源&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;仓库管理&lt;/strong&gt;（系统管理 → 仓库管理）是上游源登记处。本环境登记 5 个代理目标：&lt;code&gt;registry.k8s.io&lt;/code&gt;、&lt;code&gt;quay.io&lt;/code&gt;、&lt;code&gt;ghcr.io&lt;/code&gt;、&lt;code&gt;gcr.io&lt;/code&gt;、&lt;code&gt;docker.io&lt;/code&gt;，上游指向 daocloud，状态全部健康：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-registry-caches.png&quot; alt=&quot;Harbor 仓库管理&quot; /&gt;
&lt;em&gt;图 7：五个代理目标，上游指向 daocloud 镜像源，全部健康&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;注意：这些是&lt;strong&gt;部分镜像源&lt;/strong&gt;，&lt;code&gt;docker/dind&lt;/code&gt;、&lt;code&gt;docker/buildx&lt;/code&gt;、&lt;code&gt;moby/buildkit&lt;/code&gt; 会 404（详见“常见问题与坑“）。&lt;/p&gt;
&lt;h3 id=&quot;4-2-chuang-jian-pull-through-xiang-mu-docker-io&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#4-2-chuang-jian-pull-through-xiang-mu-docker-io&quot; aria-label=&quot;Anchor link for: 4-2-chuang-jian-pull-through-xiang-mu-docker-io&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
4.2 创建 pull-through 项目：docker.io&lt;/h3&gt;
&lt;p&gt;建项目 &lt;code&gt;docker.io&lt;/code&gt;，打开&lt;strong&gt;镜像代理&lt;/strong&gt;开关，上游 URL 指向 &lt;code&gt;https://docker.m.daocloud.io&lt;/code&gt;：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-pull-through-project.png&quot; alt=&quot;新建 pull-through 项目 docker.io&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 8：新建项目 docker.io：打开“镜像代理“开关，上游 URL 指向 daocloud 镜像源&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;实操：&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 做什么：登录私有仓库（docker CLI 只认&amp;quot;用户名 + 密码&amp;quot;，不走 OIDC）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;docker&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; login mirror.kali-team.internal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# Username: Kali-Team（OIDC 用户）  Password: （略，4.4 设置的 CLI 密码）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 输出 Login Succeeded；注意 docker 默认把凭据明文存进 ~/.docker/config.json，&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 个人机器上可接受，共享机器建议配置 credential helper（输出里有警告提示）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 做什么：经由代理拉一个镜像&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;docker&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; pull mirror.kali-team.internal/docker.io/nats:latest&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 首拉：Harbor 替我们从上游 daocloud 取回并缓存本地&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# Digest: sha256:c50b0a773c6c8d033cad54f7c53cb97fd6e09b3bfc1accda7cd4fa94e19e9ed9&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;再拉一次命中本地缓存。上游没有该镜像时 Harbor 透传 404——先确认上游能否拉到，别误以为是 Harbor 配错。&lt;/p&gt;
&lt;h3 id=&quot;4-3-quan-xian-gei-dev-sec-ops-zu-fang-ke-jiao-se&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#4-3-quan-xian-gei-dev-sec-ops-zu-fang-ke-jiao-se&quot; aria-label=&quot;Anchor link for: 4-3-quan-xian-gei-dev-sec-ops-zu-fang-ke-jiao-se&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
4.3 权限：给 dev-sec-ops 组“访客“角色&lt;/h3&gt;
&lt;p&gt;代理项目内容来自公开上游，团队只需读权限。项目成员管理页添加 &lt;code&gt;dev-sec-ops&lt;/code&gt; 组，角色&lt;strong&gt;访客（guest）&lt;/strong&gt;（Harbor 项目级角色三种：管理员 / 开发者 / 访客，1.4 的最小权限体现）：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-project-member-group.png&quot; alt=&quot;项目添加组成员（访客角色）&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 9：docker.io 项目的成员管理中添加 dev-sec-ops 组，角色为访客（只读）&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;4-4-oidc-yong-hu-de-cli-mi-ma&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#4-4-oidc-yong-hu-de-cli-mi-ma&quot; aria-label=&quot;Anchor link for: 4-4-oidc-yong-hu-de-cli-mi-ma&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
4.4 OIDC 用户的 CLI 密码&lt;/h3&gt;
&lt;p&gt;换普通用户（Kali-Team）登录，右上角 → 个人信息 → &lt;strong&gt;用户设置&lt;/strong&gt;：可见身份来源 “Onboarded via OIDC provider”（首次 OIDC 登录自动建号），以及一个 &lt;strong&gt;CLI 密码&lt;/strong&gt;字段。OIDC 只服务 Web 登录，&lt;code&gt;docker login&lt;/code&gt; 只认“用户名 + 密码“或 robot 账号，所以每个用户单独留了一个 CLI 密码，设置后 4.2 的登录才能跑通（详见“常见问题与坑“）：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-user-settings.png&quot; alt=&quot;用户设置页&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 10：Kali-Team 账号的用户设置：CLI 密码供 &lt;code&gt;docker login&lt;/code&gt; 使用（界面显示为圆点）&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;项目页可看到 &lt;code&gt;docker.io&lt;/code&gt; 与 &lt;code&gt;library&lt;/code&gt; 两个 project；“其他操作“菜单里有&lt;strong&gt;导出 CVEs&lt;/strong&gt;，把漏洞扫描结果导出成文件（第 5 章）：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-project-cve-export.png&quot; alt=&quot;项目页与导出 CVEs 菜单&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 11：项目列表：“其他操作“菜单里的“导出 CVEs”&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;4-5-kai-fa-ji-shou-dong-tui-song&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#4-5-kai-fa-ji-shou-dong-tui-song&quot; aria-label=&quot;Anchor link for: 4-5-kai-fa-ji-shou-dong-tui-song&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
4.5 开发机手动推送&lt;/h3&gt;
&lt;p&gt;四步：&lt;strong&gt;前提&lt;/strong&gt;是机器信任内网 CA（&lt;code&gt;docker login/push&lt;/code&gt; 走 https，加信任与流水线 “Verify Certificate” 是同一套双通道，6.1）；然后 &lt;code&gt;docker login&lt;/code&gt;（CLI 密码）；项目页的&lt;strong&gt;推送命令&lt;/strong&gt;按钮直接给出完整目标地址（形如 &lt;code&gt;mirror.kali-team.internal/&amp;lt;项目名&amp;gt;/&amp;lt;仓库名&amp;gt;:&amp;lt;tag&amp;gt;&lt;/code&gt;，以页面显示为准）；最后：&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 做什么：把本地镜像改名为 Harbor 目标地址，再推送&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 怎么做：docker tag 给本地镜像起&amp;quot;新名字&amp;quot;（不复制内容，只是加别名）；&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;#         docker push 把镜像内容推到目标&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# 为什么：tag 的目标地址必须与项目页显示一字不差（项目名、仓库名、tag）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;docker&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; tag&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;本地镜&lt;/span&gt;&lt;span&gt;像&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;本地ta&lt;/span&gt;&lt;span&gt;g&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; mirror.kali-team.internal/&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;项目&lt;/span&gt;&lt;span&gt;名&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;仓库&lt;/span&gt;&lt;span&gt;名&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;ta&lt;/span&gt;&lt;span&gt;g&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;docker&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; push mirror.kali-team.internal/&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;项目&lt;/span&gt;&lt;span&gt;名&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;仓库&lt;/span&gt;&lt;span&gt;名&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;ta&lt;/span&gt;&lt;span&gt;g&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;验证：项目页该仓库的 Artifacts 列表出现新 tag，或换一台机器 &lt;code&gt;docker pull&lt;/code&gt; 同一地址。边界：pull-through 代理项目只读、push 被拒（详见“常见问题与坑“），构建产物进私有项目 &lt;code&gt;dev-sec-ops&lt;/code&gt;。&lt;code&gt;podman push&lt;/code&gt; 与 &lt;code&gt;helm push oci://mirror.kali-team.internal/&amp;lt;项目名&amp;gt;&lt;/code&gt;（以 OCI 格式推 Helm Chart）是同一套“登录 + 目标地址“逻辑。&lt;/p&gt;
&lt;h3 id=&quot;4-6-zhu-jie-mian-su-lan&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#4-6-zhu-jie-mian-su-lan&quot; aria-label=&quot;Anchor link for: 4-6-zhu-jie-mian-su-lan&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
4.6 主界面速览&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;项目列表&lt;/strong&gt;（登录后主界面）：所有项目的入口；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;仓库列表&lt;/strong&gt;（项目页）：项目下的仓库（即镜像），代理项目这里就是从上游取回并缓存的镜像列表；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;镜像详情（Artifacts 页）&lt;/strong&gt;：一行一个 tag——tag 名、digest、大小、推送 / 拉取时间、可直接复制的 &lt;code&gt;docker pull&lt;/code&gt; 命令，页面还有&lt;strong&gt;按需扫描&lt;/strong&gt;入口。&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;5-jing-xiang-sao-miao-rang-trivy-cheng-zhao-jing-xiang&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#5-jing-xiang-sao-miao-rang-trivy-cheng-zhao-jing-xiang&quot; aria-label=&quot;Anchor link for: 5-jing-xiang-sao-miao-rang-trivy-cheng-zhao-jing-xiang&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
5 镜像扫描：让 Trivy 盯着镜像&lt;/h2&gt;
&lt;h3 id=&quot;5-1-sao-miao-qi-shi-xian-cheng-de-trivy&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#5-1-sao-miao-qi-shi-xian-cheng-de-trivy&quot; aria-label=&quot;Anchor link for: 5-1-sao-miao-qi-shi-xian-cheng-de-trivy&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
5.1 扫描器是现成的：Trivy&lt;/h3&gt;
&lt;p&gt;chart 自带 &lt;strong&gt;Trivy&lt;/strong&gt; 扫描器，不用另装。配置页显示：Trivy v0.72.0，默认扫描器且已启用，支持&lt;strong&gt;漏洞扫描&lt;/strong&gt;与 &lt;strong&gt;SBOM 生成&lt;/strong&gt;（SBOM = 软件物料清单），严重级别 &lt;code&gt;UNKNOWN, LOW, MEDIUM, HIGH, CRITICAL&lt;/code&gt; 全开：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-scanner-trivy.png&quot; alt=&quot;Trivy 扫描器配置&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 12：Harbor 镜像扫描器页：Trivy v0.72.0（默认、已启用），严重级别 UNKNOWN–CRITICAL 全开&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Trivy 拉下镜像、解开系统包与应用依赖，逐个对照漏洞数据库匹配（漏洞库由 Trivy 后台下载，下载慢 / 不全时换镜像源，详见“常见问题与坑“）。触发方式两种：&lt;strong&gt;按需&lt;/strong&gt;（镜像页点“扫描“）与&lt;strong&gt;自动&lt;/strong&gt;（推送后按扫描策略）。&lt;/p&gt;
&lt;h3 id=&quot;5-2-bei-sao-de-jing-xiang-cong-na-lai&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#5-2-bei-sao-de-jing-xiang-cong-na-lai&quot; aria-label=&quot;Anchor link for: 5-2-bei-sao-de-jing-xiang-cong-na-lai&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
5.2 被扫的镜像从哪来&lt;/h3&gt;
&lt;p&gt;代理项目的仓库列表就是 pull-through 缓存的台账：&lt;code&gt;goharbor/*&lt;/code&gt;（Harbor 自家组件）、&lt;code&gt;bitnamilegacy/*&lt;/code&gt;（Nexus / Dependency-Track 用的共享 PostgreSQL 等）、&lt;code&gt;nats&lt;/code&gt;、&lt;code&gt;postgres&lt;/code&gt;、&lt;code&gt;rancher&lt;/code&gt; 等共 99 条：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-docker-io-repositories.png&quot; alt=&quot;docker.io 项目的镜像仓库列表&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 13：docker.io 项目的镜像仓库列表：goharbor/&lt;/em&gt;、bitnamilegacy/&lt;em&gt;、nats、postgres、rancher 等共 99 条&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;5-3-sao-miao-jie-guo-zen-me-du&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#5-3-sao-miao-jie-guo-zen-me-du&quot; aria-label=&quot;Anchor link for: 5-3-sao-miao-jie-guo-zen-me-du&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
5.3 扫描结果怎么读&lt;/h3&gt;
&lt;p&gt;以 &lt;code&gt;library/nats:2.12.6-alpine&lt;/code&gt; 为例（图 14）。每条漏洞看四样：&lt;strong&gt;CVE 编号、严重级别、受影响组件、是否有修复版本&lt;/strong&gt;：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;CVE-2026-31789&lt;/code&gt;：危急（critical），组件 &lt;code&gt;libcrypto3&lt;/code&gt; / &lt;code&gt;libssl3&lt;/code&gt;（OpenSSL 运行时库），有修复版本；&lt;/li&gt;
&lt;li&gt;&lt;code&gt;CVE-2026-22184&lt;/code&gt;：严重（high），组件 &lt;code&gt;zlib&lt;/code&gt;，有修复版本。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-scan-result-nats.png&quot; alt=&quot;扫描结果示例&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 14：library/nats 2.12.6-alpine 的扫描结果：CVE-2026-31789（危急，libcrypto3/libssl3）、CVE-2026-22184（严重，zlib）等，均已显示修复版本&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;动作：有修复版本 → 把镜像升到含修复的版本；没有 → 评估可利用性（KEV：已知在野利用的漏洞优先级最高）并记录风险接受。要留审计痕迹就用项目页“导出 CVEs“（图 11）。&lt;/p&gt;
&lt;h2 id=&quot;6-ci-cd-lian-dong-docker-yaml-zen-me-yong-harbor&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#6-ci-cd-lian-dong-docker-yaml-zen-me-yong-harbor&quot; aria-label=&quot;Anchor link for: 6-ci-cd-lian-dong-docker-yaml-zen-me-yong-harbor&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
6 CI/CD 联动：docker.yaml 怎么用 Harbor&lt;/h2&gt;
&lt;p&gt;本节只讲 Harbor 为流水线提供的三样东西：账号、证书、动作。&lt;/p&gt;
&lt;h3 id=&quot;6-1-robot-zhang-hao-ci-zhuan-yong-zhang-hao&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#6-1-robot-zhang-hao-ci-zhuan-yong-zhang-hao&quot; aria-label=&quot;Anchor link for: 6-1-robot-zhang-hao-ci-zhuan-yong-zhang-hao&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
6.1 robot 账号：CI 专用账号&lt;/h3&gt;
&lt;p&gt;流水线推镜像用 robot 账号 &lt;code&gt;robot-dev-sec-ops+ci-runner&lt;/code&gt;：&lt;strong&gt;project 级&lt;/strong&gt;（只作用于 &lt;code&gt;dev-sec-ops&lt;/code&gt;）、&lt;strong&gt;repository pull+push&lt;/strong&gt;、&lt;strong&gt;长期有效&lt;/strong&gt;。密码创建时只显示一次，存进 Gitea 仓库 Secret 的 &lt;code&gt;MIRROR_USER&lt;/code&gt; / &lt;code&gt;MIRROR_TOKEN&lt;/code&gt;。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;API 创建时有两个要点：&lt;code&gt;kind&lt;/code&gt; 字段不能少；&lt;code&gt;duration: 0&lt;/code&gt; 不合法，长期有效要写 &lt;code&gt;-1&lt;/code&gt;。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-robot-ci-runner.png&quot; alt=&quot;Harbor robot 账号列表&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 15：&lt;code&gt;dev-sec-ops&lt;/code&gt; 项目 → Robot Accounts：&lt;code&gt;robot-dev-sec-ops+ci-runner&lt;/code&gt;（2 项权限、Never Expires）&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;6-2-ca-zhu-ru-xin-ren-nei-wang-zheng-shu-de-shuang-tong-dao&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#6-2-ca-zhu-ru-xin-ren-nei-wang-zheng-shu-de-shuang-tong-dao&quot; aria-label=&quot;Anchor link for: 6-2-ca-zhu-ru-xin-ren-nei-wang-zheng-shu-de-shuang-tong-dao&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
6.2 CA 注入：信任内网证书的双通道&lt;/h3&gt;
&lt;p&gt;任务容器默认不信任内网 CA，流水线在 “Verify Certificate” 步骤注入两处：&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; cp kali-team-ca.crt /usr/local/share/ca-certificates/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; update-ca-certificates&lt;/span&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;                                # 通道一：系统信任库（git/curl 等 HTTPS 用它）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; mkdir -p /etc/docker/certs.d/mirror.kali-team.internal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; cp kali-team-ca.crt /etc/docker/certs.d/mirror.kali-team.internal/ca.crt&lt;/span&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;   # 通道二：docker 客户端&amp;quot;按 registry&amp;quot;的 CA&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;6-3-deng-lu-tui-song-yan-zheng-san-ge-dong-zuo&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#6-3-deng-lu-tui-song-yan-zheng-san-ge-dong-zuo&quot; aria-label=&quot;Anchor link for: 6-3-deng-lu-tui-song-yan-zheng-san-ge-dong-zuo&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
6.3 登录 / 推送 / 验证：三个动作&lt;/h3&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      -&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; Login to Harbor Registry 登录Harbor Registry&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;        uses&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; https://hub.kali-team.internal/actions/login-action@v2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;        with&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;          registry&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; https://mirror.kali-team.internal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;          username&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; ${{ secrets.MIRROR_USER }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;          password&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; ${{ secrets.MIRROR_TOKEN }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;      # （中间为 checkout / QEMU / 缓存 / buildx 配置）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      -&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; Build and push Docker image for ${{ matrix.service }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;        uses&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; https://hub.kali-team.internal/actions/build-push-action@v6&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;        with&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;          context&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; .&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;          platforms&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; linux/amd64&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;          push&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;          target&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; ${{ matrix.service }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;          tags&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-7&quot;&gt;            mirror.kali-team.internal/dev-sec-ops/example-${{ matrix.service }}:${{ needs.setup.outputs.version }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-7&quot;&gt;            mirror.kali-team.internal/dev-sec-ops/example-${{ matrix.service }}:latest&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;          # （build-args 与 cache-from/to 参数见 Build and push 步骤）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      -&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; Inspect image&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;        run&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-7&quot;&gt;          docker buildx imagetools inspect mirror.kali-team.internal/dev-sec-ops/example-${{ matrix.service }}:${{ needs.setup.outputs.version }}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;login-action@v2&lt;/code&gt; 把 robot 凭据写进任务容器的 &lt;code&gt;~/.docker/config.json&lt;/code&gt;，后续 push 自动带上；&lt;/li&gt;
&lt;li&gt;&lt;code&gt;build-push-action@v6&lt;/code&gt; 构建并直接推入 Harbor，一次打两个 tag；产物落私有 project &lt;code&gt;dev-sec-ops&lt;/code&gt;（代理项目只读，推不进去）；&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docker buildx imagetools inspect&lt;/code&gt; 不拉镜像，只向 registry 要 manifest——能打印出来即证明镜像已在 Harbor，完成“推送成功“自检。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;顺带一提：QEMU 注册用的镜像也走代理（&lt;code&gt;mirror.kali-team.internal/docker.io/tonistiigi/binfmt:latest&lt;/code&gt;）——pull-through 在流水线里的实际用法。&lt;/p&gt;
&lt;h3 id=&quot;6-4-liu-shui-xian-tui-song-yan-zheng-run-6&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#6-4-liu-shui-xian-tui-song-yan-zheng-run-6&quot; aria-label=&quot;Anchor link for: 6-4-liu-shui-xian-tui-song-yan-zheng-run-6&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
6.4 流水线推送验证：run #6&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;docker.yaml&lt;/code&gt; 手动触发（&lt;code&gt;build_server=true&lt;/code&gt;、&lt;code&gt;version=1.0.0&lt;/code&gt;）：&lt;code&gt;setup&lt;/code&gt; job 5s 算出版本号，&lt;code&gt;build-and-push&lt;/code&gt; job 32s 走完全流程（总耗时 1m25s）。&lt;code&gt;dev-sec-ops&lt;/code&gt; 项目出现 &lt;code&gt;example-server&lt;/code&gt;——tags &lt;code&gt;1.0.0&lt;/code&gt; 与 &lt;code&gt;latest&lt;/code&gt; 指向同一 digest &lt;code&gt;sha256:4cd55…e3513&lt;/code&gt;（约 49.6 MiB）。&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.kali-team.cn/blog/2026/09/%E5%AE%89%E5%85%A8%E5%BC%80%E5%8F%91-Harbor/harbor-project-dev-sec-ops.png&quot; alt=&quot;Harbor dev-sec-ops 项目页&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;图 16：&lt;code&gt;dev-sec-ops&lt;/code&gt; 项目页（Repositories 视图）：&lt;code&gt;example-server&lt;/code&gt; / &lt;code&gt;gitea/gomod-cache&lt;/code&gt; / &lt;code&gt;gitea/runner-images&lt;/code&gt; 三个镜像仓库已入库&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;6-5-san-lei-quan-xian-yi-lan&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#6-5-san-lei-quan-xian-yi-lan&quot; aria-label=&quot;Anchor link for: 6-5-san-lei-quan-xian-yi-lan&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
6.5 三类权限一览&lt;/h3&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;身份&lt;/th&gt;&lt;th&gt;类型&lt;/th&gt;&lt;th&gt;作用范围&lt;/th&gt;&lt;th&gt;权限&lt;/th&gt;&lt;th&gt;谁在用&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Kali-Team&lt;/td&gt;&lt;td&gt;人（OIDC）&lt;/td&gt;&lt;td&gt;所属项目&lt;/td&gt;&lt;td&gt;Web + CLI（CLI 密码，4.4）&lt;/td&gt;&lt;td&gt;人用 &lt;code&gt;docker login/pull&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;dev-sec-ops 组&lt;/td&gt;&lt;td&gt;组&lt;/td&gt;&lt;td&gt;&lt;code&gt;docker.io&lt;/code&gt; 项目&lt;/td&gt;&lt;td&gt;访客（只读）&lt;/td&gt;&lt;td&gt;团队拉公开镜像&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;robot-dev-sec-ops+ci-runner&lt;/td&gt;&lt;td&gt;robot&lt;/td&gt;&lt;td&gt;&lt;code&gt;dev-sec-ops&lt;/code&gt; 项目&lt;/td&gt;&lt;td&gt;repository pull+push&lt;/td&gt;&lt;td&gt;CI 流水线推镜像&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2 id=&quot;7-chang-jian-wen-ti-yu-keng&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#7-chang-jian-wen-ti-yu-keng&quot; aria-label=&quot;Anchor link for: 7-chang-jian-wen-ti-yu-keng&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
7 常见问题与坑&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;上游镜像源不全：&lt;code&gt;docker/dind&lt;/code&gt;、&lt;code&gt;docker/buildx&lt;/code&gt;、&lt;code&gt;moby/buildkit&lt;/code&gt; 全部 404&lt;/strong&gt;（daocloud 是部分镜像源，经代理拉取 404 易误判为 Harbor 配置问题）。绕行方案：docker CLI 拷宿主二进制进任务镜像、buildx 用宿主 Go 源码编译烤入、buildx 选 docker 驱动——去掉对这三个公网镜像的依赖。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OIDC 登录 ≠ 能 &lt;code&gt;docker login&lt;/code&gt;&lt;/strong&gt;：OIDC 只服务 Web，CLI 只认“用户名 + 密码“或 robot；OIDC 用户没设 &lt;strong&gt;CLI 密码&lt;/strong&gt;时 &lt;code&gt;docker login&lt;/code&gt; 认证失败。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;externalURL&lt;/code&gt; 必须随域名一起改&lt;/strong&gt;：Harbor 用它生成回调 / 跳转地址，只改 &lt;code&gt;hosts.core&lt;/code&gt; 而 &lt;code&gt;externalURL&lt;/code&gt; 留默认 &lt;code&gt;core.harbor.domain&lt;/code&gt;，OIDC 授权会跳去不存在的域名。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Trivy 漏洞库没下载完成&lt;/strong&gt;（库体积大、下载源不稳）：扫描慢或失败时换镜像源；重要扫描建议搭建期先预热一遍。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;pull-through 项目推不进去&lt;/strong&gt;（设计约束，非故障）：代理项目内容由上游定义、只读；构建产物必须进普通私有项目（&lt;code&gt;dev-sec-ops&lt;/code&gt;）——这也是 robot 只授该项目 pull+push 的原因。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;初始 admin 密码的存放&lt;/strong&gt;：chart 写进 secret &lt;code&gt;mirror-harbor-core&lt;/code&gt;；首次登录后改密，按团队凭据规范存放。&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;8-xiao-jie&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#8-xiao-jie&quot; aria-label=&quot;Anchor link for: 8-xiao-jie&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
8 小结&lt;/h2&gt;
&lt;p&gt;Harbor（2.15.2）装进 k3s，接上 Gitea 单点登录，配好五个平台镜像代理，&lt;code&gt;docker.yaml&lt;/code&gt; 流水线用 robot 账号推镜像、&lt;code&gt;imagetools inspect&lt;/code&gt; 自检，Trivy 持续扫镜像漏洞：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;搭建&lt;/strong&gt;：diff 只动三组——ingress 域名、关 chart 自带 TLS、&lt;code&gt;externalURL&lt;/code&gt;；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OIDC&lt;/strong&gt;：Gitea 应用 + Harbor OIDC 设置，与其它平台共用统一登录；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;使用&lt;/strong&gt;：仓库管理登记上游、代理项目取回缓存、组授只读、CLI 密码走 CLI；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;扫描&lt;/strong&gt;：Trivy 内置，按需 / 自动触发，结果按“CVE / 级别 / 组件 / 修复版本“读；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CI/CD&lt;/strong&gt;：robot + CA 双通道 + 登录 / 推送 / 验证三动作，无人持有 admin 密码；&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;下一步可选：&lt;strong&gt;镜像签名&lt;/strong&gt;（cosign）、&lt;strong&gt;复制（replication）&lt;/strong&gt;（跨集群 / 备份仓库同步）、把扫描结果接进流水线质量门禁（命中危急漏洞即卡发版）。&lt;/p&gt;
&lt;h2 id=&quot;can-kao&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#can-kao&quot; aria-label=&quot;Anchor link for: can-kao&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
参考&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://goharbor.io/docs/&quot;&gt;Harbor 官方文档&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/goharbor/harbor-helm&quot;&gt;Harbor Helm chart（仓库地址 https://helm.goharbor.io/）&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/goharbor/harbor&quot;&gt;goharbor/harbor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://trivy.dev/&quot;&gt;Trivy 文档&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://docs.docker.com/build/buildx/reference/buildx_imagetools/&quot;&gt;Docker buildx imagetools&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
        <summary type="html">在内网 DevSecOps 体系里部署 Harbor（私有容器镜像仓库）：Rancher chart 搭建、Gitea OIDC 单点登录、五个平台镜像代理（pull-through 缓存），再用 robot 账号把 Gitea Actions 流水线的镜像推上去，让 Trivy 扫出镜像漏洞</summary>
        </entry>
</feed>
