Build a RHEL Cloud Image for GCE

This is a brief tutorial on how you can create a Red Hat Enterprise Linux cloud image for Googles Compute Engine. These instructions are meant for a Linux hosts which runs KVM.

1. Download the GCE Tools google-cloud-sdk so you can create and upload the future image. You will need to have internet connection as the tool will comunicate with GCE’s api.

2. Untar the Google cloud SDK

[root@host191 ~]# tar -xzvf google-cloud-sdk-112.0.0-linux-x86_64.tar.gz
[root@host191 ~]# cd google-cloud-sdk/

3. Install the SDK. You will need to be able to communicate to the outside world here as well as visit a website

[root@host191 ~]#  ./install.sh

4. Once installed build your linux VM. Create a qcow2 disk. You will have to convert the disk later on to raw format.

[root@host191 ~]# qemu-img create -f qcow2 /var/lib/libvirt/images/gce.qcow2 10G

5. Follow:
building-images#os_security_best_practices
Google also supports meta data service so you can install cloud-init as well which you can find in the rhel-7-server-rh-common-rpms. Once your done you can shutdown your vm and convert it into raw. IMPORTANT, the name of your disk needs to be disk.raw .

6. Convert the image to raw. The image needs to be named disk.raw

[root@host191 ~]#  qemu-img convert -f qcow2 -O raw gce.qcow2 disk.raw

7. Tar it up.

[root@host191 ~]#  tar -Sczf gcerhel7.tar.gz disk.raw

8. If there is no data store create one. Rhelimages is my datastore name

[root@host191 ~]# ./gsutil mb gs://rhelimages/

9. Upload the tarball to the gce storage

[root@host191 ~]# ./gsutil cp /var/lib/libvirt/images/gcerhel7.tar.gz gs://rhelimages/

10. Create the compute image. Once done you will be able to create GCE compute instances from that image.

[root@host191 ~]#  ./gcloud compute images create rhel7-custom-amd64 --source-uri gs://rhelimages/gcerhel7.tar.gz

Leave a Reply

Your email address will not be published. Required fields are marked *

*


Hit Counter provided by laptop reviews