使用 vSphere Docker Credential Helper CLI 将容器映像安全地推送到嵌入式 Harbor 注册表以及从嵌入式 Harbor 注册表中提取容器映像。

Kubernetes CLI 工具下载页面包含用于下载 vSphere Docker Credential Helper 的链接。可使用 vSphere Docker Credential Helper 将 Docker 客户端安全地连接到嵌入式 Harbor 注册表。

前提条件

  • 在主管集群上启用嵌入式 Harbor 注册表
  • 从 vSphere 管理员获取 适用于 vSphere 的 Kubernetes CLI 工具 下载页面的链接。
  • 或者,如果您有权访问 vCenter Server,请按如下所示获取链接:
    • 使用 vSphere Client 登录 vCenter Server
    • 导航到 vSphere 集群 > 命名空间,然后选择要操作的 vSphere 命名空间
    • 选择摘要选项卡,然后找到状态图标。
    • 选择链接到 CLI 工具标题下的打开以打开下载页面。或者,可以复制该链接。
  • 配置 Docker 客户端。请参见使用嵌入式 Harbor 注册表 证书配置 Docker 客户端

过程

  1. 使用浏览器,导航到适用于您环境的 Kubernetes CLI 工具下载 URL。
  2. 向下滚动到 vSphere Docker Credential Helper 部分。
  3. 选择操作系统。
  4. 下载 vsphere-docker-credential-helper.zip 文件。
  5. 将 ZIP 文件的内容提取到工作目录。
    docker-credential-vsphere 二进制可执行文件包含在内。
  6. docker-credential-vsphere 二进制文件复制到 Docker 客户端主机。
  7. 将二进制文件的位置添加到系统路径中。
    例如,在 Linux 上:
    mv docker-credential-vsphere /usr/local/bin/docker-credential-vsphere
  8. 通过在 shell 或终端会话中运行命令 docker-credential-vsphere,验证 vSphere Docker Credential Helper 的安装。
    将显示横幅消息和 CLI 的命令行选项列表。
    vSphere login manager is responsible for vSphere authentication. 
    It allows vSphere users to securely login and logout to access Harbor images.
    
    Usage:
      docker-credential-vsphere [command]
    
    Available Commands:
      help        Help about any command
      login       Login into specific harbor server and get authentication
      logout      Logout from Harbor server and erase user token
    
    Flags:
      -h, --help   help for docker-credential-vsphere
    
    Use "docker-credential-vsphere [command] --help" for more information about a command.
    
  9. 登录到嵌入式 Harbor 注册表。
    首先,查看用法:
    docker-credential-vsphere login -help
    Usage:
      docker-credential-vsphere login [harbor-registry] [flags]
    
    Flags:
      -h, --help               help for login
      -s, --service string     credential store service
          --tlscacert string   location to CA certificate (default "/etc/docker/certs.d/*.crt")
      -u, --user string        vSphere username and password
    
    然后,使用以下命令登录:
    docker-credential-vsphere login <container-registry-IP>
    将获取并保存身份验证令牌,并且您已登录。
    docker-credential-vsphere login 10.179.145.77
    Username: [email protected]
    Password: INFO[0017] Fetched username and password
    INFO[0017] Fetched auth token
    INFO[0017] Saved auth token
    
  10. 注销嵌入式 Harbor 注册表。
    docker-credential-vsphere logout 10.179.145.77

下一步做什么

将映像推送到嵌入式 Harbor 注册表.