Book Image

The Kubernetes Book

By : Nigel Poulton, Pushkar Joglekar
Book Image

The Kubernetes Book

By: Nigel Poulton, Pushkar Joglekar

Overview of this book

Kubernetes is the leading orchestrator of cloud-native apps. With knowledge of how to work with Kubernetes, you can easily deploy and manage applications on the cloud or in your on-premises data center. The book begins by introducing you to Kubernetes and showing you how to install it. You’ll learn how to use Kubernetes Services and bring stable and reliable networking to apps that are deployed on Kubernetes. You'll delve deep into the powerful storage subsystem of Kubernetes and learn how to leverage the variety of external storage backends in your applications. As the book progresses, it shows you how to use features such as DaemonSets, Helm, and RBAC to enhance your Kubernetes applications. You'll explore the six categories of identifying vulnerabilities and look at a few ways to prevent and mitigate them. You'll also look at ways to secure the software delivery pipeline by discussing some image-related best practices. The book ends by sharing with you some resources that’ll help take your Kubernetes knowledge to the next level. By the end of the book, you’ll have the confidence and skills to leverage all the features of Kubernetes to develop scalable applications.
Table of Contents (23 chapters)
Free Chapter
1
Chapter 1
3
Chapter 2
5
Chapter 3
7
Chapter 4
9
Chapter 5
11
Chapter 6
13
Chapter 7
15
Chapter 8
17
Chapter 9
19
Chapter 10
21
Chapter 11

How to Create a Deployment

In this section, we'll create a brand-new Kubernetes Deployment from a YAML file. We can do the same thing imperatively using the kubectl run command, but we shouldn't. The right way is the declarative way!

The following code snippet is the Deployment manifest file that we'll use. It's available in the book's GitHub repo in the deployments folder and is called deploy.yml.

The examples assume it's in your system's PATH and is called deploy.yml.

apiVersion: apps/v1  #Older versions of k8s use apps/v1beta1
kind: Deployment
metadata:
  name: hello-deploy
spec:
  replicas: 10
  selector:
    matchLabels:
      app: hello-world
  minReadySeconds: 10
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - name: hello-pod
        image: nigelpoulton/k8sbook:latest
        ports:
...