{"id":1421,"date":"2016-06-17T09:53:22","date_gmt":"2016-06-17T13:53:22","guid":{"rendered":"http:\/\/blog.domb.net\/?p=1421"},"modified":"2016-06-20T10:39:08","modified_gmt":"2016-06-20T14:39:08","slug":"build-a-rhel-cloud-image-for-gce","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=1421","title":{"rendered":"Build a RHEL Cloud Image for GCE"},"content":{"rendered":"<p>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. <\/p>\n<p>1. Download the GCE Tools <a href=\"https:\/\/dl.google.com\/dl\/cloudsdk\/channels\/rapid\/downloads\/google-cloud-sdk-112.0.0-linux-x86_64.tar.gz\">google-cloud-sdk<\/a> so you can create and upload the future image. You will need to have internet connection as the tool will comunicate with GCE&#8217;s api. <\/p>\n<p>2. Untar the Google cloud SDK<br \/>\n<code><br \/>\n[root@host191 ~]# tar -xzvf google-cloud-sdk-112.0.0-linux-x86_64.tar.gz<br \/>\n[root@host191 ~]# cd google-cloud-sdk\/<br \/>\n<\/code><\/p>\n<p>3. Install the SDK. You will need to be able to communicate to the outside world here as well as visit a website<br \/>\n<code><br \/>\n[root@host191 ~]#  .\/install.sh<br \/>\n<\/code><\/p>\n<p>4. Once installed build your linux VM. Create a qcow2 disk. You will have to convert the disk later on to raw format.<br \/>\n<code><br \/>\n[root@host191 ~]# qemu-img create -f qcow2 \/var\/lib\/libvirt\/images\/gce.qcow2 10G<br \/>\n<\/code><\/p>\n<p>5. Follow:<br \/>\n<a href=\"https:\/\/cloud.google.com\/compute\/docs\/tutorials\/building-images#os_security_best_practices\" target=\"_blank\">building-images#os_security_best_practices<\/a><br \/>\nGoogle 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 <strong>disk.raw<\/strong> .<\/p>\n<p>6. Convert the image to raw. The image needs to be named disk.raw<br \/>\n<code><br \/>\n[root@host191 ~]#  qemu-img convert -f qcow2 -O raw gce.qcow2 disk.raw<br \/>\n<\/code><\/p>\n<p>7. Tar it up.<br \/>\n<code><br \/>\n[root@host191 ~]#  tar -Sczf gcerhel7.tar.gz disk.raw<br \/>\n<\/code><\/p>\n<p>8. If there is no data store create one. Rhelimages is my datastore name<br \/>\n<code><br \/>\n[root@host191 ~]# .\/gsutil mb gs:\/\/rhelimages\/<br \/>\n<\/code><\/p>\n<p>9. Upload the tarball to the gce storage<br \/>\n<code><br \/>\n[root@host191 ~]# .\/gsutil cp \/var\/lib\/libvirt\/images\/gcerhel7.tar.gz gs:\/\/rhelimages\/<br \/>\n<\/code><\/p>\n<p>10. Create the compute image. Once done you will be able to create GCE compute instances from that image.<br \/>\n<code><br \/>\n[root@host191 ~]#  .\/gcloud compute images create rhel7-custom-amd64 --source-uri gs:\/\/rhelimages\/gcerhel7.tar.gz<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[37,3],"tags":[29,65,66],"class_list":["post-1421","post","type-post","status-publish","format-standard","hentry","category-cloudforms","category-linux","tag-cloudforms","tag-gce","tag-rhel"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1421"}],"version-history":[{"count":6,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1421\/revisions"}],"predecessor-version":[{"id":1436,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1421\/revisions\/1436"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}