You are on page 1of 68

Kubernetes Fundamentals: A

Step-by-Step Development and


Interview Guide 1st Edition Himanshu
Agrawal
Visit to download the full and correct content document:
https://ebookmass.com/product/kubernetes-fundamentals-a-step-by-step-developmen
t-and-interview-guide-1st-edition-himanshu-agrawal-2/
Kubernetes
Fundamentals
A Step-by-Step Development and
Interview Guide

Himanshu Agrawal
Foreword by Krishna Prasad P
Kubernetes
Fundamentals
A Step-by-Step Development
and Interview Guide

Himanshu Agrawal
Foreword by Krishna Prasad P
Kubernetes Fundamentals: A Step-by-Step Development and
Interview Guide
Himanshu Agrawal
Pune, India

ISBN-13 (pbk): 978-1-4842-9728-5 ISBN-13 (electronic): 978-1-4842-9729-2


https://doi.org/10.1007/978-1-4842-9729-2

Copyright © 2023 by Himanshu Agrawal


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Divya Modi
Development Editor: James Markham
Copyeditor: Kimberly Wimpsett
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York,
1 New York Plaza, Suite 4600, New York, NY 10004-1562, USA. Phone 1-800-SPRINGER, fax (201)
348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media,
LLC is a California LLC and the sole member (owner) is Springer Science + Business Media
Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for
reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is
available to readers on GitHub (github.com/apress). For more detailed information, please visit
https://www.apress.com/gp/services/source-code.
Paper in this product is recyclable
For my mother, my sister, and my Pittar Baavji.
Love you, Papa, Unnat, Yashi, Jiju, Bittu, Shanu, Kanak,
Mamaji, Mamiji, and Naaniji.
कर्मण्येवाधिकारस्ते मा फलेषु कदाचन।
मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि॥
Bhagavad Gita Chapter 2, Verse 47:
You are only entitled to act (karma),
not to the fruits of your act.
Do not become attached to the fruits of your actions. At the
same time, do not become attached to inaction (no karma).
Table of Contents
About the Author������������������������������������������������������������������������������xvii

About the Technical Reviewer�����������������������������������������������������������xix

Acknowledgments�����������������������������������������������������������������������������xxi

Introduction�������������������������������������������������������������������������������������xxiii

Foreword���������������������������������������������������������������������������������������� xxvii

Chapter 1: Welcome to The World of Containers!���������������������������������1


Fundamental Questions We Need to Ask��������������������������������������������������������������2
How Has Application Deployment Evolved?����������������������������������������������������2
What Is a Hypervisor?��������������������������������������������������������������������������������������4
What Is Virtualization?�������������������������������������������������������������������������������������6
What Is Distributed Design?����������������������������������������������������������������������������7
What Are Different Application Design Architectures in
Distributed Design?�����������������������������������������������������������������������������������������8
What Is Cloud Computing?����������������������������������������������������������������������������10
What Is Containerization?������������������������������������������������������������������������������12
What Are the Advantages of Containerization Over Virtualization?����������������13
Can Containerized Applications Run on a Cloud Infrastructure?�������������������16
What Is the Microservices Architecture?�������������������������������������������������������16
How Is Containerization Different from the Microservices Architecture?������19
What Is the Future of Containerization?��������������������������������������������������������19
Understanding Key Container Technologies��������������������������������������������������������20
What Is Docker?��������������������������������������������������������������������������������������������20

v
Table of Contents

What Is Kubernetes?�������������������������������������������������������������������������������������21
What Is Red Hat’s OpenShift Container Platform?�����������������������������������������21
What Does Being “Cloud-Native” Mean?�������������������������������������������������������22
What Is Serverless?���������������������������������������������������������������������������������������23
Why Use Docker and Kubernetes?����������������������������������������������������������������24
Comparing Key Container Technologies��������������������������������������������������������������25
What Are the Alternatives to Docker?������������������������������������������������������������25
What Are the Alternatives to Kubernetes?�����������������������������������������������������26
How Are Kubernetes and Docker Related?����������������������������������������������������27
How Is Kubernetes Different from Docker Swarm?���������������������������������������27
How Is Kubernetes Different from Red Hat OpenShift,
Google Kubernetes Engine, and Others?�������������������������������������������������������28
Summary������������������������������������������������������������������������������������������������������������28

Chapter 2: Kubernetes Deep Dive�������������������������������������������������������31


History of Kubernetes�����������������������������������������������������������������������������������������32
How Did Kubernetes Come into Existence?��������������������������������������������������32
What Is the Linux Foundation?����������������������������������������������������������������������34
What Is the Cloud Native Computing Foundation?����������������������������������������34
Kubernetes Architecture�������������������������������������������������������������������������������������35
What Is the Architecture of Kubernetes?�������������������������������������������������������35
What Are the Key Features of Kubernetes?���������������������������������������������������36
What Is Kubernetes Not?�������������������������������������������������������������������������������38
Master Node (Control Plane)�������������������������������������������������������������������������������39
What Does the Master Node Do?�������������������������������������������������������������������40
What Are the Different Components of the Master Node?�����������������������������41
What Is the API Server (kube-apiserver)?������������������������������������������������������41
What Is the Scheduler (kube-scheduler)?�����������������������������������������������������42

vi
Table of Contents

What Is the Controller Manager (kube-controller-­manager)?������������������������42


What Is etcd?�������������������������������������������������������������������������������������������������43
What Is cloud-controller-manager?���������������������������������������������������������������43
Can the Master Node and Worker Nodes Run on the Same Machine?����������44
Worker Node�������������������������������������������������������������������������������������������������������44
What Are the Components of a Worker Node?����������������������������������������������45
What Is the Node Agent kubelet?������������������������������������������������������������������45
What Is the Node Agent kube-proxy?������������������������������������������������������������46
What Is the Container Runtime?��������������������������������������������������������������������46
What Is the Container Runtime Interface?�����������������������������������������������������47
Communication Between Worker Nodes and Master Nodes�������������������������������48
How Does the Worker Node Communicate with the Master Node?��������������48
How Does the Master Node Communicate with the Worker Node?��������������48
Object Management and Garbage Collection������������������������������������������������������49
What Are Objects in Kubernetes?������������������������������������������������������������������50
What Are the Important Elements of a Kubernetes Object?��������������������������50
How Do You Manage Objects in Kubernetes?������������������������������������������������54
What Is Garbage Collection in Kubernetes?��������������������������������������������������56
Installing Kubernetes������������������������������������������������������������������������������������������58
What Are Several Kubernetes Installation Configurations?���������������������������58
What Are Several Options for Running a Kubernetes Cluster on
Any Local Box?����������������������������������������������������������������������������������������������59
What Is Kubeadm?����������������������������������������������������������������������������������������59
What Is Minikube?�����������������������������������������������������������������������������������������59
Summary������������������������������������������������������������������������������������������������������������64

Chapter 3: Fundamental Objects in Kubernetes Clusters�������������������67


Containers�����������������������������������������������������������������������������������������������������������68
What Is a Container and a Container Image?������������������������������������������������69

vii
Table of Contents

Are Containers Immutable and Stateless?����������������������������������������������������69


Can Containers Self-Heal?�����������������������������������������������������������������������������70
Which Kubernetes Component Creates Containers Within a Pod?����������������70
Do We Always Need to Pull the Container Image?�����������������������������������������70
How Do I Create a Pod with a Single Container?�������������������������������������������71
What Are Container Life-Cycle Hooks?����������������������������������������������������������73
What Are the Possible Container Life-Cycle States?�������������������������������������75
What Are Init Containers?������������������������������������������������������������������������������76
Explain Ephemeral Containers�����������������������������������������������������������������������79
What Are Different Multicontainer Pod Patterns?������������������������������������������80
Pods��������������������������������������������������������������������������������������������������������������������81
What Is a Pod?�����������������������������������������������������������������������������������������������81
Can a Pod Have More Than One Container Running Inside It?����������������������82
Is It Recommended to Have More Than One Container in a Pod?�����������������82
Can You Add a New Container After the Pod Has Been Created?������������������83
Can Pods Self-Heal?��������������������������������������������������������������������������������������84
Do Containers Inside a Pod Share Resources like IP Addresses?�����������������84
Within a Pod, Can Containers Have the Same Names?���������������������������������84
What Is the Threshold for the Number of Pods You Can Create
on a Node?����������������������������������������������������������������������������������������������������85
What Are the Different Pod Life-Cycle Phases?���������������������������������������������85
Pod Status vs. Pod Phase Status�������������������������������������������������������������������87
What Are the Different Pod Conditions?��������������������������������������������������������87
How Do You Control Container Restarts Within a Pod?����������������������������������88
How to List Pods from All Namespaces?�������������������������������������������������������89
What Is Pod Networking?������������������������������������������������������������������������������89
Within the Same Pod, Can Containers Share the Pod’s Storage Volume?�����90
How Are Pods Created or Managed?�������������������������������������������������������������90

viii
Table of Contents

What Are Static Pods?�����������������������������������������������������������������������������������90


What Happens to Pods When a Node Dies, and Can the Same
Pod Get Rescheduled to Another Node?��������������������������������������������������������91
What Happens to Terminated Pods?��������������������������������������������������������������91
Can the Pod Be Forcefully Deleted?��������������������������������������������������������������92
What Are Affinity and Anti-affinity in Kubernetes?����������������������������������������92
What Happens When More Than One Node Selection Term Is
Specified with Node Affinity?������������������������������������������������������������������������97
What Happens When More Than One Match Expression Is Specified
with Node Affinity?����������������������������������������������������������������������������������������98
How Will You Make Sure That a Certain Pod Gets Created on a Certain
Node?������������������������������������������������������������������������������������������������������������98
How Will You Make Sure That Your Pod Gets Scheduled Only on a
Node That Is Already Running a Certain Pod?���������������������������������������������101
How Will You Ensure That Two Pods Get Scheduled on the Same Node?����101
How Can You Control Pod Security?������������������������������������������������������������105
What Is the Runtime Class?�������������������������������������������������������������������������106
Summary����������������������������������������������������������������������������������������������������������107

Chapter 4: Advanced Objects In Kubernetes Clusters����������������������109


Workload Resources�����������������������������������������������������������������������������������������110
What Are Workload Resources?�������������������������������������������������������������������110
What Are Several Built-in Workload Resources?�����������������������������������������110
DaemonSet and StatefulSet������������������������������������������������������������������������������111
What Is DaemonSet?�����������������������������������������������������������������������������������111
What Is a DaemonSet Object?���������������������������������������������������������������������111
What Is StatefulSet?������������������������������������������������������������������������������������114
Can You Explain a StatefulSet Object?��������������������������������������������������������114
How Does StatefulSet Different from Deployment?������������������������������������116
How Do You Delete a DaemonSet and StatefulSet?������������������������������������117

ix
Table of Contents

ReplicaSet: Providing a Stable Set of Running Pods�����������������������������������������118


What Is ReplicaSet, and What Is Its Purpose?���������������������������������������������119
What Is a ReplicaSet Object?����������������������������������������������������������������������119
How Do You List All ReplicaSets from All Namespaces?�����������������������������121
How Do You Delete a ReplicaSet?���������������������������������������������������������������122
How Does ReplicaSet Work?�����������������������������������������������������������������������122
Is ReplicaSet Self-Healing?�������������������������������������������������������������������������123
Which Kubernetes Object Creates a ReplicaSet?����������������������������������������123
Do You Need to Explicitly Create a ReplicaSet?�������������������������������������������123
Can ReplicaSet Be Used Independently of the Deployment Object?�����������123
When Do You Explicitly Use ReplicaSet?�����������������������������������������������������124
Deployment�������������������������������������������������������������������������������������������������������124
What Is the Kubernetes Deployment Workload?�����������������������������������������124
Can You Explain Several Elements of the Deployment Specification?���������125
Can You Explain a Simple Deployment Object?�������������������������������������������127
How Do You List All Deployments from All Namespaces?���������������������������129
How Do You Delete a Deployment?�������������������������������������������������������������130
Is a New ReplicaSet Created Each Time a Deployment Is Created?������������130
What Are Deployment Rollout and Revision?����������������������������������������������130
What Are the Different Deployment Life-­Cycle Statuses?���������������������������132
How Can You Restart a Deployment?����������������������������������������������������������134
What Is a Rolling Update?���������������������������������������������������������������������������136
How Can You Roll Back a Deployment?�������������������������������������������������������142
How Can You Scale a Deployment?�������������������������������������������������������������144
What Is Horizontal Autoscaling?������������������������������������������������������������������145
How Can You Pause and Resume a Deployment?���������������������������������������146
Can You Delete a Pod from a Running Deployment, and What
Happens Then?��������������������������������������������������������������������������������������������146

x
Table of Contents

Can You Update a Deployment While an Existing Deployment Is


Rolling Out?�������������������������������������������������������������������������������������������������146
What Is the Difference Between the matchLabels and labels Fields
of Any Object’s Template?���������������������������������������������������������������������������147
What Are Common Deployment Strategies?������������������������������������������������148
What Is the Blue-Green Deployment Strategy?�������������������������������������������149
What Is a Canary Deployment?�������������������������������������������������������������������151
How Do You Deploy a Feature with Zero Downtime in Kubernetes?�����������154
Summary����������������������������������������������������������������������������������������������������������155

Chapter 5: Objects Important For A Secure Kubernetes Cluster������157


Jobs: Seeing the Task to Completion����������������������������������������������������������������158
What Is a Job in Kubernetes?����������������������������������������������������������������������158
How Do Jobs Differ from Other Workload Resources?��������������������������������159
Can You Use a Job to Run Multiple Pods in Parallel?����������������������������������159
Where Can a Kubernetes Job Be Used?������������������������������������������������������159
What Are Alternatives to Kubernetes Jobs?������������������������������������������������160
What Is a Simple Nonparallel Job Object?��������������������������������������������������160
How Do You Specify How Many Tries the Job Controller Should
Make to Finish the Job?������������������������������������������������������������������������������162
How Do You Specify the Maximum Time for Which a Job Should Run?������164
How Do You Delete a Job?���������������������������������������������������������������������������166
What Are Parallel Jobs?�������������������������������������������������������������������������������167
What Is a Cron Job?������������������������������������������������������������������������������������173
How Do You Delete a Cron Job?������������������������������������������������������������������175
What Happens If a Cron Job Is Already Running and It Is Time for
the Next Job?����������������������������������������������������������������������������������������������176
How Do You Control the History of Cron Job Execution?�����������������������������177
Namespaces: Virtual Clusters Within Kubernetes Clusters�������������������������������177
What Is a Namespace?��������������������������������������������������������������������������������177

xi
Table of Contents

Can You Have Multiple Objects with the Same Name in


One Namespace?����������������������������������������������������������������������������������������178
How Do You Create a New Namespace?�����������������������������������������������������178
How Do You Create an Object in a Particular Namespace?�������������������������179
How Do You Delete a Namespace?��������������������������������������������������������������181
How Can You List All the Namespaces?������������������������������������������������������182
Which Namespaces Are by Default Present in the Kubernetes System?����182
Do All Kubernetes Resources Fall Under Some Namespace?���������������������184
How Can You Explicitly Set the Default Namespace?����������������������������������185
Labels and Label Selectors: All About Filtering and Selection��������������������������187
What Are Object Names and Object UIDs?��������������������������������������������������188
Labels����������������������������������������������������������������������������������������������������������188
Label Selectors��������������������������������������������������������������������������������������������191
What Are Annotations?��������������������������������������������������������������������������������196
Authentication, Authorization, and Admission Control��������������������������������������198
How Does Access Control Work in Kubernetes?������������������������������������������198
What Is Authentication?�������������������������������������������������������������������������������199
What Is Authorization?���������������������������������������������������������������������������������204
What Is Admission Control?�������������������������������������������������������������������������207
Summary����������������������������������������������������������������������������������������������������������209

Chapter 6: Networking In Kubernetes����������������������������������������������211


Fundamentals of Kubernetes Networking��������������������������������������������������������212
Basic Computer Networking Concepts��������������������������������������������������������212
What Is Kubernetes Networking?����������������������������������������������������������������215
What Are the Fundamental Restrictions in Kubernetes Networking?����������216
How Do Two Containers Within the Same Pod Interface with
Each Other?�������������������������������������������������������������������������������������������������217
How Do Two Containers, Running in Different Pods, Interface
with Each Other?�����������������������������������������������������������������������������������������217

xii
Table of Contents

How to Expose Applications Inside and Outside of the Cluster?�����������������218


Service: Exposing Applications to the Outside World����������������������������������������219
What Is Service, and Why Do We Need It?���������������������������������������������������219
What Are Endpoints and EndpointSlice?������������������������������������������������������220
What Are a Service Object and Pod Selection?�������������������������������������������221
What Are the Different Service Types?��������������������������������������������������������226
What Is the ClusterIP Service?��������������������������������������������������������������������227
What Is the ExternalName Service?������������������������������������������������������������232
Can You Expose Two Ports in the Same Service?����������������������������������������234
How Can You Add Session Affinity to Your Service?������������������������������������235
What Are the Service Discovery Mechanisms in Kubernetes?��������������������235
Ingress: Consolidate Routing Rules�������������������������������������������������������������������235
What Is Ingress and the Ingress Controller?������������������������������������������������236
What Is an Ingress Object?��������������������������������������������������������������������������237
What Are the Possible Values of the Path Type, and How
Does Path Matching Work?�������������������������������������������������������������������������242
What Are the Different Ingress Types?��������������������������������������������������������243
Summary����������������������������������������������������������������������������������������������������������246

Chapter 7: Kubernetes Storage System��������������������������������������������249


Volumes: Store Your Data����������������������������������������������������������������������������������250
What Is a Volume in Kubernetes, and Why Is It Needed?����������������������������250
What Is the Ephemeral Volume Type?����������������������������������������������������������252
What Is the Persistent Volume Type?�����������������������������������������������������������255
What Are PersistentVolume and PersistentVolumeClaim?��������������������������257
What Are the PersistentVolume and PersistentVolumeClaim Objects?�������260
Can You Demonstrate the Creation and Use of Persistent Volumes?����������264
How Do You Delete PersistentVolume and PersistentVolumeClaim
Objects?�������������������������������������������������������������������������������������������������������267

xiii
Table of Contents

ConfigMap: Store Configuration Data in Plain Text��������������������������������������������268


What Is ConfigMap, and What Is Its Purpose?���������������������������������������������269
What Are Several Ways to Create a ConfigMap Object?������������������������������269
How Can You Use ConfigMap Inside a Pod?������������������������������������������������274
Is ConfigMap Data Immutable?�������������������������������������������������������������������278
Secrets: Store Configuration Data in Encrypted Format�����������������������������������279
What Is Secret, and What Is Its Purpose?����������������������������������������������������279
What Are Several Ways to Create a Secret Object?�������������������������������������280
How Can You Use Secret Inside a Pod?�������������������������������������������������������286
What Is the Difference Between ConfigMap and Secret?����������������������������290
Summary����������������������������������������������������������������������������������������������������������290

Chapter 8: Manage Your Kubernetes Cluster Efficiently�������������������293


Probes: Health Check Your Containers��������������������������������������������������������������294
What Is a Probe?�����������������������������������������������������������������������������������������294
What Are Several Mechanisms for Performing a Probe?�����������������������������294
What Are Some Outcomes of a Probe?��������������������������������������������������������295
What Are Several Types of Probes?�������������������������������������������������������������295
What Are Important Configuration Parameters for Probes?������������������������298
Can You Create an exec Liveness Probe?����������������������������������������������������299
What Is a httpGet Liveness Probe?��������������������������������������������������������������303
What Is a tcpSocket liveness Probe?����������������������������������������������������������305
Can You Create a Readiness Probe?������������������������������������������������������������306
Resource Management: Requests, Limits, and Quotas�������������������������������������312
What Are Requests and Limits?�������������������������������������������������������������������313
What Are Resource Quotas?������������������������������������������������������������������������317
What Are Limit Ranges?������������������������������������������������������������������������������320
Can You Create a Pod with Explicit CPU and Memory Requests and
Limits?���������������������������������������������������������������������������������������������������������323

xiv
Table of Contents

What Happens When You Create a Pod with Unreasonably High


Requests and Limits?����������������������������������������������������������������������������������325
What Happens When You Create a Pod That Breaches Resource
Quota Limits?����������������������������������������������������������������������������������������������326
How to Automatically Assign Default Requests and Limits for Pods?���������328
How Do You Define Minimum and Maximum CPU and Memory
Constraints for Pods?����������������������������������������������������������������������������������330
What Happens When You Create a Pod Without Any Explicit CPU
and Memory Requests and Limits?�������������������������������������������������������������333
What Is Pod Priority, and How Is It Useful?��������������������������������������������������334
Taints and Tolerations���������������������������������������������������������������������������������������338
What Are Taints and Tolerations?�����������������������������������������������������������������338
What Are the Different Effects of Taints And Tolerations?���������������������������342
Can a Node Have More Than One Taint?������������������������������������������������������342
Summary����������������������������������������������������������������������������������������������������������346

Chapter 9: Docker Overview And Kubernetes Best Practices�����������349


Docker: All You Need to Know to Get Started����������������������������������������������������350
Fundamentals of Docker�����������������������������������������������������������������������������350
Understanding Primary Technologies in Docker������������������������������������������364
Primary Docker Commands�������������������������������������������������������������������������369
Docker Best Practices���������������������������������������������������������������������������������������373
What Are Docker Development Best Practices?������������������������������������������373
What Are Dockerfile Best Practices?�����������������������������������������������������������375
What Are Docker Security Best Practices?��������������������������������������������������377
Kubernetes Best Practices��������������������������������������������������������������������������������378
What Are Kubernetes Development Best Practices?�����������������������������������378
What Are the Best Practices for Large Clusters?�����������������������������������������381

xv
Table of Contents

What Are the General Security Best Practices?�������������������������������������������381


What Are the Secret Configuration Security Best Practices?����������������������383
Summary����������������������������������������������������������������������������������������������������������384

Chapter 10: kubectl: The Command-Line Tool����������������������������������385


Fundamentals of kubectl����������������������������������������������������������������������������������385
What Is kubectl?������������������������������������������������������������������������������������������385
How Does kubectl Find the Details of the Kubernetes Cluster?������������������386
Can You Explain a Sample kubeconfig File?������������������������������������������������387
What Is the General kubectl Syntax?�����������������������������������������������������������388
Important kubectl Commands: A Cheat Sheet��������������������������������������������������392
General Commands�������������������������������������������������������������������������������������393
Namespace Commands�������������������������������������������������������������������������������396
Pod Commands�������������������������������������������������������������������������������������������397
Commands to Customize the kubectl Output����������������������������������������������398
Workload Resource Commands�������������������������������������������������������������������401
Deployment Commands������������������������������������������������������������������������������402
Jobs and CronJobs Commands�������������������������������������������������������������������404
Networking Commands�������������������������������������������������������������������������������406
Storage Commands�������������������������������������������������������������������������������������407
Node Commands�����������������������������������������������������������������������������������������408
Summary����������������������������������������������������������������������������������������������������������410

Index�������������������������������������������������������������������������������������������������413

xvi
About the Author
Himanshu Agrawal is an accomplished IT
professional with more than a decade of
experience in designing and implementing
complex solutions with JEE technologies. He
is a technical reviewer for a published book on
JVM and specializes in niche technical areas
such as JVM, Multithreading, TLS, Apache,
and Kubernetes, to name a few. Himanshu
has certifications from prestigious universities
such as Harvard and MIT.
Himanshu is an Oracle Certified Java
Developer, an Oracle Certified Web Component Developer, and certified
by Google Cloud for Architecting with the Google Kubernetes Engine.
Himanshu has also worked on .NET technologies in his early career and is
a Microsoft Certified Professional.
Currently Himanshu works as an Associate Consultant with CGI,
counted among the largest IT and business consulting services firms in
the world. He is a distinguished engineer and a recognized professional
within CGI, having received many quarterly and annual awards. Himanshu
extends his technical expertise to teams primarily in the finance and
telecom domains.
Himanshu actively contributes to online technical communities
including StackOverflow.com. In his spare time, Himanshu enjoys
watching movies and reading books.

xvii
About the Technical Reviewer
Nikhil Jain is an Ansible expert with more
than a decade of DevOps experience. He has
been contributing to and using Ansible since
its inception. He currently works closely with
Ansible engineering.
He is an open-source enthusiast and is part
of the Ansible Pune meetup-­organizing team.
He has presented multiple Ansible sessions
at various global and local events. In addition
to automating things using Ansible, he loves
watching sports and is a regular player on the
local cricket team.

xix
Acknowledgments
I would like to thank Apress and its editorial team for giving me the
opportunity to write this book.
A special thanks to Divya Modi, acquisition editor, for working with
me throughout the project. Without her, this book would not have seen
the light of day. Thanks to the book’s production editor, Sowmya Thodur.
Thanks also to the book’s development editor, James Markham, and the
technical reviewer, Nikhil Jain, for their feedback.
I would like to thank God for everything He has given me.
Finally, I would like to thank my parents, my sister, and my Pittar
Baavji, without whom I would not have gotten this far in my life.

xxi
Introduction
This book is a step-by-step development guide designed with an
interview-driven approach. This book will walk you through the breadth
of Kubernetes concepts required to develop, deploy, and manage
applications on Kubernetes, and as you do so, you will be getting ready for
job interviews. Each concept in the book is presented in the form of a Q&A,
with questions being framed exactly as they would be in an interview. This
book can be of great advantage if you are preparing for a job interview that
involves working with Kubernetes.
Specifically, in Chapter 1, “Welcome to The World of Containers!”
you will understand how application development and deployment have
evolved over the decades and led to containerization. We will discuss a
broad range of concepts such as virtualization, hypervisors, microservices,
and more.
In Chapter 2, “Kubernetes Deep Dive,” we will enter the world of
Kubernetes. We will start our discussion with the Kubernetes architecture
and how all its components work together to form a Kubernetes cluster.
You will also be taken through the history and evolution of Kubernetes.
In Chapter 3, “Fundamental Objects in Kubernetes Clusters,” and
Chapter 4, “Advanced Objects in Kubernetes Cluster,” you will learn about
all the important Kubernetes objects: containers, pods, deployments,
ReplicaSets, and more. We will go into detail about how to work with each
of them to maximize their potential. We will also go through Kubernetes
deployment strategies and concepts related to rollout and rollback.
In Chapter 5, “Objects Important for a Secure Kubernetes Clusters,”
you will learn about Kubernetes objects such as namespaces, jobs, etc.,
that play a pivotal role in creating a secure Kubernetes cluster. You will

xxiii
Introduction

learn how labels, label selectors, and annotations work in Kubernetes. You
will also understand Kubernetes access control mechanisms, covering
authentication, authorization, and admission control.
In Chapter 6, “Networking in Kubernetes,” and Chapter 7, “The
Kubernetes Storage System,” you will learn about two critical components
in any computing ecosystem: networking and storage. We will discuss
Kubernetes services and ingress. We will also go over the various storage
options available in Kubernetes for both normal and confidential data.
In Chapter 8, “Manage Your Kubernetes Cluster Efficiently,” you will
gain an understanding of how to manage a Kubernetes cluster using health
checks, probes, resource quotas, and resource limits. You will also learn
about taints and tolerations.
In Chapter 9, “Docker Overview and Kubernetes Best Practices,” you
will get an overview of Docker. We will also cover some best practices for
using Kubernetes and Docker together.
In Chapter 10, “kubectl: The Command-Line Tool,” you will be
introduced to the kubectl command-line tool. We will also provide a
summary of key kubectl commands.
Over the course of the book, you can expect to learn about the
following:
• How application design and deployment have evolved
over the past decades, including all the related
technologies such as virtualization, hypervisor,
distributed computing, containerization, microservices
architecture, and more

• The architecture and history of Kubernetes

• The two most fundamental objects of Kubernetes:


containers and pods

xxiv
Introduction

• Advanced Kubernetes objects and workload resources:


Deployment, ReplicaSet, StatefulSet, DaemonSet, Job,
and CronJob

• Kubernetes deployment strategies

• Creating virtual clusters within the same Kubernetes


cluster, using the Namespace object

• Access control in Kubernetes, covering authentication,


authorization, and admission control

• Filtering, selection, and tagging using labels, label


selectors, and annotations

• The Kubernetes networking and storage system

• Managing a Kubernetes cluster using health checks,


probes, resource quotas, and resource limits

• The kubectl command-line tool and a cheat sheet of


important kubectl commands

xxv
Foreword
The technological landscape is evolving at an unprecedented pace. Over
the last three decades, I have seen a lot of advancements and am more
excited and optimistic about technological advancements now than ever.
We are making momentous, responsible progress across the technological
spectrum, from human intelligence to machine learning and artificial
intelligence, manual tasks to automation and RPA, distributed ledgers to
blockchains, on-premise to cloud computing, and so on. They all have one
thing in common: a piece of software, an application, on top of the stack
that requires a container to run on.
Along with these technological advancements, we are also making a
significant shift in application design and deployment strategies. Moving
from a monolithic to a microservices architecture is no longer a choice
but rather a fundamental need, a strategic decision in order to maintain
a competitive edge in a world where scalability and resilience are the
foundations of customer expectations. This is where containerization
comes into play. It is expected that, eventually, all production-grade large
to medium-sized applications will be migrated to a containerized platform.
Kubernetes as the best container orchestrator is almost becoming
cliché. Kubernetes sits in the center of any greenfield or brownfield
application architecture and is changing the way applications are
developed and maintained. Container orchestrators such as Kubernetes
are also critical components of the DevOps architecture. And today we
cannot imagine a production design that is not woven with the fabric
of DevOps. This brings us to our central point: Kubernetes is quickly
becoming an indispensable technology for application development and
deployment, and it is a must-learn for anyone working in the field.

xxvii
Foreword

Himanshu begins his book Kubernetes Fundamentals by discussing


how application design and deployment have evolved over time,
eventually leading to containerization. Then he delves into Kubernetes
application development concepts in depth. Himanshu is a distinguished
engineer who has grown from being a software engineer to a technical
architect and is well-known within CGI and various technology forums for
his technical expertise. Himanshu has brought his best knowledge to this
essential book on Kubernetes.
I am pleased to present Himanshu Agrawal’s Kubernetes
Fundamentals.

Krishna Prasad
Vice President Consulting Delivery, CGI

xxviii
CHAPTER 1

Welcome to The World


of Containers!
In this chapter, we will lay some solid groundwork by introducing key
technologies involved in the evolution of containerization. We will start
by covering how application deployment has evolved over the decades.
We will discuss what virtualization is and how hypervisors are key to the
process of virtualization. We will extend that discussion to understand
distributed architecture, cloud computing models, and how virtualization
and distributed architecture are at the core of cloud computing. We will
also discuss the microservices architecture and how containerization is
different from the microservices architecture.
Next, we will start our discussion of two key containerization
technologies: Docker and Kubernetes. We will explain why container
orchestrators like Kubernetes and Red Hat’s OpenShift Container
Platform (OCP) are needed, what it means to be “cloud-native,” and what
serverless is.
Lastly, we will review some popular alternatives to Docker and
Kubernetes and explain how these technologies are related to each other.
We will also compare and contrast two popular container orchestration
platforms: Kubernetes and Docker Swarm.
With those expectations in mind, let’s begin!

© Himanshu Agrawal 2023 1


H. Agrawal, Kubernetes Fundamentals, https://doi.org/10.1007/978-1-4842-9729-2_1
Chapter 1 Welcome to The World of Containers!

Fundamental Questions We Need to Ask


In this section, we will go through several fundamental concepts related
to how application design and deployment have evolved over the past
several decades, as well as key technologies involved in the evolution of
containerization.

How Has Application Deployment Evolved?


We can categorize the evolution of application deployment into three
deployment models: the traditional deployment model, the virtualized
deployment model, and the containerized deployment model. Figure 1-1
depicts the evolution of the application deployment model.

Figure 1-1. Application deployment models

Traditional Deployment Model


In the traditional deployment model, the application runs directly on the
operating system, and the OS runs on the hardware. This deployment
model clearly has a problem because a bad application can end up
hogging most of the server’s resources while other applications are starved

2
Chapter 1 Welcome to The World of Containers!

for the server’s resources. A typical solution used for this problem is to
run each application on a different physical server, but running a set of
physical servers is expensive even for big organizations.
Suppose we have four applications and a 5GB physical server (for easy
understanding, we are only considering RAM size). So, to overcome the
problem, we would deploy our application on different physical servers of
1GB each, guaranteeing a fixed set of server resources to each application.

Virtualized Deployment Model


In the virtualized deployment model, an application runs on a (guest)
OS, and the (guest) OS, instead of running on the hardware as in the case
of the traditional deployment model, runs inside a VM. The VM runs
on a hypervisor, the hypervisor runs on an OS, and the OS runs on the
hardware. The only major problem with this deployment model is that
virtual machines are too heavy, and therefore scalability and performance
become bottlenecks.
Using the same example as before, in the virtualized deployment
model, we would create four 1GB virtual machines on our 5GB physical
server and then deploy each of our four applications in a separate virtual
machine.

Containerized Deployment Model


In the containerized deployment model, an application runs inside a
container, and the container runs on a container runtime (like Docker).
Now, this container runtime runs either on an operating system, as in the
case of a traditional deployment model, or on a (guest) operating system,
as in the case of a virtualized deployment model. In this deployment
model, the container runtime virtualizes the operating system.
Using the same example as before, in the containerized deployment
model, we would deploy our four applications in different containers and
assign 1GB of server resources to each container.

3
Chapter 1 Welcome to The World of Containers!

This is the best and most flexible deployment model because if, at any
point in time, we think that one of our applications needs only 500MB of
server resources, then we can make this adjustment within seconds by
reconfiguring the container to use only 500MB of server resources, thereby
freeing up 500MB of server resources that can then be used somewhere
else. And these adjustments are possible because containers are very
lightweight.

What Is a Hypervisor?
A virtual machine is an emulation of a physical computer, and a hypervisor
is software that creates and runs VMs. A hypervisor virtualizes a host
system’s hardware by emulating CPU, memory, and networking resources
so that these resources can be divided and several virtual machines can be
created from them. Since the hypervisor provides hardware virtualization,
each virtual machine can have a different operating system.
Primarily, hypervisors are of two types: type-1 and type-2. Figure 1-2
shows a graphical depiction of type-1 and type-2 hypervisors.

Figure 1-2. Type-1 versus type-2 hypervisor

4
Chapter 1 Welcome to The World of Containers!

Type-1 (Native or Bare-Metal) Hypervisor


A type-1 hypervisor runs on bare metal (or the host’s hardware), so we can
say that a hypervisor type-1 is an abstraction of the hardware. And since
type-1 hypervisors run on bare metal, they have complete control of the
computer resources, and hence type-1 hypervisors can perform resource
management and allocation without interfacing with the host OS.
The stack for the type-1 hypervisor will look like this: at the bottom,
there is bare metal or hardware; on top of the hardware, there is a
hypervisor; and on top of the hypervisor, there are many different virtual
machines.
IBM z/VM, Oracle VM Server for SPARC, Microsoft Hyper-V, etc., are
type-1 hypervisor examples.

Type-2 (Hosted) Hypervisor


A type-2 hypervisor runs on a host operating system, and the host
operating system runs on the hardware. And since type-2 hypervisors
don’t run directly on the hardware, they cannot perform complete
resource allocation and management; instead, the system administrator
performs resource allocation and management and distributes them to the
required number of VMs.
The stack for the type-2 hypervisor will look like this: at the bottom,
there is bare metal or hardware; on the hardware, there is a host OS; on
the host OS, there is a hypervisor; and on the hypervisor, there are many
different VMs.
VirtualBox (a product of Oracle), VMware Player, etc., are some type-2
hypervisor examples.

5
Chapter 1 Welcome to The World of Containers!

What Is Virtualization?
Virtualization is a broad concept that means creating a virtual representation
of something. In the world of IT, virtualization is a technology that allows
us to virtualize computing resources such as servers, networks, storage,
etc. By hardware virtualization, we get virtual machines (VMs). Two core
entities in the concept of virtualization are hypervisors and virtual machines.
Hypervisors were already discussed in the previous section, and virtual
machines are nothing but byproducts of hypervisors.

What Are Different Virtualization Types?


As mentioned, virtualization is a broad concept through which we can
create a virtual representation of something. In terms of IT, different
virtualization types can be as follows:

• Virtualization of server

• Virtualization of storage

• Virtualization of network

• Virtualization of data

• Virtualization of desktop

How Are Virtualization and Cloud Computing Different?


Cloud computing is nothing but the delivery of computing resources
on an on-demand basis, and virtualization is the technology that makes
cloud computing possible. Without virtualization technologies, there
would be no cloud computing. In cloud computing, when you create a
compute instance, technically it is nothing but a virtualized instance of the
physical server.
Another backbone of cloud computing is distributed architecture.

6
Chapter 1 Welcome to The World of Containers!

What Is Distributed Design?


A distributed design, also known as distributed computing or distributed
system or distributed architecture, is a group of computing systems spread
across multiple computing nodes that work together to achieve a common
goal. These computing systems could be software processes or hardware
devices.
A distributed design is in contrast to a centralized design, where
the complete state of the system lies on a central node or a central node
that plays the role of the master. In a centralized design, since all key
decisions are centralized, there are always chances of bottlenecks and
the failure of one node resulting in complete system failure. Chances of
such bottlenecks or cascading failure are greatly reduced with distributed
designs.

Figure 1-3. Distributed design versus centralized design

As shown in Figure 1-3, both in distributed systems and in centralized


systems, there are many nodes (computing systems), but the difference is
that in the case of a centralized system, one node will play the role of the

7
Chapter 1 Welcome to The World of Containers!

master, managing all other worker nodes, while in the case of a distributed
system, there is no such master node. This master node of the centralized
system can result in a cascading failure of nodes, and since this master
node is absent in the distributed system, there is no single point of failure,
making distributed systems very resilient.
In simple words, having a distributed system or design just means
that your system is designed in such a way that there is no single point of
failure.
Cloud computing, the microservices architecture, and
containerization, in some way or another, are all practical examples of
distributed systems.

 hat Are Different Application Design


W
Architectures in Distributed Design?
Depending on how you are designing your application, there can be four
application architectures in distributed computing:

• An architecture with one client and one server

• An architecture with three tiers


• An architecture with n tiers

• An architecture involving peer-to-peer communication

An Architecture with One Client and One Server


This is the most basic type of distributed computing architecture, which
consists of one server and one or more clients. The server is responsible
for providing a service, and the clients consume the service by making
requests to the server. Most commonly, these requests are made using a
lightweight protocol like HTTP. Email servers, web servers, and file servers
are good examples of a client-server architecture.

8
Chapter 1 Welcome to The World of Containers!

And since client-server architecture is a centralized architecture,


it is prone to issues of a centralized architecture like communication
bottlenecks and single points of failure.

An Architecture with Three Tiers


In an architecture with three tiers, on the server side, there is more
than one tier: one tier representing application servers and one tier
representing database servers.
The tier representing application servers commonly plays the role of
the middle tier, sitting between clients and database servers. They contain
all the application and business logic needed for running the application.
The tier representing database servers commonly plays the role of the
data tier that is responsible for data storage and management. There is no
direct communication with this third tier from the client tier; the third tier
communicates only with the middle tier.
The advantage of a three-tier architecture is that it reduces
communication bottlenecks and single points of failure and improves
distributed computing performance.

An Architecture with n Tiers


In an architecture with n tiers, which is commonly known as a multitier
architecture, is an upgrade of the architecture with three tiers in which
server responsibilities are further divided into layers or tiers and each layer
has a specific responsibility.
Suppose the application design is broken down into five parts; then it
becomes a five-tier application architecture. The three-tier architecture is
an example of n-tier architecture.

9
Chapter 1 Welcome to The World of Containers!

Peer-to-Peer
The peer-to-peer architecture eliminates the roles of client and server
because, in this architecture, there is no separate node that performs the
role of a server and there is no separate node that performs the role of a
client; any node can have the role of a client or a server.
The peer-to-peer architecture is the closest form of a decentralized
system. In peer-to-peer architecture, since any node can play the role of a
server or client, the scalability of peer-to-peer architecture is the highest.
Blockchain and instant messaging are the best examples of a peer-to-peer
architecture.

What Is Cloud Computing?


Simply put, cloud computing is the delivery of computing resources on an
on-demand basis, and the client pays on a usage basis. These computing
resources could be ready-to-use applications, servers (either physical or
virtual machines), storage, networking, etc. A cloud provider hosts these
computing resources at a remote data center and makes them available
over the Internet on an on-demand basis.
The cloud computing model is in contrast to the traditional on-­
premises IT model, where organizations either pay huge up-front costs to
purchase the expensive infrastructure or pay heavy monthly bills for all
the infrastructure they have rented or leased, irrespective of whether it is
used. In this way, cost savings are among the many advantages of cloud
computing. Another big advantage of the cloud computing model is that it
makes infrastructure provisioning very rapid. With cloud computing, the
provisioning of resources can be achieved in just a couple of mouse clicks
and within a few seconds or minutes, which is in contrast to the traditional
on-premises IT model, where clients need not go through a tiresome
bureaucratic process and wait for days or weeks to get the requested
infrastructure resources.

10
Chapter 1 Welcome to The World of Containers!

Virtualization and distributed architecture are enablers of cloud


computing. And, containerization and the microservices architecture are
complementary technologies that, when combined, provide a very cost-­
effective, scalable, and fault-tolerant application ecosystem.

What Are the Types Of Cloud Deployment Models?


Broadly, cloud deployment models can be categorized as follows:

• Public cloud model

• Private cloud model

• Hybrid cloud model

A public cloud is a cloud deployment model in which a cloud provider


makes all the computing resources available to users over the Internet.
Google Cloud by Google, Azure by Microsoft, and AWS by Amazon are
examples of public clouds. A private cloud is a cloud deployment model
in which a cloud provider makes all computing resources available to the
client on-premises in the client’s data center. Many companies opt for
private clouds for security and regulatory compliance reasons. A hybrid
cloud deployment model is a cloud deployment model that combines both
public clouds and private clouds.

What Are the Types of Cloud Services?


Broadly, cloud deployment models can be categorized as follows:

• Infrastructure as a Service (IaaS)

• Platform as a Service (PaaS)

• Software as a Service (SaaS)

In IaaS, complete infrastructure—storage, networking, physical


servers, etc.—is rented, and the client is responsible for setting up and
managing everything. In PaaS, infrastructure is managed by the cloud

11
Chapter 1 Welcome to The World of Containers!

provider, and the client gets an environment for developing and delivering
applications. In SaaS, the client gets on-demand access to ready-to-use
applications over the Internet.

What Is Containerization?
Containerization is a form of virtualization, because they both allow for full
isolation of applications from underlying infrastructure so that they can
be operational in different types of environments. With containerization,
we can bundle all of the components of an application needed to run the
code into a single lightweight executable called a container and run it in an
isolated user space on the same shared operating system.
The idea of containerization and process isolation has been around
for a long time, but the architectural shift to microservices and the release
of the open-source Docker Engine accelerated the widespread adoption
of this idea. Another major reason for the widespread adoption of
containerization is that it makes the application totally portable. Once we
have packaged all the components of an application into a single container
image, we can run this image in any environment as long as there is a
container runtime in that environment. The way the JVM makes the Java
platform independent, similarly containerization makes applications
“write once and run anywhere.”
There are many use cases for containerization, but the most popular
ones are microservices and multicloud deployment.

What Is the Open Container Initiative?


The Open Container Initiative (OCI) is an open governance framework
created specifically to develop an open and common industry standard for
container runtimes.

12
Chapter 1 Welcome to The World of Containers!

The rapid growth in interest and use of container-based solutions


has necessitated the development of container technology standards
and methods to bundle the application code. Docker and other
container industry leaders established the OCI in June 2015. The runtime
specification, image specification, and distribution specification are
the three specifications that currently make up the OCI. The image
specification outlines standards for the creation of a container image. The
OCI image specification contains an image index, an image manifest, a set
of file system layers, and a configuration. The distribution specification
outlines how to facilitate and standardize the distribution of content.
The advantage of the OCI standard is that you can easily move your
application between OCI-compliant container runtimes.

 hat Are the Advantages of Containerization


W
Over Virtualization?
Figure 1-4 illustrates the advantages of containerization over virtualization,
which we will explore in detail in this section.

Figure 1-4. Containerization versus virtualization

13
Chapter 1 Welcome to The World of Containers!

These are the advantages:

• Portability: One of the biggest advantages of


containerization over virtualization is portability.
A containerized application will run the same in
all environments, whether it is development or
production, as long as there is an underlying container
runtime running in that environment. And that is
because a containerized application has everything it
needs to run. This is much like how the JVM makes the
Java code platform independent.

• Isolation and allocation: In the case of virtualization,


you cannot put applications in certain resource
boundaries. But with containerization, you can specify
the resource limits of containers, thereby putting
resource boundaries on the application itself. Please
note that here the comparison is between virtualization
and containerization technologies to provide resource
limits directly on the applications; this comparison is
not with runtimes like JVM, which provide an option
to limit memory usage. And even if we compare it with
runtimes like the JVM, with JVM there is no option
to specify CPU and other resource limits, which is
possible in the case of containerization.

• Better fit for microservices: Containerized applications


are an excellent fit for the microservice architecture
because we can deploy and scale containers
individually. So, with the microservices architecture,
we can decompose our application into smaller
services and run each of these services inside a
container that can be scaled up or down as per request
traffic requirements.

14
Chapter 1 Welcome to The World of Containers!

• Scalability and speed: Containers can be created,


replicated, or destroyed much faster as compared to
hypervisors because the OS kernel is shared among
applications. Please note that how fast a container
can start will depend on the size of the application,
but typically containers can start within a few seconds
while virtual machines can take a couple of minutes.
And since containers are lightweight and faster to re-­
create, scaling containers is much easier than scaling
virtual machines.

• Resource efficient: Since containers (container images,


to be more precise) include only the applications
really needed to run, they are much smaller in size as
compared to a virtual machine, and this allows the
underlying machine (whether physical or virtual) to
run more containers on the same server capacity.

• Fault isolation: Each container running on a


container runtime runs in isolation from other
running containers; therefore, if one container fails,
then it doesn’t impact the working of other running
containers. In fact, this is an advantage in the sense
that if we have an e-commerce application with three
services (in turn, containers): account, billing, and
catalog. If for whatever reason the account container
has crashed, then users can still do cataloging and
billing. Please note that fault isolation is not the same
as fault tolerance. Containers themselves don’t provide
fault tolerance, but container orchestration systems like
Kubernetes do.

15
Chapter 1 Welcome to The World of Containers!

• Automation: Designing an automation solution that


would work seamlessly across different platforms and
resources is easier with containerization as compared
to virtualization.

 an Containerized Applications Run


C
on a Cloud Infrastructure?
Yes. Containerized applications don’t depend on the type of hardware
infrastructure. Underlying hardware infrastructure can be our own laptop
or cloud infrastructure spread across multiple data centers.

What Is the Microservices Architecture?


Microservices (or the microservices architecture) is a cloud-native
architectural approach in which an application is decomposed into many
loosely coupled and independently deployable services.
The microservices architecture has many characteristics, but the
following are the most essential characteristics of any microservices
architecture-based application:
• Each application service should be independently
deployable.

• There should not be any tight coupling between the


services of the application. This basically means that if
a change is needed in one service, then another service
should not be significantly impacted.

• Each service should be built around a single business


function or use case.

16
Chapter 1 Welcome to The World of Containers!

• Each service should be designed for failure without


bringing down the complete application. This basically
means that if a service crashes or fails, then the entire
application should not come down.

• Each service should communicate with the other using


a lightweight protocol like HTTP and a lightweight data
exchange format like JSON.

• Preferably, all interfacing with all the services should


pass through some API Gateway.

Figure 1-5 is a simple graphical depiction of the microservices


architecture.

Figure 1-5. Microservices architecture

The microservices architecture has many advantages, but the following


are some fundamental ones:

• Easier to build: The whole idea behind the


microservices architecture is to break down a big
application into smaller pieces, so it gets easier to build
smaller pieces. Different teams can work on each piece
with a total focus on a single business function.
17
Chapter 1 Welcome to The World of Containers!

• Easier to deploy: Since services in a microservices


architecture are smaller, they will have fewer
environmental dependencies and other complications
related to deploying a large application, making them
easier to deploy.

• Easier to maintain: If a bug arises in a large application,


then it can become a major challenge because of so
many moving parts, but if the application size is small,
then it becomes easier to find issues and maintain the
application.

• Higher performance and scalability: Most commonly,


each of the services of the microservices architecture
gets deployed on a containerized platform, and
containers inherently provide performance and
scalability.

Microservices vs. Monolithic


The microservices architectural approach is in contrast to the
monolithic architectural approach, in which everything is bundled into
one application and shipped as a single deployable unit. The biggest
disadvantage of monolithic architectural approach is that if one part of the
application fails or crashes, it brings down the entire application because
everything is tightly coupled. The microservices architecture remedies this
problem by promoting cohesion and loose coupling.

Microservices vs. SOA


The microservices architectural approach is also contrasted with the
service-oriented architecture (SOA) architectural approach, in which
reusable components are designed via service interfaces. The central
component of SOA architecture that performs integrations between

18
Chapter 1 Welcome to The World of Containers!

applications is an enterprise service bus (ESB). The biggest disadvantage


of this architectural approach is that over time, the system can become
more and more complex and end up with several interdependencies
between services. To sum up, SOA architecture is around integration and
has enterprise-wide scope, while microservices are around application
design architecture and have application-wide scope.

 ow Is Containerization Different from the


H
Microservices Architecture?
I think it is incorrect to compare containerization and the microservice
architecture. Containerization and the microservices architecture are not
competing technologies but rather complementing technologies. Using
a microservices architecture, an application is broken down into smaller
services, and then each service is deployed in a separate container that can
be scaled up and down as per the requirements.
A container is a key component of the microservices architecture, and
other key components and technologies are Kubernetes, API gateways,
and messaging.

What Is the Future of Containerization?


Even though containerization has taken center stage in the last decade,
I still think the future of containerization is just getting warmed up.
Eventually, almost all applications (whether enterprise applications or
small applications) will get containerized to take maximum advantage
of the cost benefits offered by the cloud computing model and ease of
application maintenance and scalability.
Many prominent technology research firms have done numerous polls,
and all of the results agree that containerization is the way of the future.

19
Chapter 1 Welcome to The World of Containers!

Understanding Key Container Technologies


In this section, we will understand two key container technologies: Docker
and Kubernetes. We will also discuss Red Hat’s OpenShift Container
Platform (OCP) and what is it means to be “cloud-native.”

What Is Docker?
Docker is an open-source platform that allows you to develop, run, and
ship containerized applications. Simply put, Docker is a container runtime
that enables you to package all your application code along with its
dependencies (external as well as system) into an image and then create
containers by running the image.
A container runtime is a piece of software that knows how to run a
container from a container image. Docker is one of the most popular
container runtimes. There are other popular container runtimes, such as
the following:

• CRI-O: A Kubernetes Container Runtime Interface


(CRI) implementation that makes it possible to use
runtimes that are compliant with OCI standards.

• containerd: A Cloud Native Computing Foundation


(CNCF) project and another open-source container
runtime, which was introduced as an alternative
to Docker with its significant focus on simplicity,
robustness, and portability.

Before Kubernetes v1.24, there was a direct integration with Docker


Engine using a component named Dockershim. Kubernetes v1.27 requires
that you use a runtime that conforms to the Container Runtime Interface.

20
Chapter 1 Welcome to The World of Containers!

What Is Kubernetes?
Kubernetes allows you to deploy, scale, and manage containerized
applications in a regulated and automated manner. Simply put,
Kubernetes is a container orchestrator. Within the technical community,
Kubernetes is also referred to as K8s. Using container runtimes like
Docker, you can package your code, dependent libraries, and runtime into
an image and run it to create containers, but containers are transient; if
your container crashes, you will need to ensure that another container
is created automatically, so these are the kinds of things that a container
orchestrator like Kubernetes does. Kubernetes also enables you to do
resource management, group the containers to create clusters, etc.
There are many technologies and projects that are built on Kubernetes,
for example, Kubeflow. The Kubeflow project aims to simplify the overall
design, portability, and scalability of machine learning (ML) workflow
deployments on Kubernetes.

What Is Red Hat’s OpenShift Container Platform?


The OpenShift Container Platform (OCP) is a highly scalable Kubernetes
platform by Red Hat that allows you to develop and run containerized
applications. Using OCP, you can quickly scale an OCP cluster from a
handful of servers to hundreds of thousands of servers.
The OpenShift Container Platform has its foundation in Kubernetes,
and it integrated very well with other Red Hat technologies, which allows
you to quickly extend and move your application from a single server
or VM to any cloud environment. The OCP provides enterprise-level
enhancements to Kubernetes, such as the following:

• Hybrid cloud deployments: You can deploy your OCP


clusters in a variety of cloud deployment models.

21
Another random document with
no related content on Scribd:
This section includes the Spider-crabs and related genera, in which
the carapace is triangular, with the apex in front formed by a
sharply-pointed rostrum. There are two chief series, the one
comprising the Spider-crabs, with much elongated walking legs, e.g.
the huge Maia squinado of European seas, the yet more enormous
Macrocheira kämpferi from Japan, supposed to be the largest
Crustacean in existence, and sometimes spanning from outstretched
chela to chela as much as eleven feet, and the smaller forms, such as
Inachus, Hyas, and Stenorhynchus, which are so common in
moderate depths off the English coasts. The other series is
represented by genera like Lambrus (Fig. 133), in which the legs are
not much elongated, but the chelipedes are enormous.
The Spider-crabs do not burrow, and their respiratory mechanism
is simple; but since they are forms that clamber about among weeds,
etc., upon the sea-bottom, they often show remarkable protective
resemblances to their surroundings, which are not found in the
burrowing Cyclometopa. Alcock[156] gives a good account and figure
of Parthenope investigatoris, one of the short-legged Oxyrhyncha,
the whole of whose dorsal surface is wonderfully sculptured to
resemble a piece of the old corroded coral among which it lives.
But besides this, the long-legged forms, such as Inachus, Hyas,
etc., have the habit of planting out Zoophytes, Sponges, and Algae
upon their spiny carapaces, so that they literally become part and
parcel of the organic surroundings among which they live. It may,
perhaps, be wondered what are the enemies which these armoured
Crustacea fear. Predaceous fish, such as the Cod, devour large
quantities of Crabs, which are often found in their stomachs; and
Octopuses of all sorts live specially upon Crabs, which they first of all
paralyse by injecting them with the secretion of poison-glands
situated in their mouth. The poison has been recently found by Dr.
Martin Henze at Naples to be an alkaloid, minute quantities of
which, when injected into a Crab, completely paralyse it. When the
Crab is rendered helpless the Octopus cuts out a hole in the carapace
with its beak, and sucks all the internal organs, and then leaves the
empty shell.
Many of the Oxyrhyncha are found in the abysses; among them are
Encephaloides armstrongi (Fig. 132), dredged by Alcock from below
the 100–fathom line in the Indian Ocean, which has the gill-
chambers (G) greatly swollen and enlarged to make up for the
scarcity of oxygen in these deep regions.
Fam. 1. Maiidae.—The
chelipedes are not much larger
than the other legs, but are very
mobile. Orbits incomplete. A very
large family, including all the true
Spider-crabs, very common in the
Atlantic and Mediterranean
littoral. Inachus, Pisa, Hyas,
Stenorhynchus, Maia,
Encephaloides (Fig. 132).
Fam. 2. Parthenopidae.—
The chelipedes are much larger
than the other legs. Orbits
complete. Lambrus (Fig. 133),
Parthenope.
Fig. 132.—Encephaloides armstrongi, Fam. 3.
× 1. The long walking legs are omitted. Hymenosomatidae. The
C, Great chela; G, one of the greatly carapace is thin and flat; the
swollen gill-chambers. (After Alcock.) chelipedes are neither very long

nor especially mobile. There are


no orbits, and the male openings
are on the sternum. Characteristic
of the Antarctic seas.
Hymenosoma, Trigonoplax.

Fig. 133.—Lambrus miersi, × 1. (After


Milne Edwards and Bouvier.)

Tribe 5. Catometopa.
These Crabs resemble the Cyclometopa in general appearance, but
the carapace is very square in outline, and its margins are never so
well provided with spines as in the Cyclometopa. The position of the
male genital openings is peculiar, since they lie upon the sternum,
and are connected with the copulatory appendages upon the
abdomen by means of furrows excavated in the sternum. The
Catometopa are either littoral or shallow water forms, or else they
live entirely on land. The Grapsidae are marine Crabs, Pachygrapsus
marmoratus (Fig. 134) at Naples being exceedingly common on
rocks at high-water mark, over which it scuttles at a great rate; in the
Mediterranean it takes the place of our common Garcinus maenas,
which is not found there.
Among the land genera are
Ocypoda, Gelasimus, and
Gecarcinus of tropical lagoons
and coastal swamps. Ocypoda
often occurs in vast crowds in
these regions, and digs burrows
in the sand.
Gelasimus (Fig. 135) is
remarkable for the enormous size
of one of the chelipedes, generally
Fig. 134.—Dorsal view of Pachygrapsus
the right, in the male, which may
marmoratus, × ⅓. (From an original actually exceed in size the rest of
drawing prepared for Professor the body. It is not known what
Weldon.) purpose this organ serves in the
various species. In Gelasimus it is
supposed that the male stops up
the mouth of the burrow with it when he and the female are safely
inside. It is also used as a weapon in sexual combats with other
males; but Alcock, from observations made in the Indian Ocean,
believes that the males use it for exciting the admiration of the
females in courtship, as the huge chela is bright red in colour, and
the males brandish it about before the females as if displaying its
florid beauty.
The species of Ocypoda are exclusively terrestrial, and cannot live
for a day in water. The gills have entirely disappeared, and the
branchial chambers are converted into air-breathing lungs with
highly vascular walls, the
entrances into which are situated
as round holes between the bases
of the third and fourth pairs of
walking legs. As their name
implies, they can run with
astonishing rapidity, and they
seem to be always on the alert,
directing their eyes, which are
placed on exceedingly long stalks,
in all directions.
Some of the Grapsidae, e.g.
Aratus pisonii, are partially
adapted for life on land. Fritz
Müller, in his Facts for Darwin,
alludes to this creature as “a
charming lively crab which
ascends mangrove bushes and
gnaws their leaves.” The carapace
can be elevated and depressed
posteriorly, apparently by means
of a membranous sac, which can
be inflated by the body-fluids.
This Crab retains its gills and can
breathe under water in the
ordinary way.
A great many other
Catometopa are land-crabs; but
we may specially mention the
genus Gecarcinus, related to the Fig. 135.—Gelasimus annulipes, × 1. A,
marine Grapsidae, which has Female; B, male. (After Alcock.)
representatives in the West Indies
and West Africa. The Crabs of this genus may live in sheltered
situations several miles from the sea, but in spring the whole adult
population rushes down in immense troops to the shore, where
breeding and spawning take place; and when this is completed they
migrate back again to the land. The young pass through the normal
larval stages in the sea and then migrate inland.[157]
Fam. 1. Carcinoplacidae.—The carapace is rounded and
broader than long, usually with toothed front margin. The orbits and
eyes are normal, and not much enlarged. Geryon, in the deep littoral
of the northern hemisphere. Euryplax, Panoplax, etc., in the
American coastal waters. Typhlocarcinus, etc., in the Indo-Pacific.
Fam. 2. Gonoplacidae.—The carapace is square, with the
antero-lateral corners produced into spines. The orbits are
transversely widened, and the eye-stalks long. Gonoplax, widely
distributed in the littoral zone. G. rhomboides in British and
European seas.
Fam. 3. Pinnotheridae.—Carapace round, with indistinct
frontal margin. Orbits and eyes very small, often rudimentary. The
members of this family live symbiotically or parasitically in the shells
of living Bivalve Molluscs, corals, and wormtubes in all seas except
the Arctic. Pinnotheres pisum is fairly commonly met with off the
English coasts in the mantle-cavity of Cardium norwegicum.
Fam. 4. Grapsidae.[158]—Carapace square, the lateral margins
either strictly parallel or slightly arched. The orbits and eyes are
moderately large, but the eye-stalks are not much lengthened.
Littoral, fresh-water, and land. Pachygrapsus marmoratus (Fig.
134), the common shore-crab of the Mediterranean. Sesarma, with
fresh-water and land representatives in the tropics of both
hemispheres. Cyclograpsus, marine in the tropical littoral.
Fam. 5. Gecarcinidae.—Carapace square, but much swollen in
the branchial region. Orbits and eyes moderately large. Typically
land forms, which only occasionally visit the sea or fresh water.
Cardisoma is a completely circumtropical genus, with species in
tropical America, West and East Africa, and throughout the Indo-
Pacific. Gecarcinus in West Indies and West Africa.
Fam. 6. Ocypodidae.—Carapace square or rounded, generally
without teeth on the lateral margins. The orbits transversely
lengthened, eye-stalks usually very long. The members of this family
generally inhabit the mud-flats and sands of tropical coasts; in the
southern hemisphere they extend far into the temperate regions.
Macrophthalmus, with numerous species, in Indo-Pacific.
Gelasimus (Fig. 135), in the tropics of both hemispheres. Ocypoda,
with similar distribution.
CHAPTER VII
REMARKS ON THE DISTRIBUTION OF
MARINE AND FRESH-WATER CRUSTACEA

A. Marine.

The great majority of the Crustacea are inhabitants of the sea.


From a Zoogeographical point of view we divide the sea into three
chief regions, each of which is characterised by a special kind of
fauna—the littoral, the pelagic, and the abyssal regions.
The littoral region, which comprises all the shallow coastal waters
down to about 100 fathoms, varies very greatly in its physical
character according to the nature of the coast, its geological
constitution, latitude, etc., but, on the whole, it is characterised by
variability of temperature and salinity, by the presence of sunlight,
and by the continuous motion of its waves. On the shores of the large
oceans this region is also greatly affected by the tides. It is inhabited
by a vast assemblage of Crustacea, all of which are dependent upon a
solid substratum, either of rock or sand, or of vegetable or animal
growth, upon which they may wander in search of food, or in which
they may hide themselves. In consequence, the character of the
Crustacea on any shore is largely determined by its geological nature.
Although a certain number of Entomostraca such as Copepoda
(Harpacticidae and Cyclopidae), Ostracoda (Cypridae and
Cytheridae), and a few Operculata are littoral in habit, it is the
Malacostraca, from their larger size and variety of form, which give
the character to coastal waters.
On rocky coasts, especially those affected by tides, a great many
kinds of Shore-crab are found, which hide at low tide in the rock-
pools and under stones. Carcinus maenas is characteristic of the
rocky coasts of the North Sea, while it is replaced in warmer seas and
all round the tropics by Crabs of the family Grapsidae, which are
typical rock-livers, and exceedingly agile in clambering over tide-
washed rocks. Porcellanidae are also very common under stones at
low tide on rocky beaches. Such typical Shore-crabs as these are
remarkably resistant to desiccation, and can live out of water for an
astonishing time; nor do they require a change of water provided
they have access to the air. The edible crab (Cancer pagurus) and the
lobsters (Homarus and Palinurus) are dependent on rocks, but they
rarely come close in-shore, preferring depths of a few fathoms.
Sandy coasts are preferred by Shrimps and Prawns, which haunt
the shallow coastal waters in shoals; and in the sand are found all the
Crabs whose respiratory mechanism is specially adapted for life in
these regions, e.g. Hippidea or Mole-crabs, Corystes, Matuta,
Calappa, etc.
Characteristic of sandy bottoms are also the Thalassinidea, such as
Callianassa, which excavate galleries in the sand. On tropical sandy
shores various species of Ocypoda and Gelasimus are conspicuous,
which have deserted the sea, and live in burrows which they excavate
on the shore. Gelasimus is especially abundant in the muddy sand of
tropical mangrove swamps.
Besides the rocky and sandy coasts we must distinguish the muddy
shores and bottoms which support a large amount of vegetable and
animal growth. These, besides harbouring the greater number of
Amphipods and Isopods, are also the natural home of the Dromiacea
and Oxyrhyncha, or Spider-crabs, among which the habit is common
of decking themselves out with pieces of weed or animal growth in
order to harmonise better with their surroundings. Pagurids are also
especially abundant in the deeper waters of these coasts.
Coral-reefs support a characteristic Crustacean fauna. In the
growing coral at the reef-edge a number of small Cyclometopa are
found, e.g. Chlorodius, Actaea, Xantho, which are finely sculptured
and often coloured so as to harmonise with the coral. Alpheidae also,
Shrimp-like Macrura with highly asymmetrical claws, which can emit
a sharp cracking sound with the larger claw, are commonly found in
pools on the reef. In the coralshingle formed by abrasion from the
reef-edge at a few fathoms depth, Leucosiidae are found, in which,
again, respiratory mechanisms for filtering sand from the gills are
present.
Besides the geological nature of the coast, latitude has a very
important bearing upon the distribution of littoral Crustacea.
Indeed, the present distribution of littoral Crustacea appears to be
far more determined by the temperature of the coastal waters than
by the presence of any land-barriers, however formidable. We may
distinguish an Arctic, Antarctic, and Circumtropical zone.
The Arctic zone includes the true Arctic seas, and stretches right
down through boreal regions towards the sub-tropical seas. Almost
all the truly Arctic forms penetrate fairly far south, the Arctic seas
being characterised more by the absence of temperate forms than by
the presence of forms peculiar to itself. At the same time it must be
noted that the individuals from the coldest regions often grow to an
enormous size, a characteristic which is physiologically unexplained.
A great many of the Crustacea characteristic of this region are
circumpolar, i.e. they are not restricted in range to either the Atlantic
or Pacific. This is especially true of the extremely northern types, e.g.
Crangonidae and Hippolytidae, but it is also true of a number of
Crustacea which do not now occur as far north as Greenland or
Bering Strait, so that there is no longer any free communication for
them between Pacific and Atlantic. This gives rise to a discontinuous
distribution in the two oceans, exemplified in the common Shrimp,
Crangon vulgaris, which is found on the temperate European coasts
and on the Pacific coasts of Japan and Eastern America. The same is
true of Eupagurus pubescens and E. bernhardus.
At the same time the boreal Atlantic and Pacific have their peculiar
forms. Thus the European and American Lobsters are confined to the
Atlantic, while the North Pacific possesses a very rich array of
Lithodinae, which cannot be paralleled in the Atlantic.
We may explain the community of many littoral forms to both the
North Atlantic and Pacific coasts by the continuous coast-line uniting
them, which in former times possibly did not lie so far north, or else
was not subjected to so rigorous a climate as now.
In the Antarctic zone we are presented with very different
relations, since the great continents are drawn out to points towards
the south, and are isolated by vast tracts of intervening deep sea.
Nevertheless, certain littoral forms are circumpolar, e.g. the
Palinurid Iasus and the Crabs Cyclograpsus and Hymenosoma. The
genus Dromidia is common to Australia and South Africa, though it
is apparently absent from South America.
The Isopod genus Serolis is confined to Antarctic seas. The
majority are littoral species, and they are distributed round the
coasts of Patagonia, Australia, and Kerguelen in a manner that
certainly suggests a closer connection between these shores in the
past. These facts are, on the whole, evidence in favour of the former
existence of an Antarctic continent stretching farther north and
connecting Australia, Africa, and S. America—a supposition that has
been put forward to account for the distribution of the Penguins,
Struthious birds, Oligochaets, Crayfishes, etc., in these regions (see
pp. 215–217).
In considering the Arctic and Antarctic faunas the supposed
phenomenon of bipolarity must be mentioned, i.e. the occurrence of
particular species in Arctic and Antarctic seas, but not in the
intermediate regions. This discontinuous type of distribution was
upheld for a variety of marine animals by Pfeffer, Murray, and
others, but it has been very adversely criticised by Ortmann.[159] As
far as the Arctic and Antarctic Decapod fauna in general are
concerned, the north polar forms are quite distinct from the south
polar. Typical of the former are Hippolyte, Sclerocrangon, Hyas,
Homarus, etc.; of the latter, Hymenosoma, Dromidia, Iasus. It
appears, however, that in certain special cases, bipolarity of
distribution may be produced owing to the operation of peculiar
causes. Two such cases seem to be fairly well established. Crangon
antarcticus occurs at the two poles, and apparently not in the
intermediate regions; but, as Ortmann points out, it is represented
right down the West American coast by a very closely related form, C.
franciscorum. The waters on the tropical western coasts both of
Africa and America are exceedingly cool, and it appears that in this
way the Crangon may have migrated across the tropical belt, leaving
a slightly modified race to represent it in this intermediate region.
The other case of bipolarity is afforded by the “Schizopod,”
Boreomysis scyphops, which occurs at both poles, but is not known
from the tropics. This is a pelagic species, and we know that the
Mysidae often descend to considerable depths. We also know that
the Mysidae are dependent on cold water, only occurring in boreal or
temperate waters. We may safely suppose, therefore, that the
migration of this species has taken place by their forsaking the
surface-waters as the tropics were approached, and passing down
into the depths where the temperature is constantly low even in the
tropics.
The dependence of Crustacea upon the temperature of the water is
also illustrated by the distribution of the Lithodinae. The
headquarters of this family are in the boreal Pacific, with a few
scattered representatives in the boreal Atlantic. The cool currents on
the western coasts of America, however, have permitted certain
forms to migrate as far south as Patagonia, where they still have a
littoral habit. In the tropical Indo-Pacific, where a few species occur,
they are only found in deep waters. Thus at these various latitudes,
by following cool currents or migrating into deep water, they are
always subjected to similar conditions of temperature. The same
kind of thing is observed in Arctic seas, where deep-sea forms are apt
to take on secondarily a littoral habit owing to the temperature of the
depths and of the shore being the same.
Despite the impassable barriers of land which now sever the
tropical oceans, we can yet speak of a circumtropical zone
possessing many species common to its most widely separated parts.
Such circumtropical species, occurring on both the Atlantic and
Pacific coasts of tropical America, on the West African coast, and in
the Indo-Pacific, are various Grapsidae, Calappa granulata and its
allies, and certain Albunea. The most striking instance of all is that of
the Land-crabs. Of Ocypoda, the greater number of species occur in
the Indo-Pacific, but representatives are also found on the tropical
Eastern and Western American coasts and on the West African coast,
and the same is true of Gelasimus. The genus Cardisoma, belonging
to a different group of Land-crabs, is also typically circumtropical.
For this community of the circumtropical species we may certainly
advance in explanation the comparatively recent formation of the
Isthmus of Panama. Besides the resemblance of the Crustacea on the
east and west coasts of the isthmus, we have an actual identity of
species in several cases, e.g. Pachycheles panamensis and Hippa
emerita, and the same thing has been observed for the marine fish.
Another connexion, at any rate during early tertiary times, which
probably existed between now isolated tropical coasts, was across the
Atlantic from the West Indies to the Mediterranean and West African
coasts. Numerous facts speak for this connexion. Species of
Palinurus and Dromia occur in the West Indies and the
Mediterranean, which only differ from one another in detail, and a
connexion between these two regions has been urged from the
minute resemblances of the late Cretaceous Corals of the West Indies
with those of the Gosau beds of S. Europe, and also of the Miocene
land-molluscs of S. Europe with those at the present time found in
the West Indies.
To account, then, for the present distribution of littoral Crustacea
we must imagine that great changes have taken place during
comparatively recent times in the coast-lines of the ocean, but the
guiding principle in both the past and present has been temperature,
and this factor enables us, despite the immense changes in the
configuration of the globe that must have taken place, to divide the
coasts latitudinally into Arctic, Antarctic, and Circumtropical zones.
Pelagic Crustacea belong chiefly to the Copepoda (Calanidae,
Centropagidae, Candacidae, Pontellidae, Corycaeidae), a few
Ostracoda (Halocypridae and Cypridinae), and among Malacostraca
a few Amphipoda (Hyperina), some “Schizopoda,” and among
Decapoda only the Sergestidae, if we except the few special forms
which live on the floating weeds of the Sargasso Sea, e.g. the Prawns
Virbius acuminatus and Latreutes ensiferus, and the Brachyura
Neptunus sayi and Planes minutus. Besides these Crustacea which
are pelagic as adults, there is an enormous host of larval forms, both
among Entomostraca and Malacostraca, which are taken in the
surface-plankton.
In dealing with the Copepoda we have already mentioned the vast
pelagic shoals of these organisms which occur at particular times of
the year, and have an important influence on fishing industries.
Anomalocera pattersoni (Fig. 27, p. 60) is a good instance of this. It
is a large Heterarthrandrian, about 3 mm. long, with the body of a
fine bluish green colour; it has a remarkable power of springing out
of the water, so that a shoal has the appearance of fine rain upon the
surface of the sea. It occurs in the open Atlantic and Mediterranean,
but comes into the coasts during violent storms; the Norwegian
fishermen hail its presence in the fjords as the sign of the approach
of the summer herring.
It was Haeckel[160] who first clearly distinguished between “neritic”
plankton, the species of which have their centres of distribution in
shallow coastal waters and die out gradually as the open ocean is
approached, and “oceanic” plankton which is habitually found in the
open sea, and though it may invade the coasts is not dependent on
the sea-bottom in any way. It appears that although these two kinds
of plankton may get mixed up by currents and storms, they are
always recruited by new generations from the neritic or oceanic
stations proper to each kind.
Common oceanic species, found chiefly in the open Atlantic and in
the North Sea, are Anomalocera pattersoni, Calanus finmarchicus,
Centropages typicus, Metridia lucens, Oithona plumifera, etc.
Common neritic species in the Channel and other coastal waters are
Centropages hamatus, Euterpe acutifrons, Oithona nana, Temora
longicornis, etc. It was found by Gough[161] that although the true
oceanic species invade the Channel from the open Atlantic to the
west, they become rarer and rarer as they advance up the Channel.
Thus the plankton midway between the Lizard and Ushant at all
times of year is about 70 per cent. oceanic, while at the line drawn
from Portland to the Cap de la Hague it is about 35 per cent.
Seasonal changes in the salinity of the Channel water, chiefly due to
the influx of oceanic water from the Atlantic, as observed by
Matthews,[162] do not clearly influence the distribution of oceanic and
neritic forms. The influx of highly saline water from the Atlantic was
most marked during the winter months up to February. From
February to May the highly saline water receded, and during the
summer months at the line drawn between Portland and the Cap de
la Hague the salinity was rather low. This was increased in
November by a patch of oceanic water being cut off from the main
mass and passing up Channel, and it is noteworthy that during this
month the highest percentage of oceanic forms was taken in the
plankton of this region.
Calanus finmarchicus affords a clear instance of the way in which
the plankton may be carried about for great distances by means of
currents. This species has its home in the subarctic seas, but is
carried down in the spring by the East Icelandic Polar stream to its
spawning-place south of Iceland; the enormous shoals produced
here are carried back, continually multiplying, along the coasts of
Norway during the summer and autumn.
Besides these great migrations, the plankton organisms perform
daily movements, the majority of the Crustacea avoiding the surface
during the day, and often going down to as much as seventy fathoms
or more, and only coming up to the surface at night. Others,
however, e.g. Calanus finmarchicus, behave in the converse manner,
preferring the sunlit surface to swim in.
Owing to their dispersal by means of oceanic currents the pelagic
Crustacea do not offer any very striking features in regard to their
distribution, and the possibility of always finding congenial
temperatures by passing into the upper or under strata of water
enables them to live in almost all seas. The tropical species of
Sergestidae are mostly circumtropical, i.e. unhindered by the present
barriers of land.
The Abyssal regions of the sea contain many of the most
interesting Crustacea. Families entirely confined to the abyss are the
Eryonidae, Pylochelidae, and certain Caridean Prawns
(Psalidopodidae, etc.), but there are a great number of normally
littoral genera which have representatives in deep water. If we draw
the limit between the littoral and abyssal regions at about 200
metres, we can characterise the latter as absolutely dark except for
the presence of phosphorescent organisms, with the temperature at a
little above zero, and with a comparative lack of dissolved oxygen in
the water. These conditions bring about remarkable modifications in
the structure and life-histories of the inhabitants of the deep sea; we
have already touched on the modifications of the visual organs and
on the presence of phosphorescence in many of the animals; other
points to be noticed are the usually uniform yellowish or bright red
coloration, the frequent delicacy of the tissues without much
calcification, variations in the structure of the breathing organs, e.g.
in Bathynomus giganteus and Encephaloides armstrongi, and the
loss of the larval development. Owing to the similarity of conditions
in the deep sea all over the globe most of its inhabitants are
universally distributed. It is also a striking fact that species are found
in the deep sea of the tropics whose nearest allies occur, not in the
littoral seas of the tropics, but in those of the temperate region. This
fact has already been alluded to in dealing with the distribution of
the Lithodinae. Alcock[163] remarks that between 50–500 fathoms in
the Indian Ocean are found Crabs such as Maia, Latreillia, and
Homola, regarded as characteristic of the north temperate seas; the
lobster Nephrops andamanica, taken at 150–400 fathoms, is closely
allied to the Norwegian N. norwegica; and nine species of
“Schizopoda,” which are certainly temperate forms, occur in the
Indian Ocean at depths of 500–1750 fathoms.

B. Fresh-Water.[164]

If we except the Crayfishes and River-crabs, the Crustacean fauna


of running water is exceedingly poor, but in all standing fresh-water,
from the smallest pond to the large lakes and inland seas, Crustacea,
especially Entomostraca, are abundant and characteristic, and form
an important item in the food of fresh-water fishes. In small ponds a
vast assemblage of Cladocera is met with; these animals multiply
with great rapidity by parthenogenesis, especially during spring and
summer, but on the advent of untoward conditions sexual
individuals are produced, which lay fertilised winter-eggs which lie
dormant until favourable conditions again arise. As Weismann first
pointed out, the frequency with which sexual individuals are
produced in the various species is closely correlated with the liability
of the water in which they live to dry up; so that the Cladocera which
inhabit small ponds usually have at least two “epidemics” of sexual
individuals, one during early summer and the other before the onset
of winter.
Besides Cladocera, the Phyllopoda (e.g. Apus, Artemia, etc.)
inhabit small pools; and also a great number of Cyclopidae. Of the
other fresh-water families of Copepoda, viz. Centropagidae and
Harpacticidae, inhabitants of small pieces of water are Diaptomus
castor, as opposed to the other species of Diaptomus which are
pelagic, and a number of Harpacticidae (Canthocamptus), the
members of this family living in the weed or mud of either small
ponds or else on the shores of the larger lakes. The greater number of
Ostracoda are found in similar situations.
A district like the Broads of Norfolk, which consists partly of
slowly-moving streams and partly of extensive stretches of shallow
water, supports a Crustacean fauna intermediate in character
between that found in small ponds and the truly pelagic fauna
characteristic of deep lakes. A very complete list of the Crustacea of
the Norfolk Broads, with an interesting commentary on their
distribution, is given by Mr. Robert Gurney.[165] We miss here the
pelagic Cladocera, such as Leptodora, Bythotrephes, Holopedium,
etc., which form so characteristic a feature of large lakes; at the same
time, besides a rich development of the Cladocera, Cyclopidae, and
Harpacticidae, which haunt the weeds and mud of shallow waters,
we find such species as Polyphemus pediculus and Bosmina
longirostris among Cladocera, which are otherwise confined to large
bodies of water, and a few pelagic Diaptomus, e.g. D. gracilis. The
fauna is also complicated in this district by the proximity to the sea
and the frequently high salinity of the water, which allows a number
of typically marine Copepods to pass up the estuaries and
intermingle with typically fresh-water species; such are Eurytemora
affinis among the Centropagidae, and several species of
Harpacticidae (see p. 62).
The large lakes of the world, such as the continental lakes of
Europe and America, or of our own Lake District, reproduce on a
small scale the varied conditions which appertain to the ocean—as in
the ocean, we can recognise in these lakes a littoral, a pelagic, and an
abyssal region. Our knowledge of the physiography of lakes is largely
due to the classical work of Forel,[166] and the following account of the
physical conditions in the various regions is condensed from his
book.
The littoral region is sharply marked off from the others by the
relative instability of its physical conditions, owing to the agitation of
its waters, the affluence of streams and drainage, and the constant
changes of temperature. The water in this region generally contains a
good deal of solid matter in suspension, while the shelving banks of
the lake support a wealth of vegetable growth, both of Algae and of
Phanerogams, down to about 20–25 metres. At this depth the
daylight does not penetrate sufficiently to admit of the growth of
green plants, so that this region marks the limit, both physical and
biological, between the littoral and the abyssal zones. In this littoral
region there flourish a great quantity of Entomostraca, most of which
are also found in small ponds where similar conditions of life prevail
—the pelagic species only penetrating rarely, and by accident, into its
waters. At the beginning of July Mr. H. O. S. Gibson and myself
found that the weedy littoral region of Grasmere contained almost
entirely large quantities of the Cladoceran Eurycercus lamellatus,
and a number of Cyclops fuscus and C. strenuus. In the littoral zone
of large lakes, Amphipods, Isopods, and fresh-water shrimps may
also be met with, but this applies more to the lakes of the Tropics and
of the Southern Hemisphere.
The pelagic[167] region is distinguished from the littoral by the
greater purity and transparency of its waters, and by the relative
stability of the temperature, the annual range, even at the surface, in
Geneva being from 4°–20° C., while at 100 metres the water has a
uniform temperature of 4° or 5° C. The upper strata are, of course,
brightly illuminated, but at 20 metres there is hardly sufficient light
for green plants to grow, and at 100 metres it is completely dark. The
inhabitants of this region, known collectively as plankton, spend
their whole life swimming freely in the water, sometimes at the
surface and sometimes in the deeper strata. They consist chiefly of
Diatoms, Protozoa, Rotifera, and Crustacea. The pelagic Crustacea,
especially the Cladocera, are often the most curiously and delicately
built creatures. Leptodora hyalina, which is quite transparent, is the
largest of them, attaining to three-quarters of an inch in length,
though Bythotrephes longimanus is nearly as large if we include the
immense spine which terminates the body. Holopedium gibberum,
which is the commonest of all in Grasmere lake, but not so frequently
met with in the other English lakes, is peculiar in that its body is
enveloped in a spherical mass of transparent jelly, sometimes a
quarter of an inch in diameter, so that the contents of a tow-net jar
full of Holopedium have something of the consistency of boiled sago.
The enormous quantities in which these animals often occur during
summer is very astonishing; but to be truly appreciated tow-nettings
should be taken at the surface of the lake either during night-time
when there is not much moonlight, or else on a dark still day when
there is a quiet drizzle falling on the surface of the water. In bright
sunshine the plankton passes below the surface into the lower strata,
and can be usually taken by sinking the tow-net some 10–20 feet, or
to even greater depths in the water. The exact reason of these
periodic migrations out of the light, and their dependence on other
physical conditions, such as temperature and the agitation of the
water, is not clearly understood. It appears, however, that when the
water is rough, plankton always passes into the deeper regions.
Besides the species mentioned, the minute Bosminidae, whose
trunked heads are suggestive under the microscope of elephants, and
Polyphemus pediculus are among the commonest pelagic Cladocera,
though neither Polyphemus nor Bythotrephes ever form shoals. The
above-mentioned genera are characteristic of the larger lakes in the
Northern Hemisphere. Our knowledge of the Crustacean plankton of
tropical lakes and of those of the Southern Hemisphere is limited
(but see p. 216).
A very important constituent of lake-plankton is furnished by the
Copepoda, especially of the genus Diaptomus. With the exception of
Holopedium, by far the commonest Crustacean in Grasmere during
July was found by Mr. Gibson and myself to be D. caeruleus.
At the same time a number of Cyclopidae, e.g. Cyclops strenuus,
may occur in the pelagic region in considerable quantities, though
they were never found by us in such numbers as Diaptomus.
The life-cycle of the pelagic Entomostraca has been studied in both
the Cladocera and the Copepoda. In some of the Cladocera
Weismann at first supposed that males had altogether disappeared,
and that reproduction was entirely parthenogenetic. It appears,
however, that all the pelagic species have at least one sexual period,
namely, in the autumn, when resting eggs are produced which lie
dormant during the winter. The pelagic Copepods may either
produce resting eggs for the winter (Diaptomus), or else the winter is
passed through in the Nauplius stage, the larvae hibernating in the
mud until the spring (Cyclopidae).
We have so far only dealt with fresh-water Entomostraca. There
are, in addition, a number of Malacostraca which inhabit fresh water,
and some of these are found in the abyssal region of the great lakes,
which must now be considered.
The physical conditions of the abyssal region are still more stable
than those of the pelagic region, since the water is never disturbed,
the bottom is always composed of a fine mud, the temperature is
constant at 4°–5° C., and there is a total absence of light. It was
hardly expected that animals would inhabit this region, until Forel
discovered Asellus aquaticus in a depth of forty metres in the Lake of
Geneva, and subsequently showed that quite a number of animals,
including a Hydra, several worms, Molluscs, Crustacea, and larval
Insects, may be found in these or even much greater depths.
The Crustacea of the abyssal region are two in number, and these
have been found in a number of European lakes; Niphargus
puteanus, a blind Amphipod closely allied to Gammarus; and
Asellus forelii, allied to A. aquaticus and A. cavaticus, which may be
either quite blind or else retain the rudiments of eyes.
These two Crustacea, under a practically identical form, are also
found in the subterranean waters of Europe, and Forel considers that
they have arrived in the abysses of the lakes from the subterranean
channels, and are not derivatives of the littoral fauna.[168]
Having completed our short review of lacustrine Crustacea, we
may deal with the subterranean and cave Crustacea,[169] which,
as far as light and temperature are concerned, are subjected to very
similar conditions to those dwelling at the bottom of deep lakes. The
inhabitants of the subterranean waters have been chiefly brought to
light in Artesian wells, etc., while the cavedwellers have been
investigated especially at Carniola and in the American caves.
A number of species of Cyclopidae and Cypridae, many of which
are blind and colourless, have been brought up in well-water. The
Amphipod Niphargus puteanus has long been known from a similar
source in England[170] and all over Europe, and several other blind
Gammarids inhabit the subterranean waters and caves in various
parts of the world. Among Isopods, Asellus cavaticus is recorded
from wells and caves in various parts of Europe, Caecidotea stygia
and C. nickajackensis from the Mammoth and Nickajack Caves in
America, and two very remarkable blind Isopods are described by
Chilton from the subterranean waters of New Zealand, viz.
Cruregens fontanus, whose nearest allies are the marine Anthuridae,
and the Isopods Phreatoicus typicus and P. assimilis, which bear an
extraordinary resemblance superficially to Amphipods. Besides
these, a small number of subterranean Decapoda are known which
retain the eye-stalks but are without functional ommatidia. These are
Troglocaris schmidtii, in Hungary, related to the fresh-water Atyid
Xiphocaris of East Indian and East Asiatic fresh waters rather than
to the South European Atyephyra; Palaemonetes antrorum, from
artesian wells in Texas; and several species of Cambarus from the
Eastern United States. A blind species of Cambarus, C. stygius, has
been described from the caves of Carniola, and if this determination
is correct, is the sole Cambarus occurring outside America.
It will be seen from the above account that the subterranean
Crustacea are an exceedingly interesting and, in many respects,
archaic group, many of which have survived in these isolated and
probably uncompetitive districts, while many secular changes were
going on in the quick world overhead.
The remaining fresh water Malacostraca may be mentioned
under the headings of the groups to which they belong.
Only one “Schizopod,” apart from Paranaspides, is known from
fresh-water lakes, viz. Mysis relicta, which was discovered in 1861 by
Lovén in the Scandinavian lakes, and has since been found in the
Finnish lakes, the Caspian Sea, Lake Michigan, and other localities in
N. America, and Lough Erne in Ireland. This species is closely related
to Mysis oculata of Greenlandic seas.
In the Southern Hemisphere we have a species of Anaspides, A.
tasmaniae, occurring in mountain streams and tarns in Tasmania, a
related form which haunts the littoral zone of the Great Lake in
Tasmania, and a small species, Koonunga cursor, occurs in a little
stream near Melbourne.
Of the Isopoda certain genera, viz. Asellus and Monolistra, are
confined to fresh water, others, such as Sphaeroma, Idothea,
Alitropus, and Cymothoa, have occasional fresh-water
[171]
representatives. Packard describes a remarkable blind Isopod,
Caecidotea, from the Mammoth Cave of Kentucky, which occupies a
very isolated position, and in the same work gives a very complete
exposition of the cave-fauna of North America and Europe.
The Phreatoicidae are a curious family of Isopods confined to the
fresh waters of Australia and New Zealand, which bear a remarkable
resemblance to Amphipods, being laterally compressed and
possessing a subchelate hand on the anterior thoracic leg. These
Isopods are exceedingly common in small mountain pools and in
streams in Tasmania, and in the Great Lake in that country I have
recently found a number of species which, together with some
species of Amphipods, make up the dominant feature in the
Crustacean fauna. One of these species may grow to fully an inch in
length. The family is confined to the temperate regions, and is
usually found on mountains. A number of species are known from
the mainland of Australia, one coming from a high elevation on
Mount Kosciusko, and another (Phreatoicopsis) from the forests of
Gippsland attaining a great size, and living among damp leaves, etc.
The fresh-water Amphipoda all belong to the families Talitridae,
Gammaridae, and Haustoriidae (see p. 137).
Among the Talitridae, or Sand-hoppers, Orchestia and Talitrus
have marine as well as fresh-water and land representatives, while
the American Hyalella is entirely from fresh water, most of the
species being peculiar to Lake Titicaca. Many of these animals are
partly emancipated from an aquatic life. Thus Orchestia
gammarellus, which is common on the sea-shore of the
Mediterranean, frequently penetrates far inland, and was found in
large numbers by Kotschy near a spring 4000 feet up on Mount
Olympus.
Talitrus sylvaticus is very common among fallen leaves and
decaying timber in Tasmania and Southern Australia, many miles
from the sea, and often at an elevation of several thousand feet.
Among the Gammaridae, certain genera, e.g. Macrohectopus
(Constantia), from Lake Baikal, are purely fresh-water. An enormous
development of Gammaridae was discovered by Dybowsky in Lake
Baikal, comprising 116 species, and lately a number more have been
found by Korotneff.[172] The majority of these were originally placed
in the genus Gammarus, but Stebbing has rightly created a number
of peculiar genera for them. Certain species are, however, placed in
more widely distributed genera, e.g. Gammarus and
Carinogammarus, which is also represented in the Caspian Sea.
Korotneff found some remarkable transparent pelagic forms
(Constantia) swimming in the abyssal regions at about 600 metres
depth, the majority of them being blind, but some possessing
rudimentary eyes, often on one side only.
Besides various species of Gammarus, a number of other
Gammaridae are frequently found in brackish water. Among
Haustoriidae Pontoporeia has representatives in both the oceans and
inland lakes of the northern hemispheres (see p. 137).
Of the Decapoda, seven families are typically fresh-water in habitat
—the Aegleidae, containing the single species Aeglea laevis, related
to the Galatheidae, which inhabits streams in temperate S. America;
the Atyidae, a family of Prawns from the tropical rivers and lakes of
the New and Old World, and in the Mediterranean region. A number
of Palaemonidae are found in fresh water, e.g. Palaemonetes varians

You might also like