Bring your own Red Hat Enterprise Linux to Azure

Bring your own Red Hat Enterprise Linux to Azure

In order to run Red Hat Enterprise Linux on Azure you need to choose whether you wish to pay for RHEL usage in your Azure consumption bill or if you want to use your existing RHEL subscription.

Using the Pay-As-You-Go method and paying via Azure bill is very straightforward but has some limitations.

This post shows you how to use your existing RHEL subscription on Azure. The tasks required are quite technical.

Currently Microsoft doesn't have empty RHEL Bring-Your-Own-License images on Azure, so you will need to create your own image and upload it into Azure.


RHEL VM creation

Create a new RHEL VM on your laptop using installation latest RHEL server ISO image. If you use Hyper-V, use "generation 1".

Amount of memory is up to you, keep in mind RHEL needs couple of gigabytes for standard installation.

Size of hard disk should be as small as possible as you will need to upload uncompressed VHD image to Azure. 8GB should be enough for standard packages.


RHEL OS installation:

  • Configure partitioning manually "[X] I will configure partitioning"
  • Choose "Standard partition" (not LVM since Azure can't handle LVM booting properly at this time)
  • Use the default "XFS filesystem"
  • You will need only "/boot" and "/" partitions. Remove swap, Azure tools will add it dynamically on runtime.
  • Do not encrypt the partitions. Encryption will need additional tasks not covered in this guide.
  • Add only the root password, no normal users needed
  • Configure networking to start automatically on boot


Make the VM compatible with Azure

Login to your RHEL VM as root, and register it into subscription-manager:

subscription-manager register
subscription-manager list --available
subscription-manager attach -pool=xxxxx  #(find a subscription with RHEL)
subscription-manager repos --disable=\*
subscription-manager repos?? --enable=rhel-7-server-extras-rpms
subscription-manager repos --enable=rhel-7-server-rpms

Update the system with "yum -y update".

Edit network configuration to disallow Network Manager to mangle with the main interface:

/etc/sysconfig/network:

NETWORKING=yes
HOSTNAME=localhost.localdomain

/etc/sysconfig/network-scripts/ifcfg-eth0:

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
IPV6INIT=no
NM_CONTROLLED=no

Turn of static udev rules for network devices, could break when cloning VMs:

ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules

Ensure networking is started on boot, and reboot and verify you still get an IP address. Much easier to fix at this point if you broke something: "systemctl enable network; reboot"

Modify some boot options. Note the two console= parameters to allow messages also on local console for debugging, remove other parameters if needed.

/etc/default/grub:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rootdelay=300 console=tty0 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0"
GRUB_DISABLE_RECOVERY="true"

Generate new grub files:

grub2-mkconfig -o /boot/grub2/grub.cfg

Ensure the Hyper-V drivers are included in the image:

/etc/dracut.conf:

add_drivers+=" hv_vmbus "
add_drivers+=" hv_netvsc "
add_drivers+=" hv_storvsc "

Write the image with: "dracut –f -v"

Install Azure Linux Agent:

yum -y install WALinuxAgent python
systemctl enable waagent
yum clean all

Configure /etc/waagent.conf:

ResourceDisk.Format=y
ResourceDisk.Filesystem=ext4
ResourceDisk.MountPoint=/mnt/resource
ResourceDisk.EnableSwap=y
ResourceDisk.SwapSizeMB=4096

Apply the Azure agent settings:

waagent -force -deprovision
export HISTSIZE=0
logout

Convert the image into VHD

On your virtualization manager stop the VM and convert the disk to .vhd + fixed size file rhel7.vhd. The exact procedure depends on your hypervisor technology.

This picture shows the conversion on Hyper-V running on Windows 10:


Upload image to Azure

Upload the rhel7.vhd to Azure as "page blob" via Azure cli or portal. This can be done via portal, CLI or Powershell.

This will take from awfully to horribly long time due to the huge 8GB size of the image file, depending on your upstream bandwidth.

az storage blob upload --account-name username --account-key key1 --type page --file rhel7.vhd --name rhel7.vhd --container-name container1

Create a managed disk, using Azure CLI 2.0 in this example:

az disk ??create --resource-group rg1 --name rhel7managed --source https://username.blob.core.windows.net/container1/rhel7.vhd

Verify its really there:

az disk list -g rg1 --output=table

Create your vm with 5GB (or more) additional data disk:

az vm create --resource-group rg1 --location westeurope --name rhel7 
 --os-type linux --attach-os-disk rhel7managed --size Standard_DS1 
 --data-disk-sizes-gb 5
At this point your RHEL 7 VM should be up and running on Azure. You can create multiple VM's using the same disk image.

Useful links

Sassan Hajrasooliha

Enjoying everything-Cloud at AWS

5 年

How will you be billed? for PAYG the licensing prices are included with the VM compute time; however I have a hard time figuring out the Compute price for BYOL Linux on Azure.

回复
Toni Willberg

Head of Professional Services at Iglu

6 年

Please note the VHD really needs to be fixed size. I tested couple of times with dynamically growing file, but you can't create a disk based on it. If someone knows a workaround let me know. Uploading the VHD to Azure seems to be faster with azcopy or by via web browser than by using "az" command.

回复
Khwaja Imran Mohammed

Technology & Engineering Leader | DevSecOps, DevOps, Cloud, Site Reliability Engineering & Information Security | Banking & Financial Services | CISM, CISA, CRISC, PMP | PhD Candidate

6 年
回复
Alexander Bezprozvanny

Clouds, IoT, IaaS, PaaS, OpenShift, Kubernetes, Ansible, Digitalization

6 年

Well, instructions for preparing and deploying a custom RHEL image in Azure were available on Red Hat's site at least since October 2017 and they were a bit more detailed. Anyway, spreading the knowledge is good and can help may newcomers.

回复

要查看或添加评论,请登录

社区洞察