0

enter image description here

I use .gitlab-ci.yml file for auto deploying of my pet project to GCP, and I want to each time when I merge some new code , update my current code to new one from google cloud container registry . And the only way I see for now , it to delete old instance and create new one , you can see it in the list of my gitlab-ci file , but when I try to delete instance which for example don't exist , it send me error , that this instance don't exist ( and it is correct ) , but how can I do some checking of it ? For example , I check is there is some instance created , get response , if created - then I delete it , if it doesn't exist , then I skip step of deleting and create new instance !? Or maybe if you have better way do update my code on compute engine instance , pls let me know . I only want to find out how to work with it . Only study this process . If you need additional info , pls let me know !

John Hanley
  • 74,467
  • 6
  • 95
  • 159
Andrey Radkevich
  • 3,012
  • 5
  • 25
  • 57

1 Answers1

2

Ok, I've found solving . I don't need to delete it , I can update existing instance by using example of command:

gcloud compute instances update-container nginx-vm \
    --container-image gcr.io/cloud-marketplace/google/nginx1:latest
Andrey Radkevich
  • 3,012
  • 5
  • 25
  • 57
  • For added fun, you can set up a hook so that when you update your Gitlab repository, the container is rebuilt and the `update-container` command is run. https://about.gitlab.com/devops-tools/cloudbuild/ – John Hanley Oct 14 '19 at 03:29