Project
My long term objective is to play with networking apps, particularly node.js in the Pi environment. In order to achieve that I need some sort of Linux OS installed on Pi.Raspberry Pi comes with various OSs.
The ones caught my eye are Raspbian, and Snappy Ubuntu Core.
In this article I will demonstrate a "hello world" app built on an Ubuntu VM and deployed into a Snappy Ubuntu VM.
For this exercise we won't even need a Raspberry Pi board. We will be simulating app deployment to Snappy Ubuntu Core.
Setup
Note: this is my setup You don't need to match it 100%. Equivalents will do.
- A Mac Book Pro.
- A virtualisation app, I use VMware Fusion. ($AU 61.)
- Download Ubuntu (free) and create an Ubuntu VM using your virtualisation app.
- Download an OVA image (free) and create a Snappy Ubuntu Core VM using your virtualisation app.
- An account in Ask Ubuntu portal (free).
Ubuntu VM
This is where you will develop the snappy app. Installing Ubuntu VM using VMware Fusion is straightforward.
I allocated 30 GB, physical space, and 4 Gb RAM, probably an over-allocation. I just want to make sure swift development performance.
I think defaults would just do fine too.
Take a record of the static IP address of the VM allocated by VMware:
ergun@ubuntu:~$ ip adr show
Snappy Ubuntu Core VM
The above disk image is provided in OVA format. To create the VM using VMware follow these instructions.
After creating the Snappy Ubuntu Core VM, it will boot up. The booting process is slow (ironic if you consider the OS is called 'snappy'). The first message it displays: is "Error: malformed file". Simply ignore it. Later on it will also look like stuck with a message "Started Journal Service". But it is not. Don't panic, just leave it running, wait until it finishes, this may take several minutes.
After the boot process finishes it will ask you user name and password, just type "ubuntu" and "ubuntu" respectively until you see you are on:
ubuntu@localhost:~$
The first thing we need to do is to change the default ssh port from 22 to 8022. For this we need to edit the file /etc/ssh/sshd_config:
This file is read-only. You need to make it writeable first:
ubuntu@localhost:~$ cd /etc/ssh ubuntu@localhost:/etc/ssh$ sudo chmod 777 sshd_config ubuntu@localhost:/etc/ssh$ vi sshd_config
Port 8022
Save and exit. Put back the file into read-only:
ubuntu@localhost:/etc/ssh$ sudo chmod 644 sshd_config
To fix the ssh setup you need to run these commands:
cd sudo mv /etc/ssh/sshd_not_to_be_run . sudo service ssh start
Verify that the ssh service started with:
ubuntu@localhost:~$ sudo service --status-all | grep ssh [ + ] ssh
Power-off your snappy than restart afterwards:
ubuntu@localhost:~$ sudo poweroff
Remember, starting snappy will take minutes to complete, so be patient.
Take a record of the static IP address of the Snappy VM allocated by VMware
ubuntu@localhost:~$ ip adr show
Build snappy app, deploy and test
As the last step, we are going to build a "hello world" snappy app on the Ubuntu VM, and deploy it to Snappy VM.
Go to your Ubuntu VM.
Make sure you fixed the ssh setup issue on your Snappy Ubuntu Core VM (See the section above.)
Just follow the instructions given here at Building Snappy Apps for Ubuntu Core.
If all goes well this is what you would see:
ergun@ubuntu:~/snappy-examples/hello-world$ snappy-remote
--url=ssh://172.16.187.129:8022 install
./hello-world_1.0.5_all.snap
=======================================================
Installing ./hello-world_1.0.5_all.snap from local environment
ubuntu@172.16.187.129's password:
ubuntu@172.16.187.129's password:
WARNING:root:Signature check failed, but installing anyway
as requested
Reboot to use the new ubuntu-core.
=======================================================
ubuntu@172.16.187.129's password:
ergun@ubuntu:~/snappy-examples/hello-world$
Go back to your Snappy Ubuntu Core VM and test:
ubuntu@localhost:~$ hello-world.echo Hello World!
Note that as soon as you run your app for the first time it is auto deployed and added to apps folder:
ubuntu@localhost:~$ ls apps snappy-bin sshd_not_to_be_run

excellent!
ReplyDeleteThanks Chris. The breakthrough came this morning with an answer to my ssh problem at Ask Ubuntu portal.
ReplyDelete