Practice Exams:

Google Associate Cloud Engineer – Block and File Storage in Google Cloud Platform – GCP part 2

  1. Step 06 – Taking Snapshots for Persistent Disks

Welcome back. In this step, let’s talk about snapshots. What are snapshots? Snapshots are nothing but point in time backups of your persistent disks. You can also schedule snapshots. You can say I would want to create a snapshot every few hours. I can say, I would want to configure a backup every day. You can also auto delete snapshots after a few days. So as part of your scheduling, you can say I would want to take a snapshot every day. And snapshots which are older than ten days have to be immediately deleted. Snapshots can be multiregional and regional. Why do we create snapshots? Snapshots are backup of your persistent disks. And by having multiregional snapshots, you can get more durability for your backups. An interesting thing is that you can actually share your snapshots across projects.

You might be creating a snapshot in a specific project. You can also share it with other projects. Once you have a snapshot, you can also create new disks from it. And if this snapshot actually contains boot disk, then you can also launch a VM instance from the snapshot as well. Important thing to remember is that snapshots are incremental. Let’s say I’m taking a snapshot. If it’s the first snapshot, it contains all the data that is present on the persistent disk. However, if it’s a second snapshot, then it only contains the changes from the time the first snapshot was taken. So snapshots are incremental. However, important thing to remember is deleting a snapshot only deletes data which is not needed by other snapshots. So if you have ten snapshots and you don’t need three of them, then you can go ahead and delete them.

Because whenever you delete a snapshot, only data that is not needed by other snapshots is deleted whenever you’re taking backups. The backups need to be efficient. They should not contain unnecessary information and they should be well organized. And to ensure that, what we can do is to keep similar data together on a persistent disk. So it’s very, very important that you separate operating system, volatile data and permanent data. Your operating system runs on the boot disk on that disk. Don’t store any other data. If you want to store any data, then add persistent disk. And if the data is volatile data or temporary data, then you can actually create local SSD for storing the volatile data. If the data is permanent, then you can go for an additional persistent disk.

And if there are different categories of permanent data, then you can have multiple persistent disks for each of the categories of the data. So the recommendation is to attach multiple disks if needed. By having multiple disks, you can actually decide, okay, from this persistent disk, I would want to take snapshots, or from this persistent disk, I would want to create an image. So by having multiple disks, you can better organize your snapshots and images. So in summary, snapshots are nothing but point in time backups of your persistent disks. And there are a few important things that you need to remember about snapshots. Number one, avoid taking snapshots more often than once an hour. Why? Whenyou’re taking snapshots, the disk volumes are available. The persistent disks are available for use from the virtual machine.

However, snapshots can reduce performance. So the recommendation is to schedule snapshots during off peak hours. Another important thing to remember is creating snapshots from disk is faster than creating from images. However, creating disk from image is faster than creating disks from snapshots. So, if you are creating a new persistent disk, then creating it from an image is faster than creating it from a snapshot. Why? Because snapshots are incremental. There needs to be a little bit of calculation that needs to be done before a disk can be created. And that’s the reason why. My recommendation is that if you are repeatedly creating disks from a snapshot, so you have a snapshot, and you are repeatedly using the same snapshot to create disks in that kind of scenario, create an image from the snapshot.

So take the snapshot, create an image from the snapshot, and then you can use the image to create the disks. That would ensure that the creation of the disks is faster. So you’ll have a one time penalty when you are creating an image, but thereafter, creating this become simpler. We already talked about the fact that snapshots are incremental. But important thing to remember is that you don’t lose data by deleting older snapshots. Deleting a snapshot only deletes data which is not needed by other snapshots. So the recommendation, again, is do not hesitate to delete unnecessary snapshots. Don’t have too many snapshots present because they because snapshots consume storage space, and in the cloud, we pay for storage. So try and optimize the number of snapshots that you have.

  1. Step 07 – Playing with Persistent Disks and Snapshots in GCP

Back in the step. Let’s play with persistent disks. Let’s try and create a simple VM instance. So let’s go and say Create. I’ll choose the defaults for everything that is being recommended in here. As we discussed earlier, the place where we can add more disks is in Management, Security Disk Networking and Sold Tenancy. By default a persistent disk is automatically attached because that’s the boot disk. However, if you want more, you can actually go into over here and you can say I would want to attach more disks. I can go in here and say I want to add new disks and add different kinds of disks. For now, I don’t really want to add any extra disks. One disk is more than sufficient. Let’s go in and say Create. So this would create an instance for us. So this is creating an instance one. Let’s wait for the instance to be up and running.

It took a few seconds and the instance NAV has a green mark against it. It says that the instance is running and once the instance is up and running you can click on the instance and scroll down a little. And this is where you can see the persistent disk which is attached with this specific instance. You can see that a boot disk is attached and the name of it is this. You can see the image, you can see the size and you can see the type, the default type which is used as the boot disk is balanced persistent disk. And you can see that the encryption is managed by Google. You can click this instance one and it will take you to the persistent disk which is attached with the virtual machine. You can see all the properties related to that. You can see the estimated performance in here and you can also see the monitoring details around it.

So if you go to the monitoring you can see high level metrics around that specific disk. I’ve just created the disk so there is not a lot of monitoring information available. Another way to reach the same disk is by clicking Disks under Storage go and click Disks and this would list the disks which are present right now. What would happen if I go and terminate the VM instance? What would happen by default is that this persistent disk also will be deleted. Now, what if I don’t really want to delete this persistent disk when a VM instance is deleted? When creating an instance we can set an option. What is the option that we can set? You can go into manage security disks, networking and sol. Tenancy. And over here in Disks you can see an option here which says delete boot disk when an instance is deleted.

If you uncheck this, what would happen is the boot disk will not be deleted even when a VM instance is deleted. Now I can go back and actually on the existing VM instances also you can modify that flag. So I can go into instance one and I can say edit and I can go in. And this is where you can say when deleting instance keep disk. So for existing instances also you can keep the disk if you do want. So even when the VM instance is deleted, boot disk will not be deleted. Similar to that, if you have any additional disks which are attached, you can configure if you want to delete them or not. When a VM instance is deleted, I’m back to disks. And over here I can actually create a snapshot for the disk. So I can say go ahead and say I would want to create a snapshot.

So this would allow me to take a backup of that specific disk as it is right now. So I can say create snapshot and create a snapshot for it. So snapshot one, the source disk is automatically selected. You can choose whether you want a multiregional or a regional snapshot. If you choose a multiregional snapshot, you can see that you can see that the options which are available are US, Asia or EU. So in US in multiple regions, this snapshot would be stored, or in Asia in multiple regions or in European Union in multiple regions. You can also see that the snapshot would be encrypted using the same settings as the disk. So the snapshot will be encrypted using disk encryption settings. And you can go in over here and say I want to create a snapshot. So this would trigger the creation of a backup of your disk.

You can create multiple snapshot from your disk and these snapshots would be incremental. So I have snapshot one right now. This would by default have all the information that is needed to create the disk. If I create a snapshot two, then the snapshot two would only contain the differences between snapshot one and snapshot two. Now you can see that the snapshot is up and running and I can go in and I can now use this snapshot. I can actually click this and I can go ahead and say create instance from this snapshot. So I can use this snapshot to either create a VM instance because it contains the boot disk, I can use it to create a VM instance. You can go back to disks and over here you can say Create disk and you can say the source. You can go in and select a source as well.

So you can say I would want to create a disk from snapshot and I can select the snapshot in here. So I would want to create a disk from the snapshot. So from the snapshot you can either create a VM instance if it’s a boot disk, or you can also create a disk. That’s what we are looking at right now. If I go back to the snapshots, in addition to creating snapshots manually, you can also schedule snapshots so you can go in here and say I would want to schedule a snapshot and I can say create snapshot schedule. So the first thing that we’ll do is create the schedule of a snapshot. The schedule of a snapshot is not really linked to a disk. It’s a general schedule.

So a schedule is something like I would want to do this every few days or every 24 hours or every 5 hours. So that’s what we are creating. We are just creating a schedule right now. So schedule I’ll just call this schedule one. I’ll take the default. I’ll say the region is your central one. I’ll take the default which it’s suggesting. So the frequency which is being suggested is daily. You can also create hourly, daily and weekly snapshots. And over here it’s suggesting a time. Choose a time when there will be very very less load on your virtual machine so that the impact of snapshot on performance is less. This is very, very important option that you can see in here. This is auto delete snapshots after 14 days. Taking snapshots is good because you’ll have backups from multiple time points.

However, having too many snapshots is not really good because they consume storage. And that’s where you can actually auto delete snapshots. And you can configure over here auto delete snapshots after how many days? A lot of times in certification exams you’d see a question saying I want to auto delete a snapshot every these many days. How can I do that? The easiest way is to actually include that as part of your snapshot schedule. You can also configure this deletion rule which is if the disk is deleted, what should happen? Do you want to keep the snapshots or do you want to delete snapshots older than 14 days? I’ll go ahead and say create a schedule. We have created a schedule. However, the schedule is not really attached with a disk. How do you attach a schedule with a disk? The way you can attach a snapshot schedule with a disk is by going to the disk.

So I’m going to select the disk and say edit. So you are editing the disk and this is where you can attach a snapshot schedule. So you can go in here and say I would want to use this schedule. One which we created earlier would happen. Now the snapshot would be taken off the disk based on the schedule that we have created in here. In this step, we played around with a lot of things around persistent disks. We created a VM instance and it automatically created a boot disk, which is a persistent disk. We took a snapshot from it, we played with the snapshot and we also saw how we can create a snapshot schedule and how we can attach a snapshot schedule with a persistent disk. I’m sure you’re having an interesting time and I’ll see you on the next.

  1. Step 08 – Playing with Machine Images

In this step. Let’s play with machine images. In the previous steps we looked at images, but what are machine images? How are they different from images? That’s what we will be learning in this specific step. Machine image is very different from that of an image. An image contains an operating system and that is what is used to boot up your virtual machine. However, a machine image is is much more than an image. You can have a boot disk and multiple persistent disks that can be attached with a VM one boot disk. That is where your OS runs from and you can have multiple data disks. An image is created from the boot persistent disk. This is a persistent disk where your operating system is loaded from. However, important thing to remember is that a machine image is created from a VM instance. A machine image contains everything you would need to create a VM instance.

It would contain the configuration of the VM instance, it would contain the metadata, it would contain the metadata that is assigned to the VM instance, the permissions that are present with the VM instance and also the data from one or more disks. So it contains your boot disk, it contains data from other attached persistent disk, it contains configuration metadata and permissions as well. So, a machine image contains everything you need to create a VM instance, whereas an image only contains the boot persistent disk. The persistent disk which contains the operating system if you are planning to do disk backups, instance cloning or replication if you want to be able to clone a complete VM instance as ease or if you want to replicate the same instance in a different zone, in those kind of situations you can go for machine images.

Let’s see how to create a machine image. We have just launched up a VM instance in the previous step so we can actually use that to launch up a machine image. Over here we just have one persistent disk which is attached with this specific machine instance. However, even if you have multiple persistent disks attached with the instance, the way you create a machine image is the same. So you can click in here and say new machine image. So this would create a new machine image for us. So, new machine image and I’ll call this my first machine image. You can configure the source VM instance. You can configure whether it should be multiregional or regional and then you can also configure how you want it to be encrypted.

I’ll choose the default ones there and I would go ahead and say create. So this would create a machine image for us. Once we have a machine image, you can create an instance from the machine image. If the machine image contains four persistent disks, the instance you would create also will have four different persistent disks. In addition, the machine image also will have the configuration of your virtual machine and the permissions that are assigned to your virtual machine. In this step, we looked at machine images and we talked about how they are different from an image. I’m sure you’re having an interesting time and I’ll see you on the next step.

  1. Step 09 – Comparing Snapshots vs Images vs Machine Images

Come back in previous steps. We talked about machine image, we talked about snapshots, we talked about custom image and we also talked about instance templates in previous section on Compute engine. Now, what are the differences and what are the use cases when you would go for each one of these? If you want a single disk backup, a machine image can be used because it also contains the backups of your persistent disk. You can go go for position disk snapshot and you can go for custom image. All these would contain a backup of a single disk. However, instance template only contains the configuration of the instance. It does not contain any data from the instance. So you cannot use instance template as a disk backup.

The next thing is multiple disk backup. Machine image is the only multiple disk backup in here. If I have a VM with multiple disks attached with it and I would want to back it up, the only option I have is machine image. Persistent disk snapshot is for a single disk. The same is with the image. Image can only contain the boot disk backup. The instance template does not have any backup of data at all. The next thing is differential backup. What is the differential backup? Let’s say I take the first version of the backup and after that I take the second version of the backup. The differential backup is yes if the second backup only contains the changes after the first backup, the differential backup is false or no if the second backup contains all the information if it is an exact copy of the disk. As you can see in here, machine images and snapshots are both differential backups.

They only contain the changes from the last time a snapshot or a machine image is taken. However, a custom image is not a differential backup. Every time you create an image, it contains all the data that is present on the persistent disk. Instance template is also not a differential backup. It contains all the configuration that is needed to launch up an instance. The next important difference is can we use them? For instance cloning and replication. You can use Machine Image. You can use custom Image if your image does have you can use custom Image if the image does not have any hard disk attached with it and you can also use an instance template. However, you cannot use a snapshot for instance cloning and replication. The last one is VM instance configuration. The machine image and the instance template contain the configuration of the VM instance.

For example, if I’m opening up an instance template that we created earlier I’m inside the my first project and we created a number of instance templates earlier, I’m opening up one of them and you can see that it contains configuration. What is the machine type? What is the reservation? What is the display device? What are the labels? What are the firewalls? All this is machine configuration. Both your machine image and instance template contain your instance configuration. However, snapshots and custom images don’t contain any VM instance configuration. They only contain backups of what data is present on the disk. The idea behind this step is to quickly compare all the backup options that we have talked about until now. Machine images, images, snapshot and instance templates I’m sure you’re having a wonderful time and I’ll see you in the next.