{"id":1478,"date":"2015-07-17T14:34:11","date_gmt":"2015-07-17T18:34:11","guid":{"rendered":"https:\/\/lowtek.ca\/roo\/?p=1478"},"modified":"2023-11-24T17:04:45","modified_gmt":"2023-11-24T21:04:45","slug":"bluemix-vms","status":"publish","type":"post","link":"https:\/\/lowtek.ca\/roo\/2015\/bluemix-vms\/","title":{"rendered":"Bluemix Virtual Machines"},"content":{"rendered":"<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/bluemix-vm-header.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1479\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/bluemix-vm-header.png\" alt=\"bluemix-vm-header\" width=\"500\" height=\"134\" \/><\/a><\/p>\n<p>The Bluemix platform is expanding from being a simple Cloud Foundry (CF) based PaaS, to one with a range of runtime platforms. Today you can pick one of: app, container or virtual machine (VM). I like to think of this as a continuum, sometimes you want the simplicity of an application &#8211; or the control of a virtual machine. The decision is really based on a number of factors, but as you gain more control over the environment you also take on more responsibility for securing and maintaining the environment.<\/p>\n<p>If you don&#8217;t\u00a0have a <a href=\"https:\/\/web.archive.org\/web\/20150605075041\/https:\/\/console.ng.bluemix.net\/\">Bluemix<\/a>\u00a0account, then you&#8217;ll need one (there is a free 30 day trial).<\/p>\n<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/vmtile.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-1480\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/vmtile.png\" alt=\"vmtile\" width=\"224\" height=\"125\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/vmtile.png 520w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/vmtile-500x279.png 500w\" sizes=\"auto, (max-width: 224px) 85vw, 224px\" \/><\/a><\/p>\n<p>From your bluemix dashboard you should see the Virtual Machine (beta) button. Click on the Run Virtual Machines tile.<\/p>\n<p>This in turn will take you to a sign up page which will allow you to submit a request to be enabled for VM access. Within a few minutes you should receive an email thanking you for your interest in virtual machines on Bluemix.<\/p>\n<p>Now you must be patient while the elves that run the service get things ready and then send you another email indicating <em>&#8220;You are now ready to start creating virtual machines on Bluemix!&#8221;<\/em> &#8212; once you get this you&#8217;ll be ready to go. \u00a0It&#8217;s probably worth emphasizing the point that this is a service in <em>BETA<\/em>, so getting access might take some time, patience is a virtue.<\/p>\n<p>Now let&#8217;s look at what it takes to create a VM on Bluemix. Login to Bluemix and click on the Run Virtual Machines tile (same path we took to sign up for access to the service). You should arrive at this screen<\/p>\n<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/createvm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1484 size-medium\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/createvm-500x250.png\" alt=\"createvm\" width=\"500\" height=\"250\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/createvm-500x250.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/createvm.png 1024w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>As this will be your first time, you&#8217;ll need to add a security key. This screen capture shows my key named &#8220;BluemixVM&#8221;. \u00a0To add a key, click on the +Add Key which appears under the Security Key box. You can choose to import or create a key. The easy path is to create a key &#8211; which will trigger the download of a key in your browser. I used BluemixVM as the key name and the file that was downloaded was BluemixVM.pem.<\/p>\n<p>You can also upload an existing image &#8211; but to keep things simple, let&#8217;s pick Ubuntu 14.04 from the set of images that are available.<\/p>\n<p>The last thing you need is to &#8220;Name your VM group&#8221; &#8211; for this post I&#8217;ll pick RooVM. Then it&#8217;s simply a matter of pressing the Create button. There are other options for size etc, but you can play with those another time.<\/p>\n<p>[Insert <a href=\"https:\/\/soundcloud.com\/dabeatwrecka\/jeopardy-think-music-1960s\">Jeopardy &#8216;think&#8217; music<\/a> here..it&#8217;ll take a couple of minutes]<\/p>\n<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/runningvm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1485\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/runningvm-500x167.png\" alt=\"runningvm\" width=\"500\" height=\"167\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/runningvm-500x167.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2015\/07\/runningvm.png 1024w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a>So now we have a VM running in the cloud! You can see a public IP address has been assigned and it is using our BluemixVM security key.<\/p>\n<p>Now let&#8217;s login, I&#8217;ll show examples from a linux machine and leave other OSes as an exercise for the user.<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">$ ssh -i BluemixVM.pem ibmcloud@129.41.143.151\r\nThe authenticity of host '129.41.143.151 (129.41.143.151)' can't be established.\r\nRSA key fingerprint is 76:00:7e:b3:77:4f:37:fd:ca:5f:6b:a8:a0:8f:7f:66.\r\nAre you sure you want to continue connecting (yes\/no)? yes\r\nWarning: Permanently added '129.41.143.151' (RSA) to the list of known hosts.\r\nWelcome to Ubuntu 14.04.1 LTS (GNU\/Linux 3.13.0-24-generic x86_64)\r\n\r\n * Documentation:  https:\/\/help.ubuntu.com\/\r\n\r\nThe programs included with the Ubuntu system are free software;\r\nthe exact distribution terms for each program are described in the\r\nindividual files in \/usr\/share\/doc\/*\/copyright.\r\n\r\nUbuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by\r\napplicable law.\r\n<\/pre>\n<p>So now you&#8217;ve got a ssh session into the cloud based VM.<\/p>\n<p>There are a couple of things you might want to do:<\/p>\n<p>Let&#8217;s run a quick update to make sure that we&#8217;ve got all the latest patches<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">$ sudo apt-get update &amp;&amp; sudo apt-get upgrade<\/pre>\n<p>Set the default shell for your ibmcloud user<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">$ sudo vi \/etc\/passwd<\/pre>\n<p>and change the last line to look like this<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">ibmcloud:x:1000:1000::\/home\/ibmcloud:\/bin\/bash<\/pre>\n<p>Let&#8217;s also install my favourite shell <a href=\"https:\/\/mosh.org\/\">mosh<\/a>.<\/p>\n<blockquote><p>Mosh<br \/>\n(mobile shell)<br \/>\nRemote terminal application that allows <strong class=\"callout\">roaming<\/strong>, supports\u00a0<strong class=\"callout\">intermittent connectivity<\/strong>, and provides intelligent <strong class=\"callout\">local echo<\/strong> and line editing of user keystrokes.<\/p><\/blockquote>\n<pre class=\"lang:default highlight:0 decode:true\">$ sudo apt-get install python-software-properties\r\n$ sudo add-apt-repository ppa:keithw\/mosh\r\n$ sudo apt-get update\r\n$ sudo apt-get install mosh<\/pre>\n<p>The VM image we&#8217;re using has an <a href=\"https:\/\/en.wikipedia.org\/wiki\/Iptables\">iptables<\/a> firewall. However, <a href=\"https:\/\/wiki.ubuntu.com\/UncomplicatedFirewall\">ufw<\/a> is also installed and being used to manage the firewall &#8212; the nice thing about ufw is that by default it will persist our changes. Mosh uses the same ports as ssh, but it additionally uses some UDP ports.<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">$ sudo ufw allow 60000:60020\/udp<\/pre>\n<p>Note: the mosh installation appears to add some rules to \/etc\/ufw\/applications.d but I don&#8217;t understand why ufw isn&#8217;t picking those up. Manually adding them as above works fine.<\/p>\n<p>Now you can use mosh to connect (assuming you have mosh installed on your local laptop)<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">mosh --ssh='ssh -i BluemixVM.pem' ibmcloud@129.41.143.151<\/pre>\n<p>You still might want to combine mosh with <a href=\"https:\/\/tmux.github.io\/\">tmux<\/a> or <a href=\"http:\/\/www.gnu.org\/software\/screen\/\">screen<\/a>\u00a0as mosh doesn&#8217;t provide a scroll back buffer.<\/p>\n<p>Last tweak &#8211; you might have noticed that sudo is providing a warning every time you use it<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">$ sudo ls\r\nsudo: unable to resolve host roovm-40273122<\/pre>\n<p>This is because the \/etc\/hosts file is badly formed. Edit it such that your hostname appears on the\u00a0second line (we could probably replace ubuntu, but this is easy and won&#8217;t break anything). Below is my modified file<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">127.0.0.1       localhost\r\n127.0.1.1       ubuntu roovm-40273122\r\n\r\n# The following lines are desirable for IPv6 capable hosts\r\n::1     localhost ip6-localhost ip6-loopback\r\nff02::1 ip6-allnodes\r\nff02::2 ip6-allrouters\r\n<\/pre>\n<p>Now sudo executes without warning.<\/p>\n<p><strong>Footnote<\/strong>: this is a <em>BETA<\/em> service, don&#8217;t be surprised if some of what I show above does change. Please provide feedback via comments to this post and I&#8217;ll update accordingly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Bluemix platform is expanding from being a simple Cloud Foundry (CF) based PaaS, to one with a range of runtime platforms. Today you can pick one of: app, container or virtual machine (VM). I like to think of this as a continuum, sometimes you want the simplicity of an application &#8211; or the control &hellip; <a href=\"https:\/\/lowtek.ca\/roo\/2015\/bluemix-vms\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Bluemix Virtual Machines&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-1478","post","type-post","status-publish","format-standard","hentry","category-work"],"_links":{"self":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/comments?post=1478"}],"version-history":[{"count":14,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1478\/revisions"}],"predecessor-version":[{"id":2274,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1478\/revisions\/2274"}],"wp:attachment":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/media?parent=1478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/categories?post=1478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/tags?post=1478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}