Kubernetes Cookbook
eBook - ePub

Kubernetes Cookbook

Practical solutions to container orchestration, 2nd Edition

Hideto Saito, Hui-Chuan Chloe Lee, Ke-Jou Carol Hsu

Partager le livre
  1. 554 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Kubernetes Cookbook

Practical solutions to container orchestration, 2nd Edition

Hideto Saito, Hui-Chuan Chloe Lee, Ke-Jou Carol Hsu

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Learn how to automate and manage your containers and reduce the overall operation burden on your system.

Key Features

  • Use containers to manage, scale and orchestrate apps in your organization
  • Transform the latest concept of Kubernetes 1.10 into examples
  • Expert techniques for orchestrating containers effectively

Book Description

Kubernetes is an open source orchestration platform to manage containers in a cluster environment. With Kubernetes, you can configure and deploy containerized applications easily. This book gives you a quick brush up on how Kubernetes works with containers, and an overview of main Kubernetes concepts, such as Pods, Deployments, Services and etc.

This book explains how to create Kubernetes clusters and run applications with proper authentication and authorization configurations. With real-world recipes, you'll learn how to create high availability Kubernetes clusters on AWS, GCP and in on-premise datacenters with proper logging and monitoring setup. You'll also learn some useful tips about how to build a continuous delivery pipeline for your application. Upon completion of this book, you will be able to use Kubernetes in production and will have a better understanding of how to manage containers using Kubernetes.

What you will learn

  • Build your own container cluster
  • Deploy and manage highly scalable, containerized applications with Kubernetes
  • Build high-availability Kubernetes clusters
  • Build a continuous delivery pipeline for your application
  • Track metrics and logs for every container running in your cluster
  • Streamline the way you deploy and manage your applications with large-scale container orchestration

Who this book is for

This book is for system administrators, developers, DevOps engineers, or any stakeholder who wants to understand how Kubernetes works using a recipe-based approach. Basic knowledge of Kubernetes and Containers is required.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Kubernetes Cookbook est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Kubernetes Cookbook par Hideto Saito, Hui-Chuan Chloe Lee, Ke-Jou Carol Hsu en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Cloud Computing. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2018
ISBN
9781788836876
Édition
2
Sous-sujet
Cloud Computing

Walking through Kubernetes Concepts

In this chapter, we will cover the following recipes:
  • Linking Pods and containers
  • Managing Pods with ReplicaSets
  • Deployment API
  • Working with Services
  • Working with Volumes
  • Working with Secrets
  • Working with names
  • Working with Namespaces
  • Working with labels and selectors

Introduction

In this chapter, we will start by creating different kinds of resources on the Kubernetes system. In order to realize your application in a microservices structure, reading the recipes in this chapter will be a good start towards understanding the concepts of the Kubernetes resources and consolidating them. After you deploy applications in Kubernetes, you can work on its scalable and efficient container management, and also fulfill the DevOps delivering procedure of microservices.

An overview of Kubernetes

Working with Kubernetes is quite easy, using either a Command Line Interface (CLI) or API (RESTful). This section will describe Kubernetes control by CLI. The CLI we use in this chapter is version 1.10.2.
After you install Kubernetes master, you can run a kubectl command as follows. It shows the kubectl and Kubernetes master versions (both the API Server and CLI are v1.10.2):
$ kubectl version --short
Client Version: v1.10.2
Server Version: v1.10.2
kubectl connects the Kubernetes API server using the RESTful API. By default, it attempts to access the localhost if .kube/config is not configured, otherwise you need to specify the API server address using the --server parameter. Therefore, it is recommended to use kubectl on the API server machine for practice.
If you use kubectl over the network, you need to consider authentication and authorization for the API server. See Chapter 7, Building Kubernetes on GCP.
kubectl is the only command for Kubernetes clusters, and it controls the Kubernetes cluster manager. Find more information at http://kubernetes.io/docs/user-guide/kubectl-overview/. Any container, or Kubernetes cluster operation, can be performed by a kubectl command.
In addition, kubectl allows the inputting of information via either the command line's optional arguments or a file (use the -f option); it is highly recommended to use a file, because you can maintain Kubernetes configuration as code. This will be described in detail in this chapter.
Here is a typical kubectl command-line argument:
kubectl [command] [TYPE] [NAME] [flags]
The attributes of the preceding command are as follows:
  • command: Specifies the operation that you want to perform on one or more resources.
  • TYPE: Specifies the resource type. Resource types are case-sensitive and you can specify the singular, plural, or abbreviated forms.
  • NAME: Specifies the name of the resource. Names are case-sensitive. If the name is omitted, details for all resources are displayed.
  • flags: Specifies optional flags.
For example, if you want to launch nginx, you can use either the kubectl run command or the kubectl create -f command with the YAML file as follows:
  1. Use the run command:
$ kubectl run my-first-nginx --image=nginx "my-first-nginx"
  1. Use the create -f command with the YAML file:
$ cat nginx.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-first-nginx
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx

//specify -f (filename)
$ kubectl create -f nginx.yaml
deployment.apps "my-first-nginx" created
  1. If you want to see the status of the Deployment, type the kubectl get command as follows:
$ kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
my-first-nginx 1 1 1 1 4s
  1. If you also want the support abbreviation, type the following:
$ kubectl get deploy
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
my-first-nginx 1 1 1 1 38s
  1. If you want to delete these resources, type the kubectl delete command as follows:
$ kubectl delete deploy my-first-nginx
deployment.extensions "my-first-nginx" deleted
  1. The kubectl command supports many kinds of sub-commands; use the -h option to see the details, for example:
//display whole sub command options 
$ kubectl -h


//display sub command "get" options
$ kubectl get -h


//display sub command "run" options
$ kubectl run -h
This section describes how to use the kubectl command to control the Kubernetes cluster. The following recipes describe how to set up Kubernetes components:
  • Setting up a Kubernetes cluster on macOS using minikube and Set up a Kubernetes cluster on Windows using minikube in Chapter 1, Building Your Own Kubernetes Cluster
  • Setting up a Kubernetes cluster on Linux using kubeadm in Chapter 1, Building Your Own Kubernetes Cluster
  • Setting up a Kubernetes cluster on Linux using kubespray (Ansible) in Chapter 1, Building Your Own Kubernetes Cluster

Linking Pods and containers

The Pod is a group of one or more containers and the smallest deployable unit in Kubernetes. Pods are always co-located and co-scheduled, and run in a shared context. Each Pod is isolated by the following Linux namespaces:
  • The process ID (PID) namespace
  • The network namespace
  • The interprocess communication (IPC) namespace
  • The unix time sharing (UTS) namespace
In a pre-container world, they would have been executed on the same physical or virtual machine.
It is useful to construct your own application stack Pod (for example, web server and database) that are mixed by different Docker images.

Getting ready

You must have a Kubernetes cluster and make sure that the Kubernetes node has accessibility to the Docker Hub (https://hub.docker.com) in order to download Docker images.
If you...

Table des matiĂšres