Diving Into Containers

WARNING!!!!!! Straight from the Mad Scientist!!

Part 2

No were not talking about dumpster diving ….but close. I don’t know about you , but I am a conceptual thinker. Give me the “headlines” (and google) and I can usually figure things out. If you’re not wired that way, along with the book mentioned in Part 1, you can also find some awesome documentation over at docker.com.

OK, Part 1 left you with some homework. Did you set up your github and dockerhub accounts?…….OK….I’ll wait……go do it now!!!!

Conceptually, docker has three basic parts. Docker images (plenty to pull off of dockerhub.com), The Docker client (docker command) and the docker host (server) running the docker daemon. Most of the interaction is with the host using the client commands. Below you will see a simple model of docker.

docker_machine

At this point you should have a new Ubuntu:Mate workstation and the docker deamon installed. If you were to use the $ sudo docker images command you should see a few local images. These were pulled down from dockerhub when we tested the docker install in Part 1. Here is an example of my current system.

docker_images

You will probably notice the xod442, this is my dockerhub account name. Followed by a slash and the name of the Docker image. If you want to remove one image you can use the $ sudo docker rmi (image_name) command. If you would like a clean slate and delete all of the images you can use the $ sudo docker rmi $(sudo docker images -q), and say good bye to all your images. I used this several times in my learning process.

We briefly touched on the command to get us into a new container. We used $ sudo docker run -i -t ubuntu /bin/bash. The /bin/bash tells docker to do something and keep the container running. Without it the container would start and stop very quickly. You can use the $ sudo docker ps -a command to see the status of all containers. Without the -a option the command only shows running containers. In the graphic below I show the commands to start a new container and break down what is happening. I also show how to get out of a container (exit) and how to commit the changes that you make to a container, creating a new docker image (this is the point where the dockerhub account is going to come in handy.

docker_in_out

Here is a diagram of the process. Using the docker run to initialize a new container, adding some extra love to it and committing to a new docker image. They say a picture is worth a 1000 words but this one is most likely 385. Remember concepts/headlines only!!!

docker_create

I think this is a good breaking point. I urge you to go out to docker hub and browse some of the pre-built images. No need to reinvent the wheel, there are plenty to toys to play with. One last tip before we sign off. Use the $ sudo docker search (keyword) to look for specific images you might be interested in. You just might find what you are looking for. Finally if you want to get something you find on the dockerhub site, use the $ sudo docker pull (user-name/image_name) command to pull it down to your docker host.

Part 3 will be a docker survival kit!

I can hardly contain myself!

WARNING!!!!!! Straight from the Mad Scientist!!

Part 1

Curiosity and need often go hand in hand. When you know nothing about something, its best to start reading. Here is “The Docker Book” by James Turnbull. Perfect learners guide.

This blog is an effort to condense this information and help you get past a few wookie traps.

OK, first things first. What is Docker and why do you care? Well, I think of Docker as a multiplexer for the Operating System as opposed to VMware’s HyperVisor acting as a multiplexer for the hardware.

Here is a diagram of the basic differences between Virtualizaion and Containers. When you develop an application, it has dependencies on certain libraries and binaries (files we don’t often think about). If we are developing this on a VM in VMware, the app is dependent on certain files in that particular operation system. So if I ZIP up the APP files and send them to someone on another VM, the APP might not run. The only way to guarantee the APP to work correctly is to send the entire Virtual Machine. Docker builds and manages containers. Every dependent file needed for the APP to run properly are packaged in a very small file called a container. As long as you load the container on a similar docker host, the APP will run perfectly.

vmwarelab+logic

Let’s get started, we will need a workstation to turn into a Docker platform. I am a self confessed VirtualBox user. I could talk about why, but it would just be boring and not any fun. So fire up a new image of Ubuntu. Just found this and I have to admit….its pretty nice. Just take a look!

docker_server

Install Docker:

Installing Docker is straight forward.
Open a terminal window and at the command prompt enter:
sudo apt-get update
sudo apt-get install docker.io

Make sure it installed properly by launching a new container:
sudo docker run -i -t ubuntu /bin/bash

You should now see a new bash root@c0679a7f6d84:/#
If this is what you see then you are in a new container. Congratulations!

UP NEXT!!!! Working with containers. Do yourself a favor and signup for free accounts on Github and Dockerhub…you’re going to need them!

A box inside a box inside a box?

Starting out in a new job and I find myself needing to know way more about VMware than I do now. Luckily, I have not been living under a rock and I know what VMware is. In a very small nutshell, VMware is a virtualization technology that uses hypervisors that basically multiplex the underlying hardware to many virtual machines. Multiple hypervisors are managed by VMware vSphere (Individual hypervisors can be managed by vCenter Client, more on that later). I’m thinking more like a Pistachio nutshell.

I recently acquired a new laptop with 16 GB of RAM and I have gone a little crazy with building Virtual Machines in Oracle Virtual Box and not really having a need for VMware products. Life comes at you fast and you need to learn to adapt or you will no longer be relevant. With a little creative thinking I found a way to build a complete VMware environment with two hypervisors, a vShpere appliance and a couple of real VM’s to vMotion back and forth. Big thanks to sysAdmGirl….she rocks!

Here is a picture of the logical lab environment. Keep in mind there are only two physical devices. The laptop and the Synology data store.

vmwarelab+logic

First things first, you will need to get a copy of Oracle Virtual Box and shutdown anything that is taking up extra RAM on your system, yes Chris, that means you’ll have to shut down TweetDeck as well!

You will see from the diagram the three Oracle VB’s will have 4GB of RAM and a 10GB hard disk and 2 processors. Follow the links to the ESXi hypervisor  (an ISO file), download it and while you are on VMware’s website get the vSphere OVA appliance. Two of  the Oracle Virtual Boxes will be made by using the Oracle Virtual Box interface and create new VM’s make sure to set the network interface cars to “bridged” mode. The third (vSphere) you will just need to double-click the OVA file and it will import into Virtual Box.

When they are all installed and running it will look like this.
vmwarelab+phys

ALERT!!!!! Pay attention here!!!
When you look at the vShere appliance it will say to point your browser to https://some_IP_address:5480. When you do, you will see something that looks like this:

vmwarelab+logic

You are probably thinking, where do I import the ESXi servers?…That’s what I thought too. This screen is to configure the vShpere appliance with single sign on and database storage locations. These are not the droids you are looking for. Drop the port 5480 from your URL and you will be presented the vShpere web client interface.

The VMware vSphere Web Client is a newer interface compared to the VMware vSphere Client (the old school client). The VMware vSphere client is the same tool used to manage a single ESXi hypervisor as well as vSphere. you can find it on VMware site as well. Once it’s installed, just feed it the IP address of your vSphere appliance (minus the port 5480) and off you go!

Alright, now you should have the three VM’s up and running. You will need to create a common data store that is running NFS. I used my Synology Network attached storage device. Find something you can use and figure out how to make it appear as NAS on your lab network. Unfortunately, I don’t know what you will use, so you will have to put on your little grey hat and start looking around. Just Bing it on Google. If you need to know how the ESXi servers connect to the NAS storage you can find that information Here.

What about the VM’s?

OK, so you have this micro environment and we have to find a desktop image we can deploy on our ESXi servers to vMotion back and forth. I found Damn Small Linux (50MB) fits the bill. Get it and load it to the shared NFS storage and use vSphere to create new VM’s on each hypervisor.

You’ve been a good sport so far and I promise we are almost at the end of this exercise. I did this because I thought “I wonder what would happen if I installed VMware in Oracle Virtual Box?” Would it work?  Is it like mixing matter and anti-matter? You are about to find out.

We need to make some slight modification to the ESXi hypervisors network settings so follow along:
vsphere
In this diagram we launch the VMware vSphere Client and give the credentials for the vShpere appliance. Somehow mine is set to root/vmware. Then we click on each hypervisor and edit the networking settings.
vsphere
Drilling down a little deeper, look for the properties and select the Management network (remember, this is for a LAB, in real life you would most likely do something else). Once there, click on the vMotion option to allow vMotion across the Management network.

BOOM! Use the vSphere to “MIGRATE” the DSL VM’s back and forth. Can you say Winner!!!

This is a very brief post about the working of vmware. I found a ton of cool , free, online training  Here at VMware.com

Play Nice, you’re on your way to becoming a VCP!!

I feel a disturbance….but this time it’s a good thing

In case you have been hiding in a wiring closet admiring the weave of the Cat 5/6 cabling the last few months, let me bring you up to date on a big announcement from Hewlett-Packard. SDN.

Here is a link to the page
HP Go SDN!

In 3 days and about 4 hours, HP will officially lauch the HP SDN App Store! This is a place where HP and 3rd party applications will be made available for use with the HP VAN SDN Controller. SDN Applications can either run internally in the controller (Reactive) or externally (Proactive). These application can be easily be downloaded to your controller (Reactive) or run along side of the controller (Proactive).

This is great news because those of us who imagine we are monster DevOps mavens…I did say imagine…can create applications and once accepted, can be accessed through the App Store. These applications can generate revenue for you.

So if you’re a company in need of a SDN solution, you have a place to shop. If your capable of creating your own application, you have a marketplace to sell your wares.

After all, selling SDN applications on the HP SDN App store is my retirement plan…;-)

Also: Good information over at the SDN commiunity Discussion Boards Here

There is a new love in my life!

What can I say? I was with my long time favorite Linux Distro, Ubuntu, and we were having an argument. I wanted it to have the luscious Cinnamon interface, an it was telling me “I don’t have support for that anymore”. There was some initial shedding of tears and I steeled myself and said “It’s OK, at least I have MATE”. Well I looked up my old acquaintance, MATE and it didn’t take long until I remembered why I left in the first place.

I started staying up late at night, Hitting the Googler, hoping I would find some thing new and refreshing. Then it happened, not only did I find something refreshing, but it was also Minty! I had found something very exciting Linux Mint.

enable_server

I downloaded Linux Mint 17 and was instantly amazed by its good looks. We all know that looks can only go so far. So I took Mint out for a test drive and was completely blown away. The first thing I noticed was that the user interface was Cinnamon!!! WOOOT!

It’s the little things that make all the difference in the world. My scroll wheel on my mouse actually made the content on the screen scroll. What a concept! I was able to quickly search the network and mount my Synology NAS storage device. Lastly, I added my HP OfficeJet PRO8500A printer and it all worked flawlessly!

Just a couple quick commands on the commandline….whhhaaaa? The commandline windows are translucent? Out of the box? Just too cool……where was I…oh yes…command line…..I was able to get my L.A.M.P. server installed and with a quick “a2enmod cgi” I had the cgi script execution working as well.

So, do yourself a favor and dump that old distro for something sleek and beautiful and very, very (user) friendly with a minty fresh taste (I couldn’t resist)!

HIP TIP-O-THE DAY: Head over to Virtualboximages.com to find a boat load of “Free” virtual box VDI’s for your downloading pleasure.

Just don’t tell them I sent you!

Goodbye URLLIB2, I’m not going to miss you!

Hot on the trail of another monster chunk of code writing, I found I was stuck in a trap I made for myself. I was at the end of my understanding of Python, URLLIB2 and IMC eAPI’s. I was trying to HTTP POST a chunk of xml into IMC’s Configuration Template library. This was quite perplexing….I tried every thing I could and no matter how I changed the programming, I would still get the dreaded 500 Internal Server error….you know what I’m talking about. I feel you cringing right now!

So, after about a billion Google searches I started seeing the stuff called Requests. Developed by a guy named Kenneth Reitz, it is my new favorite plaything.

Take a look at this sample of URLLIB2 code to get the POST working.

cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
resp = opener.open(c_url)
print c_url
print cj._cookies
# get to the cookie
foo = cj._cookies[‘10.132.0.100’][‘/imc/’][‘JSESSIONID’].value
foo1 = “JSESSIONID=%s” % (foo)
# Authenticate
authhandler = urllib2.HTTPDigestAuthHandler()
authhandler.add_password(“iMC RESTful Web Services”, server, user, passw)
opener = urllib2.build_opener(authhandler)
a2 = urllib2.install_opener(opener)

# Now build header to send HTTP POST for controller file
#agent = “Apache-Httpclient/4.1 (java 1.5)”
pagehandle=urllib2.Request(my_url,c_data) #Add values forces POST
pagehandle.add_header(‘Content-Type’,’application/xml; charset=utf-8′)
pagehandle.add_header(‘Accept’,’application/xml’)
pagehandle.add_header(‘USer-Agent’,’Apache-Httpclient/4.1 (java 1.5)’)
pagehandle.add_header(‘Accept-encoding’,’application/xml’)
pagehandle.add_header(‘Connection’,’Keep-Alive’)
pagehandle.add_header(‘Cookie’, foo1)
pagehandle.add_header(‘Cookie2′,’$Version=1’)
c_result = urllib2.urlopen(pagehandle)

If you ask me, it was good for its time but very confusing with the openers and handlers.

Now here is the same code using requests..

s = requests.session() # This keeps the session open

# Cookie Factory
r = s.get(my_url)
cook = r.headers[‘set-cookie’]
# Strip out the JSESSIONID
x1, x2, x3 = cook.split(‘;’)
# Set up Authentication header info
auth=HTTPDigestAuth(user,passw)

# POST with requests (Probably don’t need all these headers…but they don’t hurt)

headers = {‘Accept’: ‘application/xml’, ‘host’: ‘10.132.0.100:80’, ‘Content-Type’: ‘application/xml; charset=utf-8’, ‘Accept-encoding’: ‘application/xml’, ‘Connection’: ‘Keep-Alive’, ‘User-Agent’: ‘Apache-HttpClient/4.1 (java 1.5)’, ‘Cookie’: x1, ‘Cookie2’: ‘$Version=1’}

# This sends the controller xml data to the IMC server

r = s.post(my_url, data=c_data, auth=auth, headers=headers)

From here I can use: r.headers, r.return_code because everything the remote site sent back is in the variable “r”.

Thank you Mr. Reitz!!!

P.S. In the end it was a xml tag that I had given a wrong name. Correct name wasand I had…..so humbling!

You Could Use A Rest!

So you have a far flung enterprise network that requires care and feeding to keep things up and running. You know you can’t do it alone and your personnel resources are stretched thin already. You need to start working smarter and not harder. During the last meeting with your HP networking team you find out about a great new network management solution called IMC, Intelligent Management Center.

You like what you see. A network management application that not only let’s you monitor and manage network products from HP, but many other vendors as well. You also discover how IMC can help with network services like AAA, its ability to do compliance checking, and position you to take advantage of Software Defined Networking (SDN) all from a single pane of glass.

After getting IMC up and running, things start to get a little simpler. You like simple. Need to push out a new set of SNMP community strings to 500 switches and routers; you easily finish the task in fifteen minutes. Need to verify you didn’t miss any default community strings? You can set up a compliance check and run it against all the devices in your network with very little effort.

Now that you have IMC doing the heavy lifting for you, taking care of the day to day tasks of backing up all the configurations on your network, base lining software revisions, and keeping an eye on everything else, you deserve a Rest. Not like a siesta, but more like a new innovation to take you to the next level.

RESTful API’s are what I am talking about. With the release of IMC 5.0, HP opened up the eAPI’s for third party applications to integrate with IMC. This results in the ability to have scripts that run outside of IMC get information stored in IMC and push changes into IMC. That’s a lot of IMC! The first time I heard of this I thought, “Hey, I have a new use for my Python chops” and I started to think about the possibilities.

RESTful API’s are basically HTTP calls in the form of PUT, GET and POST. You have probably seen them a thousand times in the top of your web browser and never even noticed them. By using the RESTful API’s you can use a POST to the IMC server to make a change. Perhaps you want to move a single device from one vlan to the next by simply entering the device’s MAC address and a vlan number. Wrap it up in RESTful API script and the job is done. There are multiple client languages that are supported.  Java and Python are my personal favorite.

OpenStack for Idiots

So, being somewhat savvy with the teknical stuff, I thought I would explore the world of Openstack. At first I was thinking that this was similar to OpenFlow. NOT. OpenFlow is the language that is used by the Software Defined Network (SDN) Controller to establish flow tables in Openflow enabled switches…what to know more go to www.openflow.org. Openstack is the environment where compute, storage and networking are virtualized……OK, I’ll wait while you google it…

Moving on…I wanted to know more about this teknology so I did what I always do, buy a book and start reading. It is absolutely amazing what is in those things…

I picked up OpenStack Cloud Computing Cookbook by Kevin Jackson. It’s a great resource but if you are trying to use it as a step by step guide, I wish you good luck. There are a lot of moving parts to OpenStack like Nova, Glance, Keystone, Swift and it requires some general knowledge of what these are. When I saw Keystone I thought of that beer commercial with “Keith Stone”, I can’t get that out of my head.

I used Oracle’s Virtual Box as a base platform and tried to set it up as instructed by the book but soon ran into things that were obsolete. Seems that nova-manage has been replaced with keystone..(I’m getting thirsty, again!).

Eager to see the Horizon dashboard, I went to the ultimate source of knowledge, Google. It wasn’t long until I discovered DevStack. It could not get any simpler to set up a Openstack dev environment. Here’s how I did it.

Set up a generic Linux Virtual Box VM. I use VDMK as the disk file type. Then, using this (http://devstack.org/guides/single-vm.html) as a resource, I just followed the simple instructions.

I picked up a copy of the minimal Ubuntu image at https://help.ubuntu.com/community/Installation/MinimalCD#A64-bit_PC_.28amd64.2C_x86_64.29
It’s only 35M and it’s a quick setup in Virtual Box. Once you get logged into the VM just issue these commands.

apt-get update
apt-get install -qqy git
git clone https://github.com/openstack-dev/devstack.git
cd devstack
echo ADMIN_PASSWORD=password > localrc
echo MYSQL_PASSWORD=password >> localrc
echo RABBIT_PASSWORD=password >> localrc
echo SERVICE_PASSWORD=password >> localrc
echo SERVICE_TOKEN=tokentoken >> localrc
./stack.sh

HIPTIP of the week: If you issue the command “sudo bash” without quotes on the command line, ubuntu will prompt for your password. Now you do not need to start every command with sudo.

Keep an eye on the stack.sh when its finished, it will give instructions on how to access the dashboard.

Congratulations you now have a OpenStack dev platform to play with and just took you first step into the world of Software Defined Networking.