Incase anyone not familiar with Google Compute Engine, it is the Infrastructure as a Service (IaaS) capability available on Google Cloud Platform. Google now supports Windows Server images, unfortunately only Windows Server 2008 R2 DataCenter edition SP1 is available at the time of writing this article.
Bit of a background for this. I’m testing deploying SharePoint on Google Compute Engine and I needed a base image that has all the required software in it. Additionally there are some steps you have to perform in GCE if you want to be able to assign static IP addresses for your virtual machine. I did not want to keep doing the same thing each time I create a virtual machine in GCE. So this article basically covers how I built a base windows image that contains SharePoint + the configurations required so the virtual machine can have a static IP address assigned. You can follow the same methods to create base windows images that contains software and configuration that your application needs.
First thing create a new virtual machine using the windows server image that is currently available.
gcloud compute --project "ce-playground" instances create "sp-base-image" --zone "us-central1-a" --machine-type "n1-standard-2" --network "sp-farm-net" --metadata "gce-initial-windows-user=rprakashg" "gce-initial-windows-password=P@ssw0rd" --maintenance-policy "MIGRATE" --scopes "https://www.googleapis.com/auth/devstorage.read_only" "https://www.googleapis.com/auth/logging.write" --image "https://www.googleapis.com/compute/v1/projects/windows-cloud/global/images/windows-server-2008-r2-dc-v20150110" --boot-disk-type "pd-standard" --boot-disk-device-name "sp-base-image" --can-ip-forward
if you look at the above command for machine type I used n1-standard-2 and for boot disk I used pd-standard, you have the option to use SSD here if you like. Also –can-ip-forward is used to enable IP routing for virtual machines. Compute Engine does not support assigning static network IP address for virtual machines. you can use a combination of routes and instances –can-ip-forward ability to work around this.
Download the RDP file for the newly created virtual machine and remote into the virtual machine and perform steps below. This is required since we want to assign static network IP address. Reason why we care about this is that the internal network IP addresses are managed by compute engine and can change when you start/stop instances.
Enable Windows Loopback Adapter
Windows Loopback adapter will allow assigning of static IP address to a virtual machine. Follow steps below to enable loopback adapter.
- Type Device Manager in Start menu
- From the device manager right click on the virtual machine name and select add legacy hardware
- Click Next on the welcome screen.
- Select Install the hardware that I manually select from a list and click Next.
- Select Network Adapter from the list
- Select Microsoft from the manufactures list and Microsoft Loopback Adapter from the network adapters list and click next
Add Windows firewall rule that allows ICMP traffic
To support pinging we will add a firewall rule to allow ICMP traffic
- type Windows Firewall with Advanced Security in start menu
- Right click on Inbound Rules and select New Rule
- Select Custom for rule type and click next
- Keep default settings for Program and click next
- From the Protocol Type dropdown select ICMPV4 and click next
- Keep default settings for Scope, Action, Profile
- Provide a Name and Description for rule and click finish (For the purpose of this post I used ICMP)
Enable IP Forwarding
- Run regedit
- Switch to HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > services > Tcpip > Parameters.
- Set value for IPEnableRouter property to 1 (This enables IP routing for the instance)
- Click OK
Next we will set the windows update settings to “download updates but let me chose whether to install them” (By default its set to automatic download and install, we don’t want that as we want to control what updates get installed on virtual machine). Next we will install Microsoft update to get updates for other products such as Office, SharePoint etc. Apply outstanding updates to keep the virtual machine up to date on patches.
Install SharePoint on the Virtual Machine
Next we are going to install SharePoint with all the Pre-Requisites on the virtual machine. This image is going to be a base image for SharePoint 2013 with Service Pack 1. I’ve downloaded this from my MSDN subscription. Depending on your scenario you might choose to use a different version of SharePoint.
Double click on default application, this will bring up a splash screen. Click on Install Software prerequisites
This will bring up the prerequisite installer tool. Click Next, Accept the terms of agreement and install all prerequisites.
prerequisites installer tool will reboot once during the install, after the reboot installer will automatically continue and complete. Once the prerequisites are successfully installed, we can go ahead and install SharePoint Server by clicking on the Install SharePoint Server link in splash screen. (note: due to the reboot during install of prerequisites we need to fire up the splash screen again)
Since I’m using SharePoint 2013 with SP1 downloaded from MSDN a valid product key must be entered before I can continue with SharePoint Server install. You can also use evaluation version of SharePoint Server bits as you probably don’t want to use a licensed version in the image. Since this image is going to be a private used strictly by me I can safely use my MSDN product key. If you are going to share the image with others you are going to want to use evaluation version instead of giving away your key.
For Server Type keep Complete selected and click on install now
After installation is complete uncheck Run the SharePoint Products Configuration Wizard now. Since we are building a base image we don’t want to do this.
I also ran a PowerShell script that does couple of things
- Turn off unneeded services
- Apply disable loopback check fix
- Turn off CRL check
Created a folder named Scripts under C drive and copied some additional PowerShell scripts that automates configuration of SharePoint. Once the Virtual Machine comes up you can simply run the scripts.
At this point we are ready to turn this virtual machine into a base image.
Run command prompt elevated, type gcesysprep and hit enter. (note: Don’t run the standard sysprep utility that we use to sysprep windows images). Gcesysprep utility will terminate the virtual machine instance, we can simply delete the virtual machine without deleting the persistent disk by running following command
gcloud compute instances delete sp2013-image --keep-disks boot
Next we need to create a snapshot out of the root persistent disk. Snapshot allows us to create new persistent disk with the data from the snapshot, additionally you can restore to larger size than what was originally used or even a different type of disk that was originally used. Run following command to create the snapshot of our sp2013-image disk that was syspreped using the gcesysprep utility.
gcloud compute disks snapshot "sp2013-image" --project "ce-playground" --snapshot-names "sp2013-with-sp1-win2008r2sp1"
The above command will return a URI for the snapshot, you’ll want to write this down. Next thing we’ll need to do is create a new persistent disk using the snapshot that we created earlier.
gcloud compute disks create "sp2013withsp1onwin2k8r2sp1" --source-snapshot "https://www.googleapis.com/compute/v1/projects/ce-playground/global/snapshots/sp2013-with-sp1-win2008r2sp1" --project "ce-playground" --zone "us-central1-a"
Next we will create an image using the new persistent disk that was created in previous step
gcloud compute images create "sharepoint-server-2013-sp1" --source-disk "sp2013withsp1onwin2k8r2sp1" --source-disk-zone "us-central1-a" --project "ce-playground"
You can see from the screenshot below that my custom image is now available for me and I can create new virtual machines using this image.
You can run following command to see all the metadata associated with your custom image
gcloud compute images describe "sharepoint-server-2013-sp1" --project "ce-playground"
At this point we can create new virtual machines using this image. Once the virtual machine is created you can simply RDP into the virtual machine and run the PowerShell script to Create a new SharePoint Farm or join to an existing SharePoint Farm. This significantly cuts down the time required to get infrastructure up and running in Google Cloud Platform to run SharePoint workload. I plan to do some performance testing. My goal is to compare how Google Compute Engine stack up against Azure IaaS specifically when it comes to running large workloads like SharePoint in the cloud.