Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

CI/CD pipeline to update GCP image

how do i update a GCP image using a CI.CD pipeline?

currently this is what i do

1. I use packer to build and customize the vmdk on my mac laptop

2. upload the vmdk to cloud bucker with gsutil

3. import the image to library: 

gcloud compute images import rocky-linux9-custom-date-xxx \
--source-file=gs://xxxxxx/RockyLinux-disk001.vmdk

4. delete the old image

 

any idea?

3 1 219
1 REPLY 1

Hello @gcp888  ,Welcome on Google Cloud Community.

1a. Use Packer to build and customize image as you doing this now
OR
1b. Create Packer template 
2. Create Service Account for GH Actions
3. Add service account key to GH secrets
4. Push your changes to gh repo
5. Use GH and GH Actions ( I like GH Actions ) to store,  trigger upload and cleanup :

  • Checkout the repository.
  • Install Packer and Google Cloud SDK.
  • Build the VM image using Packer.
  • Upload the generated VMDK file to a Google Cloud Storage bucket.
  • Import the VMDK file as a new image in GCP.
  • Cleanup the VMDK files from the storage bucket.

6. Check your image.

PS: Of course, you need dedicated repo, GH Actions file, bucket, service account and key for that. However, if you ask any AI-like chat, it will provide for your relevant Gh Actions code.  

PS2: If you plan use this workflow on production, be sure that you are not using keys but WIF for GH Actions. WIF is more secured way to allows external applications doing things behalf on service account, resides on your infra. Keys are good for testing imho.

--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost