简体   繁体   English

将 Packer VM 映像保存到 GCP Artifact Registry 的路径和选项

[英]Path and options for saving a Packer VM image to GCP Artifact Registry

(Warning, Newbie here) I'm learning Packer by building a VM. (警告,这里是新手)我正在通过构建虚拟机来学习 Packer。 I followed links to cloud-builders-community/packer example.我点击了指向 cloud-builders-community/packer example 的链接。 Unfortunately this seems to be out of date.不幸的是,这似乎已经过时了。 It pushes the output to gcr.io … which I'm discovering is being deprecated in favour of Artifact Registry.它将 output 推送到 gcr.io ……我发现它已被弃用,取而代之的是 Artifact Registry。 It's also using YAML instead of HCL2.它还使用 YAML 而不是 HCL2。

Is this old code and is there an up to date equivalent somewhere else?这是旧代码吗?其他地方是否有最新的等效代码?

Assuming I can or should continue using this sample code… I'm confused about a couple things.假设我可以或应该继续使用这个示例代码……我对一些事情感到困惑。 Artifact Registry: Create Repository has options for Docker, Maven, etc. but does not have an option for VM images. Artifact Registry:Create Repository 有 Docker、Maven 等选项,但没有 VM 映像的选项。 Do I just choose Docker?我只选择 Docker 吗?

Then in cloud-builders-community/packer/cloudbuild.yaml what path do I use to replace gcr.io?那么在cloud-builders-community/packer/cloudbuild.yaml我用什么路径替换gcr.io呢? gcr.io appears multiple times. gcr.io 出现多次。

From: https://github.com/GoogleCloudPlatform/cloud-builders-community/packer/cloudbuild.yaml来自: https://github.com/GoogleCloudPlatform/cloud-builders-community/packer/cloudbuild.yaml

steps:
  - name: 'gcr.io/cloud-builders/wget'
    args: ["https://releases.hashicorp.com/packer/${_PACKER_VERSION}/packer_${_PACKER_VERSION}_linux_amd64.zip"]
  - name: 'gcr.io/cloud-builders/docker'
    args: ['build', '-t', 'gcr.io/$PROJECT_ID/packer:${_PACKER_VERSION}',
           '-t', 'gcr.io/$PROJECT_ID/packer',
           '--build-arg', 'PACKER_VERSION=${_PACKER_VERSION}',
           '--build-arg', 'PACKER_VERSION_SHA256SUM=${_PACKER_VERSION_SHA256SUM}',
           '.']
substitutions:
  _PACKER_VERSION: 1.7.8
  _PACKER_VERSION_SHA256SUM: 8a94b84542d21b8785847f4cccc8a6da4c7be5e16d4b1a2d0a5f7ec5532faec0

images:
  - 'gcr.io/$PROJECT_ID/packer:latest'
  - 'gcr.io/$PROJECT_ID/packer:${_PACKER_VERSION}'
tags: ['cloud-builders-community']

BTW, the overall arc of my learning project is:顺便说一句,我的学习项目的总体思路是:

Packer => VM Image => GCP Artifact Repository => Terraform => GCP VM Packer => VM Image => GCP Artifact Repository => Terraform => GCP VM

I don't know specifics about packer, but in general, for using AR with docs that specify gcr.io:我不知道有关加壳器的细节,但总的来说,对于将 AR 与指定 gcr.io 的文档一起使用:

  • Anytime you want to use AR as a replacement for GCR, you should choose docker.任何时候你想用AR代替GCR,你应该选择docker。

  • You should replace gcr.io/$PROJECT_ID with $REGION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_ID for anywhere it refers to your project, and leave the gcr.io url as-is for other people's projects (like cloud-builders).您应该将 gcr.io/$PROJECT_ID 替换为 $REGION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_ID 用于它引用您项目的任何地方,并保留 gcr.io url 用于其他人的项目(如云 -建设者)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从打包程序实例导入时,GCP yum 工件注册表 403 - GCP yum artifact registry 403 when imported from packer instance GCP:如何修剪/维护工件注册表存储? - GCP: How to prune/maintain Artifact Registry storage? 如何从工件注册表(GCP)下载 jar? - How to download jar from artifact registry (GCP)? 如何在 k8s deployment.yaml 中从 GCP Artifact Registry 中拉取图像? - How pull image from GCP Artifact Registry in k8s deployment.yaml? Twine GCP 工件注册表 - HTTPError:413 请求实体太大 - Twine GCP Artifact registry - HTTPError: 413 Request Entity Too Large 如何自动从 Artifact Registry 中删除图像 - How to remove an image from Artifact Registry automatically 如何在 gcp vm 中部署 docker 镜像 - how to deploy docker image in gcp vm 命令删除工件注册表的所有图像版本,除了最新的? - Command To Delete All Image Versions of Artifact Registry Except Latest? 有什么方法可以将 GCP 工件注册表中的工件显示为 Jenkins 构建参数 - Is there any way to show artifacts from GCP Artifact Registry as Jenkins build parameter 我应该在生产和测试等不同阶段之间共享 GCP Artifact Registry 实例吗? - Should I share GCP Artifact Registry instances between different stages like production and test?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM