Jump to Content
Compute

Compute Engine explained: Scheduling the OS patch management service

January 12, 2021
Dmitry Sadakov

Software Engineer

Last year, we introduced the OS patch management service to protect your running Compute Engine VMs against defects and vulnerabilities. The service makes patching Linux and Windows VMs with the latest OS upgrades simple, scalable and effective. In this blog, we share a step-by-step guide on how to set up a project with a schedule to automatically patch filtered VM instances, resolve issues if an agent is not detected, and view an overview of patch compliance across your VM fleet.

Getting started

Imagine an example project with several VM instances hosting a mythical web service. You want to automatically keep the instances updated with the latest critical fixes and security updates against malicious software. You have a production fleet and a development fleet of machines for which you want to apply updates using different schedules. 

First, enable the service by navigating to GCE > OS Patch Management in the Google Cloud Console. Alternatively, you can also enable Cloud OS Config API and Container Analysis API through the Google Cloud Marketplace, or gcloud:

Loading...

Note that the OS Config agent is most likely already installed on the VM instances and just needs to be enabled via project metadata keys:

Loading...

After the agent collects data across the VM fleet, this data is then displayed on the patch compliance dashboard, which shows the state across all your VMs and operating systems, and displays a bird eye’s view of your patch compliance:

https://storage.googleapis.com/gweb-cloudblog-publish/images/1_OS_patch_management_uKpdY6Y.max-1100x1100.jpg

You can now see some VM instances that you might like to patch more frequently, for example the CentOS and Red Hat Enterprise Linux (RHEL) fleet. 

Creating a patch deployment

You can then click the New Patch Deployment at the top of the screen and walk through the steps to create a patch deployment for the target VMs, each with specific patch configurations and scheduling options.

In the Target VMs section, you can use VM Instance name prefixes and labels to target only the VM instances with labels that start with a certain prefix. More instance filtering options are available, including zonal and combinations of label groups.

https://storage.googleapis.com/gweb-cloudblog-publish/images/2_Target_VMs.max-800x800.jpg

In the Patch config option, you can select to patch RHEL, CentOS and Windows with critical and security patches, or specify exact Microsoft Knowledge Base (KB) numbers and packages to install. You can also exclude specific packages from being installed in the ‘Exclude’ fields.

https://storage.googleapis.com/gweb-cloudblog-publish/images/3_Patch_config.max-400x400.jpg

Finally, you can schedule the patch job. For example, here’s how to run the job every second Tuesday of the month for a maximum duration (three-hour maintenance window), from 11 AM to 2PM:

https://storage.googleapis.com/gweb-cloudblog-publish/images/4_scheduling.max-800x800.jpg

After the patch job runs, you can see the result of the installed patches. This information is reported on the compliance dashboard and the VM instances tab:

https://storage.googleapis.com/gweb-cloudblog-publish/images/5_compliance_dashboard.max-1200x1200.jpg
https://storage.googleapis.com/gweb-cloudblog-publish/images/6_OS_patch_management.max-600x600.jpg

Patch your Compute Engine VMs today

To learn more about the OS patch management service on Compute Engine including automating patch deployment, visit our documentation page.

Posted in