ninesalt
ninesalt

Reputation: 4354

create instance template from private repo

I'm trying to create a GCP instance template which has the most recent version of my repo on it. My repository is private and I cant figure out how to clone it in the instance groups. I don't think I can use SSH because the machines will be randomly destroyed and created and therefore the generated keys will be inconsistent. Whats the best way to do this?

Upvotes: 0

Views: 108

Answers (1)

Amir Rahwane
Amir Rahwane

Reputation: 674

An Instance Template is based on an Image. This image can be a clean Ubuntu/Windows/Debian copy or a custom image created by you.

Saying that, I can think of 2 ways for you to get your repository inside there.

  1. Using a custom image. In essence, A snapshot of an instance with your latest code and dependencies installed on it. There are two paths you can go with here.

a. Create a custom image when you clone the repository to the instance. You might need to that for every update in the code.

b. An alternative is to use some sort of Network File System (NFS/SMB). This will usually require more resources like another server that is always available.

  1. If you want to avoid creating images, or as a solution to the issue mentioned in 1a you can set up a Startup Script to run on the server at boot(creation) time to clone/pull the latest copy.

There are Pros and Cons for both. I guess only you can tell what is best for you. I hope it gets you in the right direction.

Read more about creating an image here. Read more about startup scripts here.

Upvotes: 1

Related Questions