[英]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.