Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
DevOps with Kubernetes. - Second Edition

You're reading from  DevOps with Kubernetes. - Second Edition

Product type Book
Published in Jan 2019
Publisher Packt
ISBN-13 9781789533996
Pages 484 pages
Edition 2nd Edition
Languages
Concepts
Authors (3):
Hideto Saito Hideto Saito
Profile icon Hideto Saito
Hui-Chuan Chloe Lee Hui-Chuan Chloe Lee
Profile icon Hui-Chuan Chloe Lee
Cheng-Yang Wu Cheng-Yang Wu
Profile icon Cheng-Yang Wu
View More author details

Table of Contents (14) Chapters

Preface 1. Introduction to DevOps 2. DevOps with Containers 3. Getting Started with Kubernetes 4. Managing Stateful Workloads 5. Cluster Administration and Extension 6. Kubernetes Network 7. Monitoring and Logging 8. Resource Management and Scaling 9. Continuous Delivery 10. Kubernetes on AWS 11. Kubernetes on GCP 12. Kubernetes on Azure 13. Other Books You May Enjoy

Getting Started with Kubernetes

So far, we've learned about the benefits that containers can bring us, but what if we need to scale out our services to meet the needs of our business? Is there a way to build services across multiple machines without dealing with cumbersome network and storage settings? Is there an easy way to manage and roll out our microservices with a different service cycle? This is where Kubernetes comes into play. In this chapter, we'll look at the following concepts:

  • Understanding Kubernetes
  • Components of Kubernetes
  • Kubernetes resources and their configuration files
  • How to launch the kiosk application using Kubernetes

Understanding Kubernetes

Kubernetes is a platform for managing containers across multiple hosts. It provides lots of management features for container-oriented applications, such as auto-scaling, rolling deployments, compute resources, and storage management. Like containers, it's designed to run anywhere, including on bare metal, in our data center, in the public cloud, or even in the hybrid cloud.

Kubernetes fulfills most application container operational needs. Its highlights include the following:

  • Container deployment
  • Persistent storage
  • Container health monitoring
  • Compute resource management
  • Auto-scaling
  • High availability by cluster federation

With Kubernetes, we can manage containerized applications easily. For example, by creating Deployment, we can roll out, roll over, or roll back selected containers (Chapter 9, Continuous Delivery) with just a single command. Containers...

Getting started with Kubernetes

In this section, we'll learn how to set up a single-node cluster. Then, we'll learn how to interact with Kubernetes via its command-line tool: kubectl. We'll go through all of the important Kubernetes API objects and their expressions in YAML format, which is the input to kubectl. We'll then see how kubectl sends requests to the API server to create the desired objects accordingly.

Preparing the environment

Firstly, kubectl has to be installed. In major Linux distributions (such as Ubuntu or CentOS), you can just search for and install the package named kubectl via the package manager. In macOS, we can choose to use Homebrew (https://brew.sh/) to install it. Homebrew is...

Multi-container orchestration

In this section, we'll revisit our ticketing service: a kiosk web service as a frontend that provides an interface for get/put tickets. There is a Redis acting as cache to manage how many tickets we have. Redis also acts as a publisher/subscriber channel. Once a ticket is sold, the kiosk will publish an event into it. The subscriber is called recorder and will write a timestamp and record it to the MySQL database. Please refer to the last section in Chapter 2, DevOps with Containers, for a detailed Dockerfile and Docker compose implementation. We'll use Deployment, Service, Secret, Volume, and ConfigMap objects to implement this example in Kubernetes. The source code can be found at the following link: https://github.com/DevOps-with-Kubernetes/examples/tree/master/chapter3/3-3_kiosk.

The service architecture with Kubernetes resources is...

Summary

In this chapter, we learned the basic concepts of Kubernetes. We learned that a Kubernetes master has kube-apiserver to handle requests and controller managers are the control center of Kubernetes. These ensure our desired container amount is fulfilled, they control the endpoint to associate pods and services, and they control API access tokens. We also have Kubernetes nodes, which are the workers to host the containers, receive the information from the master, and route the traffic based on the configuration.

We then used minikube to demonstrate basic Kubernetes objects, including pods, ReplicaSets, Deployments, Services, secrets, and ConfigMaps. Finally, we demonstrated how to combine all of the concepts we've learned into our kiosk application.

As we mentioned previously, the data inside containers will disappear when a container is gone. Therefore, volume is extremely...

lock icon The rest of the chapter is locked
You have been reading a chapter from
DevOps with Kubernetes. - Second Edition
Published in: Jan 2019 Publisher: Packt ISBN-13: 9781789533996
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}