OpenStack, Kubernetes and OpenShift crash course for impatient - OpenStack
January 19, 2018 2 min read
OpenStack is a pretty old standard for describing cloud resources and interacting with them. Most of its APIs were suggested around 2012. It is "Open" because multiple vendors that provide cloud services (including Rackspace and Red Hat) agreed to use the same API for interaction with them and called it OpenStack.
OpenStack
OpenStack evolves over time and has seen many releases. OpenStack consists of a list of APIs, called Projects for managing different aspects of you cloud infrastructure. Arguably the most important among them are Nova used to create new virtual machines and Cinder used to manage block devices. You'll also have to interact with Keystone project in order to authenticate your requests to all the OpenStack APIs.
Key concepts
I'll briefly list the key concepts of Nova and key concepts of Cinder here.
- instance - a virtual server.
- flavor - in OpenStack you can't just say I want a server with X MB RAM, Y processor, Z hard drive - you have to choose one from the existing presets - flavors - e.g. 32 MB RAM, 4 core processor, 20 GB hard drive (see more here).
- disk - every instance needs at least a root disk that contains boot loader and operating system to boot; root disk can be represented either by an ephemeral disk that will be destroyed when the instance is destroyed or by persistent volume that will survive the destruction of instance (see more here).
- volume - persistent Cinder volume; by contrast with ephemeral disks, contents of volumes are persistent and survive instance destruction (see more here).
- image - image of an operating system, similar to .iso images that you install your OS from. Used to create ephemeral root disks.
- snapshot - copy of a disk or volume, taken at a certain moment of time; could be used to create a root volume from it.
Python APIs
OpenStack provides convenient python APIs for each project. You can add them to
requirements.txt
file of your project and install them via pip
.
Here I'll provide a sample piece of code that creates an instance. Note that Openstack apis change a bit over time, so this piece of code might become obsolete (especially, considering it's 2 years old).
Terraform
Instead of using the raw OpenStack API, you can use some compatibility layer that abstracts out some of the API details. A popular solution nowadays is Terraform by Hashicorp. Here is their manual on provisioning servers via OpenStack.
Part 2. KubernetesWritten by Boris Burkov who lives in Moscow, Russia, loves to take part in development of cutting-edge technologies, reflects on how the world works and admires the giants of the past. You can follow me in Telegram