Setting up and managing our own servers can take a considerable amount of time especially if we are not a day to day linux user. That is why we see things like serverless and containers catching on. There’s another option out there though too and it’s called unikernels.
What are unikernels though? Unikernels are simple single application operating systems. Instead of deploying our software on top of linux unikernels create an operating system out of our application and run only that app – nothing else. There’s no concept of usernames/passwords or sshin’g into the application as it is only running one application. Traditionally unikernels have been hard to work with as they used to require expert level of systems knowledge. Now there are newer tools like OPS that fix that.
In the next few minutes we are going to build, run, then deploy a php unikernel. First things first let’s download OPS from https://ops.city:
We can also download and build it from github. can always go to https://github.com/nanovms/ops and build it from source – it’s written in Go.
3. Build and Run our First PHP Unikernel
Now that we have that let’s create a temporary working directory:
For this simple example we’ll just use the built-in php webserver just to keep things simple. Put this into a config.json file:
What this does is tell the built in php webserver to listen on port 3030 and place the index.php file onto the otherwise barren filesystem. We’ll put this into a index.php:
Now let’s run it via:
Here we tell OPS that we wish to use PHP7. When we are running this it will first download a php package then it looks at the config file and finally opens up a local port on 3030.
We should see this:
Assuming that boots we should now be able to hit it with curl:
4. Deploy to Google Cloud
Great! We just ran our first php unikernel! Now let’s deploy it. Assume have a google cloud account we’ll need a project id, a service worker key, and a cloud storage bucket to place our built images in. We definitely don’t have to use google but we are using it for this example.
We are going to slightly modify our config.json file and put this inside:
What this does is tell OPS to place our built image in the bucket ‘my-bucket’ and use ‘my-project-id’. We also changed the port to 80 which is the default HTTP port.
If we got a service worker key we can put that somewhere to source like so:
Then let’s build the image. What this does is create a virtual machine on Google Cloud that contains only our application with the php interpreter. It’s important to note that there is no underlying linux system here. When the virtual machine boots it boots straight into our application just like it did locally. This make it run much faster and safer than linux.
We should see something like this when it’s done building:
Now let’s create an instance. Keep in mind an instance is the server. The image is the actual disk image of the server.
If we look at the instance list we can see it running:
Now if we hit that ip up with curl we can see our php unikernel running in Google Cloud!
We can also see the logs from the unikernel:
Congratulations! We’ve built, ran and deployed our first php unikernel on google cloud – now we can go show our friends that we don’t need servers to deploy our applications anymore! Unikernels give us the convenience of containers and serverless with the protection and speed of traditional virtual machines.
Most Recent Articles
- Nov 11, 2019 What Is The Process Of Updating Garmin GPS Maps Free Of Cost? by Henry Ford
- Nov 5, 2019 Quicken Support Number USA by alexa thomson
- Nov 1, 2019 Importance Of Hiring Cyber Security Specialists To Avoid Data Breach& Cyber Attacks by Cyber Defense Group
- Oct 24, 2019 Guide to upgrade MS Office on your Mac devices by Michael Smith
- Oct 7, 2019 Your Organization Needs Information Security Program by Cyber Defense Group
Most Viewed Articles
- 313 hits Google Lighthouse- Auditing & Enhancing Shopify Theme Performance by Anuj Sharma
- 290 hits How Trading Strategies Software Helps to Grow Your Business? by Build Alpha
- 288 hits AVG Tech Support Phone Number by Amy Wilson
- 278 hits Www RR Com Toll-Free 1-800-414-2180 by Rachel Cooper
- 275 hits Collect Plausible Information on SCADA Now by James Finch
In today’s competitive world, one must be knowledgeable about the latest online business that works effectively through seo services....
Are you caught in between seo companies introduced by a friend, researched by you, or advertised by a particular site? If that is the...
Walmart is being sued by a customer alleging racial discrimination. The customer who has filed a lawsuit against the retailer claims that it...
L'arte del tatuaggio maori e i tatuaggi Maori tradizionali sono estremamente unici; questi rigorosi tatuaggi Maori tradizionali hanno la loro...
Generic Viagra is an effective medicine for treatment of erectile dysfunction (ED) or male impotence. It is a generic equivalent of Viagra. Both...