By Steven Eschinger | January 5, 2017
This post was updated on September 18th, 2017 for Kubernetes version 1.7.6 & Kops version 1.7.0
Kubernetes (“K8s” for short) is open-source container orchestration platform used to automate the deployment, scaling and management of containerized applications. It was created by Google in 2014 and is built upon their 10+ years of experience running containerized production workloads on a large scale.
Even though Kubernetes has only be around for a couple years, it has already become the most popular container orchestration tool, beating out other major players in the space such as Apache Mesos and Docker Swarm. And some are saying that it is one of the fastest moving projects in the history of open source, based on an analysis of GitHub repository activity.
For somebody who is new to Kubernetes, it can be difficult to know where to get started. For example, there are currently 40 different ways to deploy a Kubernetes cluster, depending on the IaaS provider you are using, the configuration management system you have in place and what type of networking model you want to use.
The following blog series will take you through various parts of Kubernetes, such as deploying and maintaining a single cluster, deploying & managing applications, integrating a cluster with some common CI/CD tools (e.g., Jenkins, Travis CI, Wercker) and how to setup a federation between multiple clusters.
The target audience for this blog series is anyone who is just getting started with Kubernetes and wants to get some hands-on experience.
In the following labs, we will be using Amazon AWS as the IaaS provider, so a general understanding of the following AWS services would be helpful:
- VPC - Virtual Private Cloud
- S3 - Simple Storage Service
- EC2 - Elastic Compute Cloud
- ELB - Elastic Load Balancing
- Route 53 - DNS Web Service
And although it is not mandatory, it would be good to familiarize yourself with the following Kubernetes concepts:
- Cluster Master - Runs the components that provide the cluster’s control plane, such as the API server, etcd, controller manager and the scheduler.
- Cluster Nodes - Worker machines, previously known as minions, which have the services needed to run Pods.
- Pods - Running process in a cluster, which encapsulates an application container(s), storage resources, a unique network IP and the options that govern how the container(s) should run.
- Replica Sets - Ensures that a specified number of Pod “replicas” are running at any one time.
- Deployments - Provides declarative updates for Pods and Replica Sets in order to maintain their desired state.
- Services - Defines a logical set of Pods and a policy by which to access them. Service types include ClusterIP, NodePort and LoadBalancer.
- Namespaces - Sometimes called virtual clusters, they provide the mechanism to partition resources created by users into a logically named group.
- Secrets - An object that contains a small amount of sensitive data such as a password, token or key. Can be retrieved by Pods with a reference.
- Federation - Makes it easier to manage multiple clusters by enabling cross cluster discovery and providing the ability to sync resources across clusters.
- kubectl - Command line interface for running commands against Kubernetes clusters.
- Kops - Stands for “Kubernetes Operations”, it allows you to deploy production-grade, highly-available K8s clusters from the command line.
All of the following posts in this blog series are structured as individual labs and although it is not required to go through them sequentially, it is recommended.
AWS Account: Amazon will be the IaaS provider we will be using and therefore you will need to have an AWS account. If you don’t have an account, you can sign-up for an AWS Free Tier account, which will give you a certain amount of usage of specific AWS resources for free each month for 12 months.
AWS Route 53 Domain: In addition to the AWS account, you will also need to have a public domain hosted in AWS Route 53, which is a requirement to deploy clusters with Kops. If you don’t already have a domain in Route 53 that you can use, refer to the Kops documentation for instructions on how to setup one of the three supported scenarios.
GitHub Account: We will be creating a demo website with Hugo, which will be used in multiple labs. The source for the Hugo site will need to be stored in a GitHub repository owned by you. If you don’t already have a GitHub account, you can create a free account here.
Docker Hub Account: The Docker images for the Hugo site need to be stored in a Docker Hub repository owned by you. If you don’t already have a Docker Hub account, you can create a free account here.
Warning: Some of the AWS resources that will be created in the following labs are not eligible for the AWS Free Tier and therefore will cost you money. For example, running a three node cluster with the suggested instance size of t2.medium will cost you around $0.20 per hour based on current pricing.
There is a single GitHub repository which covers all of the labs.
For the execution of the labs, you can choose to use the provided Vagrantfile to provision a Vagrant box which has everything you will need already installed or you can install the required tools on your local host:
In the first lab, Lab #1: Deploy a Kubernetes Cluster in AWS with Kops, we will go through the following:
- Deploying a cluster in AWS using Kops
- Checking the status of the cluster and the cluster controlling services
- Deleting a cluster
Labs in the Series
- Lab #1: Deploy a Kubernetes Cluster in AWS with Kops
- Lab #2: Maintaining your Kubernetes Cluster
- Lab #3: Creating Deployments & Services in Kubernetes
- Lab #4: Kubernetes Deployment Strategies: Rolling Updates, Canary & Blue-Green
- Lab #5: Setup Horizontal Pod & Cluster Autoscaling in Kubernetes
- Lab #6: Integrating Jenkins and Kubernetes
- Lab #7: Continuous Deployment with Jenkins and Kubernetes
- Lab #8: Continuous Deployment with Travis CI and Kubernetes
- Lab #9: Continuous Deployment with Wercker and Kubernetes
- Lab #10: Setup Kubernetes Federation Between Clusters in Different AWS Regions