SlideShare a Scribd company logo
Kubernetes Patterns: Reusable Elements for
Designing Cloud Native Applications, 2nd Edition
Bilgin Ibryam install download
https://ebookmeta.com/product/kubernetes-patterns-reusable-
elements-for-designing-cloud-native-applications-2nd-edition-
bilgin-ibryam/
Download more ebook from https://ebookmeta.com
We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!
Kubernetes Patterns Reusable Elements for Designing
Cloud Native Applications 2nd Ed 2nd Edition Bilgin
Ibryam
https://ebookmeta.com/product/kubernetes-patterns-reusable-
elements-for-designing-cloud-native-applications-2nd-ed-2nd-
edition-bilgin-ibryam/
Cloud Native DevOps with Kubernetes, 2nd Edition Justin
Domingus
https://ebookmeta.com/product/cloud-native-devops-with-
kubernetes-2nd-edition-justin-domingus/
Cloud Native Devops with Kubernetes: Building,
Deploying, and Scaling Modern Applications in the
Cloud, 2nd Edition Justin Domingus & John Arundel
https://ebookmeta.com/product/cloud-native-devops-with-
kubernetes-building-deploying-and-scaling-modern-applications-in-
the-cloud-2nd-edition-justin-domingus-john-arundel/
Hoodwinking Hope 1st Edition Aditya Shah
https://ebookmeta.com/product/hoodwinking-hope-1st-edition-
aditya-shah/
Psychoanalysis as an Ethical Process 1st Edition Robert
P. Drozek
https://ebookmeta.com/product/psychoanalysis-as-an-ethical-
process-1st-edition-robert-p-drozek/
The Argentine Economy: An Economic History of Argentina
Aldo Ferrer
https://ebookmeta.com/product/the-argentine-economy-an-economic-
history-of-argentina-aldo-ferrer/
Without a Stitch Monster Between the Sheets Book 14
Season 2 1st Edition Honey Phillips
https://ebookmeta.com/product/without-a-stitch-monster-between-
the-sheets-book-14-season-2-1st-edition-honey-phillips/
Machine Learning The Basics Machine Learning
Foundations Methodologies and Applications Alexander
Jung
https://ebookmeta.com/product/machine-learning-the-basics-
machine-learning-foundations-methodologies-and-applications-
alexander-jung-2/
Modern Cryptography Applied Mathematics for Encryption
and Information Security 1st Edition William Easttom
https://ebookmeta.com/product/modern-cryptography-applied-
mathematics-for-encryption-and-information-security-1st-edition-
william-easttom/
Health Norms and the Governance of Global Development
The Invention of Global Health 1st Edition Anders
Granmo
https://ebookmeta.com/product/health-norms-and-the-governance-of-
global-development-the-invention-of-global-health-1st-edition-
anders-granmo/
Kubernetes Patterns: Reusable Elements for Designing Cloud Native Applications, 2nd Edition Bilgin Ibryam
Kubernetes Patterns
SECOND EDITION
Reusable Elements for Designing Cloud Native
Applications
Bilgin Ibryam and Roland Huß
Kubernetes Patterns
by Bilgin Ibryam and Roland Huß
Copyright © 2023 Bilgin Ibryam and Roland Huß. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales
promotional use. Online editions are also available for most titles
(http://oreilly.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Acquisitions Editor: John Devins
Development Editor: Rita Fernando
Production Editor: Beth Kelly
Copyeditor: Piper Editorial Consulting, LLC
Proofreader: Sharon Wilkey
Indexer: Judy McConville
Interior Designer: David Futato
Cover Designer: Karen Montgomery
Illustrator: Kate Dullea
April 2019: First Edition
March 2023: Second Edition
Revision History for the Second Edition
2023-03-25: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781098131685 for
release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.
Kubernetes Patterns, the cover image, and related trade dress are
trademarks of O’Reilly Media, Inc.
The views expressed in this work are those of the authors and do
not represent the publisher’s views. While the publisher and the
authors have used good faith efforts to ensure that the information
and instructions contained in this work are accurate, the publisher
and the authors disclaim all responsibility for errors or omissions,
including without limitation responsibility for damages resulting from
the use of or reliance on this work. Use of the information and
instructions contained in this work is at your own risk. If any code
samples or other technology this work contains or describes is
subject to open source licenses or the intellectual property rights of
others, it is your responsibility to ensure that your use thereof
complies with such licenses and/or rights.
This work is part of a collaboration between O’Reilly and Red Hat.
See our statement of editorial independence.
978-1-098-13168-5
[LSI]
Foreword
When Craig, Joe, and I started Kubernetes nearly eight years ago, I
think we all recognized its power to transform the way the world
developed and delivered software. I don’t think we knew, or even
hoped to believe, how quickly this transformation would come.
Kubernetes is now the foundation for the development of portable,
reliable systems spanning the major public clouds, private clouds,
and bare-metal environments. However, even as Kubernetes has
become ubiquitous to the point where you can spin up a cluster in
the cloud in less than five minutes, it is still far less obvious to
determine where to go once you have created that cluster. It is
fantastic that we have seen such significant strides forward in the
operationalization of Kubernetes itself, but it is only a part of the
solution. It is the foundation on which applications will be built, and
it provides a large library of APIs and tools for building these
applications, but it does little to provide the application architect or
developer with any hints or guidance for how these various pieces
can be combined into a complete, reliable system that satisfies their
business needs and goals.
Although the necessary perspective and experience for what to do
with your Kubernetes cluster can be achieved through past
experience with similar systems, or via trial and error, this is
expensive both in terms of time and the quality of systems delivered
to our end users. When you are starting to deliver mission-critical
services on top of a system like Kubernetes, learning your way via
trial and error simply takes too much time and results in very real
problems of downtime and disruption.
This then is why Bilgin and Roland’s book is so valuable. Kubernetes
Patterns enables you to learn from the previous experience that we
have encoded into the APIs and tools that make up Kubernetes.
Kubernetes is the by-product of the community’s experience building
and delivering many different, reliable distributed systems in a
variety of different environments. Each object and capability added
to Kubernetes represents a foundational tool that has been designed
and purpose-built to solve a specific need for the software designer.
This book explains how the concepts in Kubernetes solve real-world
problems and how to adapt and use these concepts to build the
system that you are working on today.
In developing Kubernetes, we always said that our North Star was
making the development of distributed systems a CS 101 exercise. If
we have managed to achieve that goal successfully, it is books like
this one that are the textbooks for such a class. Bilgin and Roland
have captured the essential tools of the Kubernetes developer and
distilled them into segments that are easy to approach and
consume. As you finish this book, you will become aware not just of
the components available to you in Kubernetes but also the “why”
and “how” of building systems with those components.
Brendan Burns
Cofounder, Kubernetes
Preface
With the mainstream adoption of microservices and containers in
recent years, the way we design, develop, and run software has
changed radically. Today’s applications are optimized for availability,
scalability, and speed-to-market. Driven by these new requirements,
today’s modern applications require a different set of patterns and
practices. This book aims to help developers discover and learn
about the most common patterns for creating cloud native
applications with Kubernetes. First, let’s take a brief look at the two
primary ingredients of this book: Kubernetes and design patterns.
Kubernetes
Kubernetes is a container orchestration platform. The origin of
Kubernetes lies somewhere in the Google data centers where
Google’s internal container orchestration platform, Borg, was born.
Google used Borg for many years to run its applications. In 2014,
Google decided to transfer its experience with Borg into a new open
source project called “Kubernetes” (Greek for “helmsman” or “pilot”).
In 2015, it became the first project donated to the newly founded
Cloud Native Computing Foundation (CNCF).
From the start, Kubernetes gained a whole community of users, and
the number of contributors grew incredibly fast. Today, Kubernetes is
considered one of the most popular projects on GitHub. It is fair to
claim that Kubernetes is the most commonly used and feature-rich
container orchestration platform. Kubernetes also forms the
foundation of other platforms built on top of it. The most prominent
of those Platform-as-a-Service systems is Red Hat OpenShift, which
provides various additional capabilities to Kubernetes. These are only
some reasons we chose Kubernetes as the reference platform for the
cloud native patterns in this book.
This book assumes you have some basic knowledge of Kubernetes.
In Chapter 1, we recapitulate the core Kubernetes concepts and lay
the foundation for the following patterns.
Design Patterns
The concept of design patterns dates back to the 1970s and is from
the field of architecture. Christopher Alexander, an architect and
system theorist, and his team published the groundbreaking A
Pattern Language (Oxford University Press) in 1977, which describes
architectural patterns for creating towns, buildings, and other
construction projects. Sometime later, this idea was adopted by the
newly formed software industry. The most famous book in this area
is Design Patterns—Elements of Reusable Object-Oriented Software
by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides—
the Gang of Four (Addison-Wesley). When we talk about the famous
Singleton, Factories, or Delegation patterns, it’s because of this
defining work. Many other great pattern books have been written
since then for various fields with different levels of granularity, like
Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf
(Addison-Wesley) or Patterns of Enterprise Application Architecture
by Martin Fowler (Addison-Wesley).
In short, a pattern describes a repeatable solution to a problem.1
This definition works for the patterns we describe in this book,
except that we probably don’t have as much variability in our
solutions. A pattern is different from a recipe because instead of
giving step-by-step instructions to solve a problem, it provides a
blueprint for solving a whole class of similar problems. For example,
the Alexandrian pattern Beer Hall describes how public drinking halls
should be constructed where “strangers and friends are drinking
companions” and not “anchors of the lonely.” All halls built after this
pattern look different but share common characteristics, such as
open alcoves for groups of four to eight and a place where a
hundred people can meet to enjoy beverages, music, and other
activities.
However, a pattern does more than provide a solution. It is also
about forming a language. The patterns in this book form a dense,
noun-centric language in which each pattern carries a unique name.
When this language is established, these names automatically evoke
similar mental representations when people speak about these
patterns. For example, when we talk about a table, anyone speaking
English assumes we are talking about a piece of wood with four legs
and a top on which you can put things. The same thing happens in
software engineering when discussing a “factory.” In an object-
oriented programming language context, we immediately associate
with a “factory” an object that produces other objects. Because we
immediately know the solution behind the pattern, we can move on
to tackle yet-unsolved problems.
There are also other characteristics of a pattern language. For
example, patterns are interconnected and can overlap so that they
cover most of the problem space. Also, as already laid out in the
original A Pattern Language, patterns have a different level of
granularity and scope. More general patterns cover an extensive
problem space and provide rough guidance on how to solve the
problem. Granular patterns have a very concrete solution proposal
but are less widely applicable. This book contains all sorts of
patterns, and many patterns reference other patterns or may even
include other patterns as part of the solution.
Another feature of patterns is that they follow a rigid format.
However, each author defines a different form; unfortunately, there
is no common standard for how patterns should be laid out. Martin
Fowler gives an excellent overview of the formats used for pattern
languages at “Writing Software Patterns”.
Kubernetes Patterns: Reusable Elements for Designing Cloud Native Applications, 2nd Edition Bilgin Ibryam
How This Book Is Structured
We chose a simple pattern format for this book. We do not follow
any particular pattern description language. For each pattern, we
use the following structure:
Name
Each pattern carries a name, which is also the chapter’s title. The
name is the center of the pattern’s language.
Problem
This section gives the broader context and describes the pattern
space in detail.
Solution
This section shows how the pattern solves the problem in a
Kubernetes-specific way. This section also contains cross-
references to other patterns that are either related or part of the
given pattern.
Discussion
This section includes a discussion about the advantages and
disadvantages of the solution for the given context.
More Information
This final section contains additional information sources related
to the pattern.
We organized the patterns in this book as follows:
Part I, “Foundational Patterns”, covers the core concepts of
Kubernetes. These are the underlying principles and practices
for building container-based cloud native applications.
Part II, “Behavioral Patterns”, describes patterns that build on
top of foundational patterns and add the runtime aspect
concepts of managing various types of containers.
Part III, “Structural Patterns”, contains patterns related to
organizing containers within a Pod, which is the atom of the
Kubernetes platform.
Part IV, “Configuration Patterns”, gives insight into the various
ways application configuration can be handled in Kubernetes.
These are granular patterns, including concrete recipes for
connecting applications to their configuration.
Part V, “Security Patterns”, addresses various security concerns
that arise when an application is containerized and deployed on
Kubernetes.
Part VI, “Advanced Patterns”, is a collection of advanced
concepts, such as how the platform itself can be extended or
how to build container images directly within the cluster.
Depending on the context, the same pattern might fit into several
categories. Every pattern chapter is self-contained; you can read
chapters in isolation and in any order.
Who This Book Is For
This book is for developers who want to design and develop cloud
native applications and use Kubernetes as the platform. It is most
suitable for readers who have some basic familiarity with containers
and Kubernetes concepts and want to take it to the next level.
However, you don’t need to know the low-level details of Kubernetes
to understand the use cases and patterns. Architects, consultants,
and other technical personnel will also benefit from the repeatable
patterns described here.
The book is based on use cases and lessons learned from real-world
projects. It is an accumulation of best practices and patterns after
years of working in this space. We want to help you understand the
Kubernetes-first mindset and create better cloud native applications
—not reinvent the wheel. It is written in a relaxed style and is similar
to a series of essays that can be read independently.
Let’s briefly look at what this book is not:
This book is not an introduction to Kubernetes, nor is it a
reference manual. We touch on many Kubernetes features and
explain them in some detail, but we are focusing on the
concepts behind those features. Chapter 1, “Introduction”,
offers a brief refresher on Kubernetes basics. If you are looking
for a comprehensive book on Kubernetes, we highly recommend
Kubernetes in Action by Marko Lukša (Manning Publications).
This book is not a step-by-step guide on how to set up a
Kubernetes cluster itself. Every example assumes you have
Kubernetes up and running. You have several options for trying
out the examples. If you are interested in learning how to set
up a Kubernetes cluster, we recommend Kubernetes: Up and
Running by Brendan Burns, Joe Beda, Kelsey Hightower, and
Lachlan Evenson (O’Reilly).
This book is not about operating and governing a Kubernetes
cluster for other teams. We deliberately skipped administrative
and operational aspects of Kubernetes and took a developer-
first view into Kubernetes. This book can help operations teams
understand how a developer uses Kubernetes, but it is not
sufficient for administering and automating a Kubernetes cluster.
If you are interested in learning how to operate a Kubernetes
cluster, we recommend Kubernetes Best Practices by Brendan
Burns, Eddie Villalba, Dave Strebel, and Lachlan Evenson
(O’Reilly).
What You Will Learn
There’s a lot to discover in this book. Some patterns may read like
excerpts from a Kubernetes manual at first glance, but upon closer
look, you’ll see the patterns are presented from a conceptual angle
not found in other books on the topic. Other patterns are explained
with detailed steps to solve a concrete problem, as in Part IV,
“Configuration Patterns”. In some chapters, we explain Kubernetes
features that don’t fit nicely into a pattern definition. Don’t get hung
up on whether it is a pattern or a feature. In all chapters, we look at
the forces involved from the first principles and focus on the use
cases, lessons learned, and best practices. That is the valuable part.
Regardless of the pattern granularity, you will learn everything
Kubernetes offers for each particular pattern, with plenty of
examples to illustrate the concepts. All these examples have been
tested, and we tell you how to get the complete source code in
“Using Code Examples”.
What’s New in the Second Edition
The Kubernetes ecosystem has continued to grow since the first
edition came out four years ago. As a result, there have been many
Kubernetes releases, and more tools and patterns for using
Kubernetes have become de facto standards.
Fortunately, most of the patterns described in our book have stood
the test of time and remain valid. Therefore, we have updated these
patterns, added new features up to Kubernetes 1.26, and removed
obsolete and deprecated parts. For the most part, only minor
changes were necessary, except for Chapter 29, “Elastic Scale”, and
Chapter 30, “Image Builder”, which underwent significant changes
due to new developments in these areas.
Additionally, we have included five new patterns and introduced a
new category, Part V, “Security Patterns”, which addresses a gap in
the first edition and provides important security-related patterns for
developers.
Our GitHub examples have been updated and extended. And, lastly,
we added 50% more content for our readers to enjoy.
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file
extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to
program elements such as variable or function names, databases,
data types, environment variables, statements, and keywords.
As mentioned, patterns form a simple, interconnected language. To
emphasize this web of patterns, each pattern is capitalized and set in
italics, (e.g., Sidecar). When a pattern name is also a Kubernetes
core concept (such as Init Container or Controller), we use this
specific formatting only when we directly reference the pattern itself.
Where it makes sense, we also interlink pattern chapters for ease of
navigation.
We also use the following conventions:
Everything you can type in a shell or editor is rendered in
constant width font.
Kubernetes resource names are always rendered in uppercase
(e.g., Pod). If the resource is a combined name like ConfigMap,
we keep it like this in favor of the more natural “config map” for
clarity and to make it clear that it refers to a Kubernetes
concept.
Sometimes, a Kubernetes resource name is identical to a
common concept like “service” or “node.” In these cases, we
use the resource name format only when referring to the
resource itself.
TIP
This element signifies a tip or suggestion.
NOTE
This element signifies a general note.
WARNING
This element indicates a warning or caution.
Using Code Examples
Every pattern is backed with fully executable examples, which you
can find on the accompanying web page. You can find the link to
each pattern’s example in each chapter’s “More Information” section.
The “More Information” section also contains links to further
information related to the pattern. We keep these lists updated in
the example repository.
The source code for all examples in this book is available on GitHub.
The repository and the website also have pointers and instructions
on how to get a Kubernetes cluster to try out the examples. Please
look at the provided resource files when you go through the
examples. They contain many valuable comments that will further
your understanding of the example code.
Many examples use a REST service called random-generator that
returns random numbers when called. It is uniquely crafted to play
well with the examples in this book. Its source can be found on
GitHub as well, and its container image k8spatterns/random-
generator is hosted on Docker Hub.
We use a JSON path notation to describe resource fields (e.g.,
.spec.replicas points to the replicas field of the resource’s spec
section).
If you find an issue in the example code or documentation or have a
question, don’t hesitate to open a ticket at the GitHub issue tracker.
We monitor these GitHub issues and are happy to answer any
questions.
All example code is distributed under the Creative Commons
Attribution 4.0 (CC BY 4.0) license. The code is free to use, and you
can share and adapt it for commercial and noncommercial projects.
However, you should give attribution back to this book if you copy or
redistribute the example code.
This attribution can be a reference to the book, including title,
author, publisher, and ISBN, as in “Kubernetes Patterns, 2nd Edition,
by Bilgin Ibryam and Roland Huß (O’Reilly). Copyright 2023 Bilgin
Ibryam and Roland Huß, 978-1-098-13168-5.” Alternatively, add a
link to the accompanying website along with a copyright notice and
link to the license.
We love code contributions too! If you think we can improve our
examples, we are happy to hear from you. Just open a GitHub issue
or create a pull request, and let’s start a conversation.
O’Reilly Online Learning
NOTE
For almost 40 years, O’Reilly Media has provided technology and
business training, knowledge, and insight to help companies succeed.
Our unique network of experts and innovators share their knowledge
and expertise through books, articles, conferences, and our online
learning platform. O’Reilly’s online learning platform gives you on-
demand access to live training courses, in-depth learning paths,
interactive coding environments, and a vast collection of text and
video from O’Reilly and 200+ other publishers. For more information,
please visit http://oreilly.com.
How to Contact Us
Please address comments and questions concerning this book to the
publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book where we list errata, examples,
and additional information. You can access this page at
https://oreil.ly/kubernetes_patterns-2e.
Email bookquestions@oreilly.com to comment or ask technical
questions about this book.
For news and information about our books and courses, visit
https://oreilly.com.
Find us on LinkedIn: https://linkedin.com/company/oreilly-media
Follow us on Twitter: https://twitter.com/oreillymedia
Watch us on YouTube: https://youtube.com/oreillymedia
Follow the authors on Twitter: https://twitter.com/bibryam,
https://twitter.com/ro14nd
Follow the authors on Mastodon: https://fosstodon.org/@bilgin,
https://hachyderm.io/@ro14nd
Find the authors on GitHub: https://github.com/bibryam,
https://github.com/rhuss
Follow their blogs: https://www.ofbizian.com, https://ro14nd.de
Acknowledgments
Bilgin is forever grateful to his wonderful wife, Ayshe, for her endless
support and patience as he worked on yet another book. He is also
thankful for his adorable daughters, Selin and Esin, who always
know how to bring a smile to his face. You mean the world to him.
Finally, Bilgin would like to thank his fantastic coauthor, Roland, for
making this project a reality.
Roland is deeply grateful for his wife Tanja’s unwavering support and
forbearance throughout the writing process, and he also thanks his
son Jakob for his encouragement. Furthermore, Roland wishes to
extend special recognition to Bilgin for his exceptional insights and
writing, without which the book would not have come to fruition.
Creating two editions of this book was a long multiyear journey, and
we want to thank our reviewers who kept us on the right track.
For the first edition, special kudos to Paolo Antinori and Andrea
Tarocchi for helping us through the journey. Big thanks to Marko
Lukša, Brandon Philips, Michael Hüttermann, Brian Gracely, Andrew
Block, Jiri Kremser, Tobias Schneck, and Rick Wagner, who supported
us with their expertise and advice. Last but not least, big thanks to
our editors Virginia Wilson, John Devins, Katherine Tozer, Christina
Edwards, and all the awesome folks at O’Reilly for helping us push
this book over the finish line.
Completing the second edition was no easy feat, and we are grateful
to all who supported us in finishing it. We extend our thanks to our
technical reviewers, Ali Ok, Dávid Šimanský, Zbyněk Roubalík, Erkan
Yanar, Christoph Stäbler, Andrew Block, and Adam Kaplan, as well as
to our development editor, Rita Fernando, for her patience and
encouragement throughout the whole process. Many kudos go out
to the O’Reilly production team, especially Beth Kelly, Kim Sandoval,
and Judith McConville, for their meticulous attention in finalizing the
book.
We want to express a special thank you to Abhishek Koserwal for his
tireless and dedicated efforts in Chapter 26, “Access Control”. His
contributions came at a time when we needed them the most and
made an impact.
1 Alexander and his team defined the original meaning in the context of
architecture as follows: “Each pattern describes a problem which occurs over
and over again in our environment, and then describes the core of the
solution to that problem, in such a way that you can use this solution a
million times over, without ever doing it the same way twice.” (A Pattern
Language, Christopher Alexander et al., 1977.)
Chapter 1. Introduction
In this introductory chapter, we set the scene for the rest of the
book by explaining a few of the core Kubernetes concepts used for
designing and implementing cloud native applications.
Understanding these new abstractions, and the related principles
and patterns from this book, is key to building distributed
applications that can be automatable by Kubernetes.
This chapter is not a prerequisite for understanding the patterns
described later. Readers familiar with Kubernetes concepts can skip it
and jump straight into the pattern category of interest.
The Path to Cloud Native
Microservices is among the most popular architectural styles for
creating cloud native applications. They tackle software complexity
through modularization of business capabilities and trading
development complexity for operational complexity. That is why a
key prerequisite for becoming successful with microservices is to
create applications that can be operated at scale through
Kubernetes.
As part of the microservices movement, there is a tremendous
amount of theory, techniques, and supplemental tools for creating
microservices from scratch or for splitting monoliths into
microservices. Most of these practices are based on Domain-Driven
Design by Eric Evans (Addison-Wesley) and the concepts of bounded
contexts and aggregates. Bounded contexts deal with large models
by dividing them into different components, and aggregates help to
further group bounded contexts into modules with defined
transaction boundaries. However, in addition to these business
domain considerations, for each distributed system—whether it is
based on microservices or not—there are also technical concerns
around its external structure, and runtime coupling. Containers and
container orchestrators such as Kubernetes bring in new primitives
and abstractions to address the concerns of distributed applications,
and here we discuss the various options to consider when putting a
distributed system into Kubernetes.
Throughout this book, we look at container and platform interactions
by treating the containers as black boxes. However, we created this
section to emphasize the importance of what goes into containers.
Containers and cloud native platforms bring tremendous benefits to
your distributed applications, but if all you put into containers is
rubbish, you will get distributed rubbish at scale. Figure 1-1 shows
the mixture of the skills required for creating good cloud native
applications and where Kubernetes patterns fit in.
Figure 1-1. The path to cloud native
At a high level, creating good cloud native applications requires
familiarity with multiple design techniques:
At the lowest code level, every variable you define, every
method you create, and every class you decide to instantiate
plays a role in the long-term maintenance of the application. No
matter what container technology and orchestration platform
you use, the development team and the artifacts they create will
have the most impact. It is important to grow developers who
strive to write clean code, have the right number of automated
tests, constantly refactor to improve code quality, and are
guided by Software Craftsmanship principles at heart.
Domain-driven design is about approaching software design
from a business perspective with the intention of keeping the
architecture as close to the real world as possible. This
approach works best for object-oriented programming
languages, but there are also other good ways to model and
design software for real-world problems. A model with the right
business and transaction boundaries, easy-to-consume
interfaces, and rich APIs is the foundation for successful
containerization and automation later.
The hexagonal architecture and its variations, such as Onion
and Clean architectures, improve the flexibility and
maintainability of applications by decoupling the application
components and providing standardized interfaces for
interacting with them. By decoupling the core business logic of a
system from the surrounding infrastructure, hexagonal
architecture makes it easier to port the system to different
environments or platforms. These architectures complement
domain-driven design and help arrange application code with
distinct boundaries and externalized infrastructure
dependencies.
The microservices architectural style and the twelve-factor app
methodology very quickly evolved to become the norm for
creating distributed applications and they provide valuable
principles and practices for designing changing distributed
applications. Applying these principles lets you create
implementations that are optimized for scale, resiliency, and
pace of change, which are common requirements for any
modern software today.
Containers were very quickly adopted as the standard way of
packaging and running distributed applications, whether these
are microservices or functions. Creating modular, reusable
containers that are good cloud native citizens is another
fundamental prerequisite. Cloud native is a term used to
describe principles, patterns, and tools to automate
containerized applications at scale. We use cloud native
interchangeably with Kubernetes, which is the most popular
open source cloud native platform available today.
In this book, we are not covering clean code, domain-driven design,
hexagonal architecture, or microservices. We are focusing only on
the patterns and practices addressing the concerns of the container
orchestration. But for these patterns to be effective, your application
needs to be designed well from the inside by using clean code
practices, domain-driven design, hexagonal architecture-like isolation
of external dependencies, microservices principles, and other
relevant design techniques.
Distributed Primitives
To explain what we mean by new abstractions and primitives, here
we compare them with the well-known object-oriented programming
(OOP), and Java specifically. In the OOP universe, we have concepts
such as class, object, package, inheritance, encapsulation, and
polymorphism. Then the Java runtime provides specific features and
guarantees on how it manages the lifecycle of our objects and the
application as a whole.
The Java language and the Java Virtual Machine (JVM) provide local,
in-process building blocks for creating applications. Kubernetes adds
an entirely new dimension to this well-known mindset by offering a
new set of distributed primitives and runtime for building distributed
systems that spread across multiple nodes and processes. With
Kubernetes at hand, we don’t rely only on the local primitives to
implement the whole application behavior.
We still need to use the object-oriented building blocks to create the
components of the distributed application, but we can also use
Kubernetes primitives for some of the application behaviors. Table 1-
1 shows how various development concepts are realized differently
with local and distributed primitives in the JVM and Kubernetes,
respectively.
Table 1-1. Local and distributed primitives
Concept Local primitive
Distributed
primitive
Behavior encapsulation Class Container image
Behavior instance Object Container
Unit of reuse .jar Container image
Composition Class A contains
Class B
Sidecar pattern
Inheritance Class A extends
Class B
A container’s FROM
parent image
Deployment unit .jar/.war/.ear Pod
Buildtime/Runtime
isolation
Module, package,
class
Namespace, Pod,
container
Initialization
preconditions
Constructor Init container
Postinitialization trigger Init-method postStart
Predestroy trigger Destroy-method preStop
Cleanup procedure finalize(),
shutdown hook
-
Concept Local primitive
Distributed
primitive
Asynchronous and
parallel execution
ThreadPoolExecutor,
ForkJoinPool
Job
Periodic task Timer, ScheduledExec
utorService
CronJob
Background task Daemon thread DaemonSet
Configuration
management
System.getenv(), Pro
perties
ConfigMap, Secret
The in-process primitives and the distributed primitives have
commonalities, but they are not directly comparable and
replaceable. They operate at different abstraction levels and have
different preconditions and guarantees. Some primitives are
supposed to be used together. For example, we still have to use
classes to create objects and put them into container images.
However, some other primitives such as CronJob in Kubernetes can
completely replace the ExecutorService behavior in Java.
Next, let’s see a few distributed abstractions and primitives from
Kubernetes that are especially interesting for application developers.
Containers
Containers are the building blocks for Kubernetes-based cloud native
applications. If we make a comparison with OOP and Java, container
images are like classes, and containers are like objects. The same
way we can extend classes to reuse and alter behavior, we can have
container images that extend other container images to reuse and
alter behavior. The same way we can do object composition and use
functionality, we can do container compositions by putting containers
into a Pod and using collaborating containers.
If we continue the comparison, Kubernetes would be like the JVM
but spread over multiple hosts, and it would be responsible for
running and managing the containers. Init containers would be
something like object constructors; DaemonSets would be similar to
daemon threads that run in the background (like the Java Garbage
Collector, for example). A Pod would be something similar to an
Inversion of Control (IoC) context (Spring Framework, for example),
where multiple running objects share a managed lifecycle and can
access one another directly.
The parallel doesn’t go much further, but the point is that containers
play a fundamental role in Kubernetes, and creating modularized,
reusable, single-purpose container images is fundamental to the
long-term success of any project and even the containers’ ecosystem
as a whole. Apart from the technical characteristics of a container
image that provide packaging and isolation, what does a container
represent, and what is its purpose in the context of a distributed
application? Here are a few suggestions on how to look at
containers:
A container image is the unit of functionality that addresses a
single concern.
A container image is owned by one team and has its own
release cycle.
A container image is self-contained and defines and carries its
runtime dependencies.
A container image is immutable, and once it is built, it does not
change; it is configured.
A container image defines its resource requirements and
external dependencies.
A container image has well-defined APIs to expose its
functionality.
A container typically runs as a single Unix process.
A container is disposable and safe to scale up or down at any
moment.
In addition to all these characteristics, a proper container image is
modular. It is parameterized and created for reuse in the different
environments in which it is going to run. Having small, modular, and
reusable container images leads to the creation of more specialized
and stable container images in the long term, similar to a great
reusable library in the programming language world.
Pods
Looking at the characteristics of containers, we can see that they are
a perfect match for implementing the microservices principles. A
container image provides a single unit of functionality, belongs to a
single team, has an independent release cycle, and provides
deployment and runtime isolation. Most of the time, one
microservice corresponds to one container image.
However, most cloud native platforms offer another primitive for
managing the lifecycle of a group of containers—in Kubernetes, it is
called a Pod. A Pod is an atomic unit of scheduling, deployment, and
runtime isolation for a group of containers. All containers in a Pod
are always scheduled to the same host, are deployed and scaled
together, and can also share filesystem, networking, and process
namespaces. This joint lifecycle allows the containers in a Pod to
interact with one another over the filesystem or through networking
via localhost or host interprocess communication mechanisms if
desired (for performance reasons, for example). A Pod also
represents a security boundary for an application. While it is possible
to have containers with varying security parameters in the same
Pod, typically all containers would have the same access level,
network segmentation, and identity.
As you can see in Figure 1-2, at development and build time, a
microservice corresponds to a container image that one team
develops and releases. But at runtime, a microservice is represented
by a Pod, which is the unit of deployment, placement, and scaling.
The only way to run a container—whether for scale or migration—is
through the Pod abstraction. Sometimes a Pod contains more than
one container. In one such example, a containerized microservice
uses a helper container at runtime, as Chapter 16, “Sidecar”,
demonstrates.
Figure 1-2. A Pod as the deployment and management unit
Containers, Pods, and their unique characteristics offer a new set of
patterns and principles for designing microservices-based
applications. We saw some of the characteristics of well-designed
containers; now let’s look at some characteristics of a Pod:
A Pod is the atomic unit of scheduling. That means the
scheduler tries to find a host that satisfies the requirements of
all containers that belong to the Pod (we cover some specifics
around init containers in Chapter 15, “Init Container”). If you
create a Pod with many containers, the scheduler needs to find
a host that has enough resources to satisfy all container
demands combined. This scheduling process is described in
Chapter 6, “Automated Placement”.
A Pod ensures colocation of containers. Thanks to the
colocation, containers in the same Pod have additional means to
interact with one another. The most common ways of
communicating include using a shared local filesystem for
exchanging data, using the localhost network interface, or using
some host interprocess communication (IPC) mechanism for
high-performance interactions.
A Pod has an IP address, name, and port range that are shared
by all containers belonging to it. That means containers in the
same Pod have to be carefully configured to avoid port clashes,
in the same way that parallel, running Unix processes have to
take care when sharing the networking space on a host.
A Pod is the atom of Kubernetes where your application lives, but
you don’t access Pods directly—that is where Services enter the
scene.
Services
Pods are ephemeral. They come and go at any time for all sorts of
reasons (e.g., scaling up and down, failing container health checks,
node migrations). A Pod IP address is known only after it is
scheduled and started on a node. A Pod can be rescheduled to a
different node if the existing node it is running on is no longer
healthy. This means the Pod’s network address may change over the
life of an application, and there is a need for another primitive for
discovery and load balancing.
That’s where the Kubernetes Services come into play. The Service is
another simple but powerful Kubernetes abstraction that binds the
Service name to an IP address and port number permanently. So a
Service represents a named entry point for accessing an application.
In the most common scenario, the Service serves as the entry point
for a set of Pods, but that might not always be the case. The Service
is a generic primitive, and it may also point to functionality provided
outside the Kubernetes cluster. As such, the Service primitive can be
used for Service discovery and load balancing, and it allows altering
implementations and scaling without affecting Service consumers.
We explain Services in detail in Chapter 13, “Service Discovery”.
Labels
We have seen that a microservice is a container image at build time
but is represented by a Pod at runtime. So what is an application
that consists of multiple microservices? Here, Kubernetes offers two
more primitives that can help you define the concept of an
application: labels and namespaces.
Before microservices, an application corresponded to a single
deployment unit with a single versioning scheme and release cycle.
There was a single file for an application in a .war, .ear, or some
other packaging format. But then, applications were split into
microservices, which are independently developed, released, run,
restarted, or scaled. With microservices, the notion of an application
diminishes, and there are no key artifacts or activities that we have
to perform at the application level. But if you still need a way to
indicate that some independent services belong to an application,
labels can be used. Let’s imagine that we have split one monolithic
application into three microservices and another one into two
microservices.
We now have five Pod definitions (and maybe many more Pod
instances) that are independent of the development and runtime
points of view. However, we may still need to indicate that the first
three Pods represent an application and the other two Pods
represent another application. Even the Pods may be independent,
to provide a business value, but they may depend on one another.
For example, one Pod may contain the containers responsible for the
frontend, and the other two Pods are responsible for providing the
backend functionality. If either of these Pods is down, the application
is useless from a business point of view. Using label selectors gives
us the ability to query and identify a set of Pods and manage it as
one logical unit. Figure 1-3 shows how you can use labels to group
the parts of a distributed application into specific subsystems.
Figure 1-3. Labels used as an application identity for Pods
Here are a few examples where labels can be useful:
Labels are used by ReplicaSets to keep some instances of a
specific Pod running. That means every Pod definition needs to
have a unique combination of labels used for scheduling.
Labels are also heavily used by the scheduler. The scheduler
uses labels for colocating or spreading Pods to the nodes that
satisfy the Pods’ requirements.
A label can indicate a logical grouping of a set of Pods and give
an application identity to them.
In addition to the preceding typical use cases, labels can be
used to store metadata. It may be difficult to predict what a
label could be used for, but it is best to have enough labels to
describe all important aspects of the Pods. For example, having
labels to indicate the logical group of an application, the
business characteristics and criticality, the specific runtime
platform dependencies such as hardware architecture, or
location preferences are all useful.
Later, these labels can be used by the scheduler for more fine-
grained scheduling, or the same labels can be used from the
command line for managing the matching Pods at scale. However,
you should not go overboard and add too many labels in advance.
You can always add them later if needed. Removing labels is much
riskier as there is no straightforward way of finding out what a label
is used for and what unintended effect such an action may cause.
ANNOTATIONS
Another primitive very similar to labels is the annotation. Like
labels, annotations are organized as a map, but they are
intended for specifying nonsearchable metadata and for machine
usage rather than human.
The information on the annotations is not intended for querying
and matching objects. Instead, it is intended for attaching
additional metadata to objects from various tools and libraries we
want to use. Some examples of using annotations include build
IDs, release IDs, image information, timestamps, Git branch
names, pull request numbers, image hashes, registry addresses,
author names, tooling information, and more. So while labels are
used primarily for query matching and performing actions on the
matching resources, annotations are used to attach metadata
that can be consumed by a machine.
Namespaces
Another primitive that can also help manage a group of resources is
the Kubernetes namespace. As we have described, a namespace
may seem similar to a label, but in reality, it is a very different
primitive with different characteristics and purposes.
Kubernetes namespaces allow you to divide a Kubernetes cluster
(which is usually spread across multiple hosts) into a logical pool of
resources. Namespaces provide scopes for Kubernetes resources and
a mechanism to apply authorizations and other policies to a
subsection of the cluster. The most common use case of namespaces
is representing different software environments such as
development, testing, integration testing, or production.
Namespaces can also be used to achieve multitenancy and provide
isolation for team workspaces, projects, and even specific
applications. But ultimately, for a greater isolation of certain
environments, namespaces are not enough, and having separate
clusters is common. Typically, there is one nonproduction Kubernetes
cluster used for some environments (development, testing, and
integration testing) and another production Kubernetes cluster to
represent performance testing and production environments.
Let’s look at some of the characteristics of namespaces and how
they can help us in different scenarios:
A namespace is managed as a Kubernetes resource.
A namespace provides scope for resources such as containers,
Pods, Services, or ReplicaSets. The names of resources need to
be unique within a namespace but not across them.
By default, namespaces provide scope for resources, but
nothing isolates those resources and prevents access from one
resource to another. For example, a Pod from a development
namespace can access another Pod from a production
namespace as long as the Pod IP address is known. “Network
isolation across namespaces for creating a lightweight
multitenancy solution is described in Chapter 24, “Network
Segmentation”.
Some other resources, such as namespaces, nodes, and
PersistentVolumes, do not belong to namespaces and should
have unique cluster-wide names.
Each Kubernetes Service belongs to a namespace and gets a
corresponding Domain Name Service (DNS) record that has the
namespace in the form of <service-name>.<namespace-
name>.svc.cluster.local. So the namespace name is in the
URL of every Service belonging to the given namespace. That’s
one reason it is vital to name namespaces wisely.
ResourceQuotas provide constraints that limit the aggregated
resource consumption per namespace. With ResourceQuotas, a
cluster administrator can control the number of objects per type
that are allowed in a namespace. For example, a developer
namespace may allow only five ConfigMaps, five Secrets, five
Services, five ReplicaSets, five PersistentVolumeClaims, and ten
Pods.
ResourceQuotas can also limit the total sum of computing
resources we can request in a given namespace. For example,
in a cluster with a capacity of 32 GB RAM and 16 cores, it is
possible to allocate 16 GB RAM and 8 cores for the production
namespace, 8 GB RAM and 4 cores for the staging environment,
4 GB RAM and 2 cores for development, and the same amount
for testing namespaces. The ability to impose resource
constraints decoupled from the shape and the limits of the
underlying infrastructure is invaluable.
Discussion
We’ve only briefly covered a few of the main Kubernetes concepts
we use in this book. However, there are more primitives used by
developers on a day-by-day basis. For example, if you create a
containerized service, there are plenty of Kubernetes abstractions
you can use to reap all the benefits of Kubernetes. Keep in mind,
these are only a few of the objects used by application developers to
integrate a containerized service into Kubernetes. There are plenty
of other concepts used primarily by cluster administrators for
managing Kubernetes. Figure 1-4 gives an overview of the main
Kubernetes resources that are useful for developers.
Figure 1-4. Kubernetes concepts for developers
With time, these new primitives give birth to new ways of solving
problems, and some of these repetitive solutions become patterns.
Throughout this book, rather than describing each Kubernetes
resource in detail, we will focus on concepts that are proven as
patterns.
More Information
The Twelve-Factor App
CNCF Cloud Native Definition v1.0
Hexagonal Architecture
Domain-Driven Design: Tackling Complexity in the Heart of
Software
Best Practices for Writing Dockerfiles
Principles of Container-Based Application Design
General Container Image Guidelines
Part I. Foundational Patterns
Foundational patterns describe a number of fundamental principles
that containerized applications must comply with in order to become
good cloud-native citizens. Adhering to these principles will help
ensure that your applications are suitable for automation in cloud-
native platforms such as Kubernetes.
The patterns described in the following chapters represent the
foundational building blocks of distributed container-based
Kubernetes-native applications:
Chapter 2, “Predictable Demands”, explains why every container
should declare its resource requirements and stay confined to
the indicated resource boundaries.
Chapter 3, “Declarative Deployment”, describes the different
application deployment strategies that can be expressed in a
declarative way.
Chapter 4, “Health Probe”, dictates that every container should
implement specific APIs to help the platform observe and
maintain the application healthily.
Chapter 5, “Managed Lifecycle”, explains why a container should
have a way to read the events coming from the platform and
conform by reacting to those events.
Chapter 6, “Automated Placement”, introduces the Kubernetes
scheduling algorithm and the ways to influence the placement
decisions from the outside.
Chapter 2. Predictable
Demands
The foundation of successful application deployment, management,
and coexistence on a shared cloud environment is dependent on
identifying and declaring the application resource requirements and
runtime dependencies. This Predictable Demands pattern indicates
how you should declare application requirements, whether they are
hard runtime dependencies or resource requirements. Declaring your
requirements is essential for Kubernetes to find the right place for
your application within the cluster.
Problem
Kubernetes can manage applications written in different
programming languages as long as the application can be run in a
container. However, different languages have different resource
requirements. Typically, a compiled language runs faster and often
requires less memory compared to just-in-time runtimes or
interpreted languages. Considering that many modern programming
languages in the same category have similar resource requirements,
from a resource consumption point of view, more important aspects
are the domain, the business logic of an application, and the actual
implementation details.
Besides resource requirements, application runtimes also have
dependencies on platform-managed capabilities like data storage or
application configuration.
Solution
Knowing the runtime requirements for a container is important
mainly for two reasons. First, with all the runtime dependencies
defined and resource demands envisaged, Kubernetes can make
intelligent decisions about where to place a container on the cluster
for the most efficient hardware utilization. In an environment with
shared resources among a large number of processes with different
priorities, the only way to ensure a successful coexistence is to know
the demands of every process in advance. However, intelligent
placement is only one side of the coin.
Container resource profiles are also essential for capacity planning.
Based on the particular service demands and the total number of
services, we can do some capacity planning for different
environments and come up with the most cost-effective host profiles
to satisfy the entire cluster demand. Service resource profiles and
capacity planning go hand in hand for successful cluster
management in the long term.
Before diving into resource profiles, let’s look at declaring runtime
dependencies.
Runtime Dependencies
One of the most common runtime dependencies is file storage for
saving application state. Container filesystems are ephemeral and
are lost when a container is shut down. Kubernetes offers volume as
a Pod-level storage utility that survives container restarts.
The most straightforward type of volume is emptyDir, which lives as
long as the Pod lives. When the Pod is removed, its content is also
lost. The volume needs to be backed by another kind of storage
mechanism to survive Pod restarts. If your application needs to read
or write files to such long-lived storage, you must declare that
dependency explicitly in the container definition using volumes, as
shown in Example 2-1.
Example 2-1. Dependency on a PersistentVolume
apiVersion: v1
kind: Pod
metadata:
name: random-generator
spec:
containers:
- image: k8spatterns/random-generator:1.0
name: random-generator
volumeMounts:
- mountPath: "/logs"
name: log-volume
volumes:
- name: log-volume
persistentVolumeClaim:
claimName: random-generator-log
Dependency of a PersistentVolumeClaim (PVC) to be present and
bound.
The scheduler evaluates the kind of volume a Pod requires, which
affects where the Pod gets placed. If the Pod needs a volume that is
not provided by any node on the cluster, the Pod is not scheduled at
all. Volumes are an example of a runtime dependency that affects
what kind of infrastructure a Pod can run and whether the Pod can
be scheduled at all.
A similar dependency happens when you ask Kubernetes to expose a
container port on a specific port on the host system through
hostPort. The usage of a hostPort creates another runtime
dependency on the nodes and limits where a Pod can be scheduled.
hostPort reserves the port on each node in the cluster and is limited
to a maximum of one Pod scheduled per node. Because of port
conflicts, you can scale to as many Pods as there are nodes in the
Kubernetes cluster.
Another Random Scribd Document
with Unrelated Content
hundred and twenty-seven thousand six hundred and twenty-seven
dollars and thirty-eight cents, and the second, twenty-four million
eight hundred and forty-four thousand one hundred and sixteen
dollars and fifty-one cents, differing only about seventeen thousand
dollars.
The mode recommended by the secretary for the modification of
the tariff is, to reduce no part of the duties on the unprotected
articles prior to March, 1833, and then to retain a considerable
portion of them. And as to the protected class, he would make a
gradual but prospective reduction of the duties. The effect of this
would be, to destroy the protecting system, by a slow but certain
poison. The object being to reduce the revenue, every descending
degree in the scale of his plan of gradual reduction, by letting in
more of the foreign article to displace the domestic rival fabric,
would increase the revenue, and create the necessity for further and
further reduction of duties, until they would be carried so low as to
end in the entire subversion of the system of protection.
For the reasons which have been assigned, it would, I think, be
unwise in congress at this time to assume for the future, that there
would be a greater amount of net annual revenue from all sources,
including the public lands, than twenty-five millions of dollars.
Deducting from that sum the amount of seven millions of dollars,
which it has been supposed ought to be subtracted, if the resolution
before you should be adopted, there would remain eighteen millions
of dollars, as the probable revenue for future years. This includes
the sum of three millions of dollars, estimated as the future annual
receipt from the sale of the public lands—an estimate which
I presume will be demonstrated by experience to be much too large.
If a reduction so large as seven millions be made at this session,
and if the necessary measures be also adopted to detect and punish
frauds, and insure a faithful execution of the laws, we may safely
make a temporary pause, and await the development of the effect of
these arrangements upon the revenue. That the authority of the
laws should be vindicated, all ought to agree. Now the fraudulent
importer, after an exposure of his fraud, by a most strange treasury
construction of the law, (made, I understand, however, not by the
present secretary,) eludes all punishment, and is only required to pay
those very duties which he was originally bound for, but which he
dishonestly sought to evade. Other measures, with a view to a
further reduction of the revenue, may be adopted. In some
instances there might be an augmentation of duties for that
purpose. I will mention the article of foreign distilled spirits. In no
other country upon earth is there so much of the foreign article
imported, as in this. The duties ought to be doubled, and the
revenue thereby further reduced from six hundred thousand, to a
million of dollars. The public morals, the grain-growing country, the
fruit-raising and the cane-planting country, would be all benefited by
rendering the duty prohibitory. I have not proposed the measure,
because it ought to originate, perhaps, in the other house.
That the measure which I have proposed may be adopted,
without interfering with the plan of the secretary of the treasury for
the payment of the public debt by the fourth of March next, I will
now proceed to show. The secretary estimates that the receipts of
the present year, after meeting all other just engagements, will leave
a surplus of fourteen millions of dollars, applicable to the payment of
the principal of the debt. With this sum, eight millions of dollars,
which he proposes to derive from the sale of the bank stock, and
two millions of dollars, which he would anticipate from the revenue
of the next year, he suggests that the whole of the debt remaining,
may be discharged by the time indicated. The fourteen millions,
I understand, (although on this subject the report is not perfectly
explicit,) are receipts anticipated this year, from duties which accrued
last year. If this be the secretary’s meaning, it is evident that he
wants no part of the duties which may accrue during the current
year, to execute his plan. But if his meaning be, that the fourteen
millions will be composed, in part, of duties accruing and payable
within the present year, then the measure proposed might prevent
the payment of the whole of the remnant of the debt by the exact
day which has been stated. If, however, the entire seven millions
embraced by the resolution on your table were subtracted from the
fourteen, it would still leave him seven millions, besides the bank
stock to be applied to the debt, and that, of itself, would be three
millions more than can be properly applied to the object in the
course of this year, as I have already endeavored to show.
I came here, sir, most anxiously desiring that an arrangement of
the public revenue should be made, which, without sacrificing any of
the great interests of the country, would reconcile and satisfy all its
parts. I thought I perceived, in the class of objects not produced
within the country, a field on which we could all enter, in a true and
genuine spirit of compromise and harmony, and agree upon an
amicable adjustment. Why should it not be done? Why should those
who are opposed to the American system, demand of its friends an
unconditional surrender? Our common object should be, so to
reduce the public revenue as to relieve the burdens of the people, if
the people of this country can be truly said to be burdened. The
government must have a certain amount of revenue, and that
amount must be collected from the imports. Is it material to the
consumer, wherever situated, whether the collection be made upon
a few, or many objects, provided, whatever be the mode, the
amount of his contribution to the public exchequer remains the
same? If the assessment can be made on objects which will greatly
benefit large portions of the union, without injury to him, why should
he object to the selection of those objects? Yes, sir, I came here in a
spirit of warm attachment to all parts of our beloved country, with a
lively solicitude to restore and preserve its harmony, and with a firm
determination to pour oil and balm into existing wounds, rather than
further to lacerate them. For the truth and sincerity of these
declarations, I appeal to Him whom none can deceive. I expected to
be met by corresponding dispositions, and hoped that our
deliberations, guided by fraternal sentiments and feelings, would
terminate in diffusing contentment and satisfaction throughout the
land. And that such may be the spirit presiding over them, and such
their issue, I yet most fervently hope.
ON THE NOMINATION OF
MR. VAN BUREN AS
MINISTER TO GREAT
BRITAIN.
IN SECRET SESSION IN THE U. S. SENATE,
JANUARY 24, 1832.
[IN April, 1831, a rupture in the cabinet of president Jackson terminated in the
resignation of the four secretaries, and the attorney general. Among them was
Mr. Martin Van Buren, who resigned the office of secretary of state, which he had
held a little over two years. General Jackson soon afterwards appointed Mr. Van
Buren minister to Great Britain, and he took his departure for London during the
recess of the senate; of course, before the nomination could be submitted to that
body, for their action. At the ensuing session of congress, the president sent in his
name to the senate, and the subject was as usual acted upon in secret session,
but the injunction of secrecy was afterwards removed, which enables us to give
Mr. Clay’s brief but pointed remarks on the occasion. The principal ground of
opposition to the confirmation of the nomination, was that Mr. Van Buren, while
secretary of state, in July, 1829, had instructed Mr. McLane, then minister to Great
Britain, to represent to the British government that a change of administration in
the United States had produced a change of policy; thus bringing our party politics
into our negotiations with a foreign power. The senate, therefore, rebuked Mr. Van
Buren and the president, by rejecting his nomination on this occasion, by an equal
vote of the senators, and the casting vote of the vice-president (Mr. Calhoun)].
MR. PRESIDENT,
I regret that I find myself utterly unable to reconcile with the
duty I owe to my country a vote in favor of this nomination. I regret
it, because in all the past strife of party the relations of ordinary
civility and courtesy were never interrupted between the gentleman
whose name is before us and myself. But I regard my obligations to
the people of the United States, and to the honor and character of
their government, as paramount to every private consideration.
There was no necessity known to us for the departure of this
gentleman from the United States, prior to the submission of his
name to the senate. Great Britain was represented here by a
diplomatic agent, having no higher rank than that of a chargé des
affaires. We were represented in England by one of equal rank; one
who had shed lustre upon his country by his high literary character,
and of whom it may be justly said, that in no respect was he inferior
to the gentleman before us. Although I shall not controvert the right
of the president, in an extraordinary case, to send abroad a public
minister without the advice and consent of the senate, I do not
admit that it ever ought to be done without the existence of some
special cause, to be communicated to the senate. We have received
no communication of the existence of any such special cause. This
view of the matter might not have been sufficient alone to justify a
rejection of this nomination; but it is sufficient to authorize us to
examine the subject with as perfect freedom as we could have done
if the minister had remained in the United States, and awaited the
decision of the senate. I consider myself, therefore, not committed
by the separate and unadvised act of the president in despatching
Mr. Van Buren in the vacation of the senate, and not a very long
time before it was to assemble.
My main objection to the confirmation of his appointment arises
out of his instructions to the late minister of the United States at the
court of Great Britain. The attention of the senate has been already
called to parts of those instructions, but there are other parts of
them, in my opinion, highly reprehensible. Speaking of the colonial
question, he says, ‘in reviewing the events which have preceded,
and more or less contributed, to a result so much to be regretted,
there will be found three grounds, on which we are most assailable.
First, in our too long and too tenaciously resisting the right of Great
Britain to impose protecting duties in her colonies.’ * * * *
‘And, thirdly, in omitting to accept the terms offered by the act of
parliament of July, 1825, after the subject had been brought before
congress, and deliberately acted upon by our government.
* * * * You will, therefore, see the propriety of possessing
yourself of all the explanatory and mitigating circumstances
connected with them, that you may be enabled to obviate, as far as
practicable, the unfavorable impression which they have produced.’
And after reproaching the late administration with setting up claims
for the first time, which they explicitly abandoned, he says, in
conclusion, ‘I will add nothing as to the impropriety of suffering any
feelings, that find their origin in the past pretensions of this
government, to have adverse influence upon the present conduct of
Great Britain.’
On our side, according to Mr. Van Buren, all was wrong; on the
British side, all was right. We brought forward nothing but claims
and pretensions. The British government asserted, on the other
hand, a clear and incontestable right. We erred in too tenaciously
and too long insisting upon our pretensions, and not yielding at once
to the force of their just demands. And Mr. McLane was commanded
to avail himself of all the circumstances in his power to mitigate our
offence, and to dissuade the British government from allowing their
feelings, justly incurred by the past conduct of the party driven from
power, to have an adverse influence towards the American party
now in power. Sir, was this becoming language from one
independent nation to another? Was it proper, in the mouth of an
American minister? Was it in conformity with the high, unsullied, and
dignified character of our previous diplomacy? Was it not, on the
contrary, the language of an humble vassal to a proud and haughty
lord? Was it not prostrating and degrading the American eagle
before the British lion?
Let us examine a little those pretensions which the American
government so unjustly put forward, and so pertinaciously maintain.
The American government contended, that the produce of the
United States ought to be admitted into the British West Indies, on
the same terms as similar produce of the British American
continental possessions; that without this equality our produce could
not maintain in the British West Indies a fair competition with the
produce of Canada, and that British preference given to the
Canadian produce in the West Indies would draw from the western
part of New York, and the northern part of Ohio, American produce
into Canada, aggrandizing Montreal and Quebec, and giving
employment to British shipping, to the prejudice of the canals of
New York, the port of New York, and American shipping.
This was the offence of the American government, and we are at
this moment realizing the evils which it foresaw. Our produce is
passing into Canada, enriching her capitals, and nourishing British
navigation. Our own wheat is transported from the western part of
New York into Canada, there manufactured, and then transported in
British ships in the form of Canadian flour. We are thus deprived of
the privilege even of manufacturing our own grain. And when the
produce of the United States, shipped from the Atlantic ports, arrives
at the British West Indies, it is unable, in consequence of the heavy
duties with which most of it is burdened, to sustain a competition
with British or colonial produce, freely admitted.
The general rule may be admitted, that every nation has a right
to favor its own productions, by protecting duties, or other
regulations; but, like all general rules, it must have its exceptions.
And the relation in which Great Britain stands to her continental and
West India colonies, from which she is separated by a vast sea, and
the relations in which the United States stand to those colonies,
some of which are in juxtaposition with them, constitute a fit case
for such an exception.
It is true, that the late administration did authorize Mr. Gallatin to
treat with Great Britain on the basis of the rule which has been
stated, but it was with the express understanding, that some
competent provision should be made in the treaty to guard against
the British monopoly of the transportation of our own produce
passing through Canada. Mr. Gallatin was informed, ‘that the United
States consent to the demand which they have heretofore made of
the admission of their productions into British colonies, at the same
and no higher rate of duty as similar productions are chargeable with
when imported from one into another British colony, with the
exception of our produce descending the St. Lawrence and the
Sorell.’
There was no abandonment of our right, no condemnation of the
previous conduct of our government, no humiliating admission, that
we had put forth and too tenaciously clung to unsustainable
pretensions, and that Great Britain had all along been in the right.
We only forebore for the present to assert a right, leaving ourselves
at liberty subsequently to resume it. What Mr. Gallatin was
authorized to do was, to make a temporary concession, and it was
proposed with this preliminary annunciation. ‘But, notwithstanding
on a full consideration of the whole subject, the president, anxious
to give a strong proof to Great Britain of the desire of the
government of the United States to arrange this long contested
matter of the colonial intercourse in a manner mutually satisfactory,
authorizes you,’ &c. And Mr. Gallatin was required ‘to endeavor to
make a lively impression on the British government of the
conciliatory spirit of that of the United States, which has dictated the
present liberal offer, and of their expectation to meet, in the
progress of the negotiations, with a corresponding friendly
disposition.’
Now, sir, keeping sight of the object which the late secretary of
state had in view, the opening of the trade with the British colonies,
which was the best mode to accomplish it—to send our minister to
prostrate himself as a suppliant before the British throne, and to say
to the British king, we have offended your majesty! the late
American administration brought forward pretensions which we
cannot sustain, and they too long and too tenaciously adhered to
them! your majesty was always in the right; but we hope that your
majesty will be graciously pleased to recollect, that it was not we
who are now in possession of the American power, but those who
have been expelled from it, that wronged your majesty, and that we,
when out of power, were on the side of your majesty; and we do
humbly pray, that your majesty, taking all mitigating circumstances
into consideration, will graciously condescend to extend to us the
privileges of the British act of parliament of 1825, and to grant us
the boon of a trade with your majesty’s West India colonies—or to
have presented himself before the British monarch in the manly and
dignified attitude of a minister of this republic, and, abstaining from
all condemnation or animadversion upon the past conduct of his own
government, to have placed the withdrawal of our former demand
upon the ground of concession in a spirit of amity and compromise?
But the late secretary of state, the appointed organ of the
American people to vindicate their rights with all foreign powers, and
to expose the injustice of any unfounded demands which they might
assert, was not content to exert his own ingenuity to put his own
country in the wrong, and the British government in the right. He
endeavored to attach to the late administration the discredit of
bringing forward unfounded pretensions, and by disclaiming them, to
propitiate the favor of the British king. He says, that the views of the
present administration upon the subject of the colonial trade ‘have
been submitted to the people of the United States, and the counsels
by which your conduct is now directed are the result of the
judgment expressed by the only earthly tribunal to which the late
administration was amenable for its acts. It should be sufficient, that
the claims set up by them, and what caused the interruption of the
trade in question, have been explicitly abandoned by those who first
asserted them, and are not revived by their successors.’ The late
secretary of state—the gentleman under consideration—here makes
the statement, that the late administration were the first to set up
the claims to which he refers. Now, under all the high responsibility
which belongs to the seat which I occupy, I deliberately pronounce
that this statement is untrue, and that the late secretary either must
have known it to be untrue, or he was culpably negligent of his duty
in not ascertaining what had been done under prior administrations.
I repeat the charge, the statement must have been known to be
untrue, or there was culpable negligence. If it were material,
I believe it could be shown, that the claim in question—the right to
the admission into the British West Indies of the produce of the
United States upon an equal footing with similar produce of the
British continental colonies—is coeval with the existence of our
present constitution, and that whenever the occasion arose for
asserting the claim, it was asserted. But I shall go no further back
than to Mr. Madison’s administration. Mr. Monroe, the then secretary
of state, instructed our then minister at London upon this subject.
He negotiated with lord Castlereagh in respect to it, and this very
claim prevented an adjustment at that time of the colonial question.
It was again brought forward under Mr. Monroe’s administration,
when Mr. Rush was our minister at London. He opened a long and
protracted negotiation upon this and other topics, which was
suspended in the summer of 1824, principally because the parties
could not agree on any satisfactory arrangement of this very colonial
question.
Thus, at least, two administrations prior to that of Mr. Adams’s
had brought forward this identical claim or pretension, which his was
the first to assert, according to the late secretary of state.
The next charge which the late secretary of state—the official
defender of the rights of the American people—preferred against his
own government, was that of ‘omitting to accept the terms offered
by the act of parliament, of July, 1825, after the subject had been
brought before congress, and deliberately acted upon by our
government.’ Never was there a more unfounded charge brought
forward by any native against his own government, and never was
there a more unwarranted apology set up for a foreign government;
and a plain, historical narrative, will demonstrate the truth of both
these propositions.
It has been already stated, that the negotiations of Mr. Rush,
embracing the precise colonial claim under consideration, was
suspended in 1824, with an understanding between the two
governments, that it was to be resumed on all points, at some future
convenient period. Early in July, 1825, neither government having
then proposed a resumption of the negotiation, the British
parliament passed an act to regulate the colonial trade with foreign
powers. This act was never, during the late administration, either at
London or Washington, officially communicated by the British to the
American government, and we only obtained it through other
channels. Now if it had been the purpose of the British government,
by the passage of that act, to withdraw the colonial question from
the negotiation, it ought to have communicated that purpose to this
government, and at the same time, the act of parliament, as
supplanting and substituting the negotiation. But it never did
communicate such purpose. The act itself did not specifically
embrace the United States, and offered terms, which, upon the face
of the act, it was impossible for the United States to accede to. It
required, for example, that, to entitle powers not possessing
colonies, to the benefit of the act, they must place the navigation
and commerce of Great Britain upon the footing of the most favored
nations. To have done this, would have admitted British shipping to
import into the United States, on the same conditions with native
shipping, the productions of any quarter of the globe, without a
reciprocal liberty, on the part of the shipping of the United States, in
British ports. The act itself was differently construed, in different
colonial ports of Great Britain, and an order of the local government
of Halifax, closing that port against our vessels from the fifth of
January, was subsequently revoked, thereby confirming the
impression, that the act of parliament was not intended to dispense
with the previous negotiation. And to conclude this part of the
narrative, as late as the twentieth of October, 1826, Mr. Vaughan,
the British minister, upon being interrogated by the then secretary of
state, was totally uninstructed to afford any information, as to the
meaning or intent of the act of July, 1825.
Meantime, in March, more than six months after the passage of
the act of parliament, Mr. Vaughan notified the department of state,
that he had ‘received instructions from his majesty’s government, to
acquaint you that it is preparing to proceed to the important
negotiations between that country and the United States, now
placed in the hands of the American minister, in London.’ * * *
‘The negotiations will therefore be forthwith resumed.’ * * *
Here the negotiations were spoken of without exception of the
colonial question, the most important of them. If it had been
intended to withdraw that, no time could have been more suitable to
announce that intention, but no such annunciation was made.
Mr. Vaughan was informed, that we also would prepare for the
negotiation, (including, of course, the colonial question,) and
Mr. Gallatin was accordingly shortly after sent out, with full powers
and instructions, amicably to settle that question. On his arrival in
England, in the summer of 1826, he was told by the British
government, that they would not negotiate on the colonial question;
that they had made up their mind, from the passage of the act of
July, 1825, not to negotiate about it; and he was informed by the
sarcastic Mr. Canning, that as we had failed to accept the boon
which the British government had then offered, we were then too
late!
Such is the state of the case on which the late secretary of state
so authoritatively pronounces judgment against his own
government, for ‘omitting to accept the terms offered by the act of
parliament, of July, 1825!’ He adds, indeed, ‘after the subject had
been brought before congress, and deliberately acted upon by our
government.’ It was brought before congress in the session of 1825–
6, not at the instance of the American executive, but upon the
spontaneous and ill-judged motion of the gentleman from Maryland,
(Mr. Smith), and Mr. Gallatin was informed that if the bill proposed
by that gentleman had been passed, it would have been
unsatisfactory to the British government.
I have another objection to this nomination. I believe, upon
circumstances which satisfy my mind, that to this gentleman is
principally to be ascribed the introduction of the odious system of
proscription, for the exercise of the elective franchise, in the
government of the United States. I understand that it is the system
on which the party in his own state, of which he is the reputed head,
constantly acts. He was among the first of the secretaries, to apply
that system to the dismission of clerks in his department, known to
me to be highly meritorious, and among them one who is now a
representative in the other house. It is a detestable system, drawn
from the worst periods of the Roman republic, and if it were to be
perpetuated—if the offices, honors, and dignities of the people were
to be put up to a scramble, and to be decided by the results of every
presidential election—our government and institutions, becoming
intolerable, would finally end in a despotism as inexorable as that at
Constantinople.
Sir, the necessity under which we are placed is painful. But it is
no fault of the senate, whose consent and advice are required by the
constitution, to consummate this appointment, that the minister has
been sent out of the United States, without their concurrence.
I hope that the public will not be prejudiced by his rejection, if he
should be rejected. And I feel perfectly assured, that if the
government to which he has been deputed, shall learn that he has
been rejected, because he has there, by his instructions to
Mr. McLane, stained the character of our country, the moral effect of
our decision will greatly outweigh any advantages to be derived from
his negotiations, whatever they may have been intended to be.
END OF VOLUME FIRST.
THE
LIFE AND SPEECHES
OF THE
HON. HENRY CLAY.
COMPILED AND EDITED BY DANIEL MALLORY.
EMBRACING AN EPITOME OF
THE COMPROMISE MEASURES.
AND A FULL REPORT OF
The Obituary Addresses and Funeral Sermon,
DELIVERED IN THE SENATE AND HOUSE OF REPRESENTATIVES OF THE
UNITED STATES.
VOLUME II.
A. S. BARNES & COMPANY,
NEW YORK AND CHICAGO
CONTENTS OF
VOLUME II.
◆ Speech in Defence of the American System.
◆ Speech on the Public Lands.
◆ Speech on the North-eastern Boundary of the United States.
◆ Speech on President Jackson’s Veto of the Bill to Re-charter the United
States Bank.
◆ Speech on introducing the Compromise Tariff Bill.
◆ Speech in Support of the Compromise Tariff Act.
◆ Speech in Support of the Compromise Act.
◆ Speech on the President’s Message returning the Public Land Bill.
◆ Speech on the Removal of the Public Deposits from the Bank of the
United States.
◆ Speech on the Public Distress caused by the Removal of the Deposits.
◆ Speech on the State of the Country from the Effects of the Removal of
the Deposits.
◆ Speech on the State of the Country.
◆ Speech on our Relations with France.
◆ Speech on our Relations with the Cherokee Indians.
◆ Speech on the Cumberland Road Bill.
◆ Speech on the Appointing and Removing Power.
◆ Speech on the Public Land Bill.
◆ Speech on our Relations with France.
◆ Speech on the Admission of Arkansas into the Union.
◆ Speech on the Fortification Bill.
◆ Speech on Recognising the Independence of Texas.
◆ Speech on the Expunging Resolution.
◆ Speech on the Sub-treasury Bill.
◆ Speech on the Pre-emption Bill.
◆ Speech on the Sub-treasury Scheme.
◆ Speech on the Doctrine of Instruction.
◆ Speech on Petition for the Abolition of Slavery.
◆ Speech at Buffalo, New York.
◆ Speech on the Land Bill proposed by Mr. Calhoun.
◆ Speech on the Sub-treasury Bill.
◆ Speech at the Whig National Convention of Young Men.
◆ Speech on the State of the Country under Van Buren’s Administration.
◆ Speech at the Harrison Convention.
◆ Speech on the Repeal of the Sub-treasury Law.
◆ Speech on the Distribution of Proceeds of the Public Lands.
◆ Speech in Defence of Mr. Webster.
◆ Speech on the Veto of the Fiscal Bank Bill by President Tyler.
◆ Speech on the Bank Veto.
◆ Speech on a General Bankrupt Law.
◆ Speech on the Amendment of the Constitution, respecting the Veto
Power.
◆ Speech on the Compromise Tariff.
◆ Speech on the Tariff and other Measures of Public Policy.
◆ Valedictory Address to the Senate.
◆ Speech on his Retirement to Private Life.
◆ Speech on Slavery and Abolitionism.
◆ Speech on the Admission of California, &c.
◆ Speech on the Constitution of California, &c.
◆ Speech on the Compromise Measures.
◆ Correspondence, embracing Letters on Various Subjects.
SPEECHES.
IN DEFENCE OF THE
AMERICAN SYSTEM.
IN THE SENATE OF THE UNITED STATES, FEB. 2D, 3D,
AND 6TH, 1832.
[DURING the session of congress in 1832, in consequence of the violent
opposition to the protective tariff then in operation, by South Carolina and other
southern states, various propositions were introduced for the reduction of duties
on imported articles, which finally resulted in the passage of a new tariff law, in
July, 1832. This bill, which was reported in the house of representatives by
Mr. John Quincy Adams, although it was voted for by many southern members, on
the ground of its being a reduction of the former scale of duties, was not
satisfactory to them, and the controversy on the subject of the tariff was not
settled until the following year, when Mr. Clay’s compromise bill was adopted,
providing for a gradual diminution of the tariff of 1832.
In the following speech, Mr. Clay, in reply to Mr. Hayne, of South Carolina, and
others, enters into a minute and careful examination of the American system, and
its effects on the interests of the country; defending, with his usual skill and
eloquence, the doctrine of protection to domestic industry. This effort adds
another monument to his wisdom and fame, which will, we believe, be referred to
by statesmen, who seek the true interests of the country, through all future ages
of the republic.
The resolution offered by Mr. Clay in January, proposing a reduction of duties
on certain imported articles not coming in competition with our manufactures,
which he had supported in the foregoing speech of January eleventh, was still
under consideration.]
IN one sentiment, Mr. President, expressed by the honorable
gentleman from South Carolina (general Hayne), though perhaps not
in the sense intended by him, I entirely concur. I agree with him,
that the decision on the system of policy embraced in this debate,
involves the future destiny of this growing country. One way, I verily
believe, it would lead to deep and general distress, general
bankruptcy, and national ruin, without benefit to any part of the
union; the other, the existing prosperity will be preserved and
augmented, and the nation will continue rapidly to advance in
wealth, power, and greatness, without prejudice to any section of
the confederacy.
Thus viewing the question, I stand here as the humble but
zealous advocate, not of the interests of one state, or seven states
only, but of the whole union. And never before have I felt, more
intensely, the overpowering weight of that share of responsibility
which belongs to me in these deliberations. Never before have I had
more occasion than I now have, to lament my want of those
intellectual powers, the possession of which might enable me to
unfold to this senate and to illustrate to this people great truths,
intimately connected with the lasting welfare of my country.
I should, indeed, sink overwhelmed and subdued beneath the
appalling magnitude of the task which lies before me, if I did not feel
myself sustained and fortified by a thorough consciousness of the
justness of the cause which I have espoused, and by a persuasion,
I hope not presumptuous, that it has the approbation of that
Providence who has so often smiled upon these United States.
Eight years ago, it was my painful duty to present to the other
house of congress an unexaggerated picture of the general distress
pervading the whole land. We must all yet remember some of its
frightful features. We all know that the people were then oppressed,
and borne down by an enormous load of debt; that the value of
property was at the lowest point of depression; that ruinous sales
and sacrifices were every where made of real estate; that stop laws,
and relief laws, and paper money were adopted, to save the people
from impending destruction; that a deficit in the public revenue
existed, which compelled government to seize upon, and divert from
its legitimate object, the appropriations to the sinking fund, to
redeem the national debt; and that our commerce and navigation
were threatened with a complete paralysis. In short, sir, if I were to
select any term of seven years since the adoption of the present
constitution which exhibited a scene of the most wide-spread dismay
and desolation, it would be exactly that term of seven years which
immediately preceded the establishment of the tariff of 1824.
I have now to perform the more pleasing task of exhibiting an
imperfect sketch of the existing state of the unparalleled prosperity
of the country. On a general survey, we behold cultivation extended,
the arts flourishing, the face of the country improved, our people
fully and profitably employed, and the public countenance exhibiting
tranquillity, contentment, and happiness. And if we descend into
particulars, we have the agreeable contemplation of a people out of
debt; land rising slowly in value, but in a secure and salutary degree;
a ready though not extravagant market for all the surplus
productions of our industry; innumerable flocks and herds browsing
and gamboling on ten thousand hills and plains, covered with rich
and verdant grasses; our cities expanded, and whole villages
springing up, as it were, by enchantment; our exports and imports
increased and increasing; our tonnage, foreign and coastwise,
swelling and fully occupied; the rivers of our interior animated by the
perpetual thunder and lightning of countless steamboats; the
currency sound and abundant; the public debt of two wars nearly
redeemed; and, to crown all, the public treasury overflowing,
embarrassing congress, not to find subjects of taxation, but to select
the objects which shall be liberated from the impost. If the term of
seven years were to be selected, of the greatest prosperity which
this people have enjoyed since the establishment of their present
constitution, it would be exactly that period of seven years which
immediately followed the passage of the tariff of 1824.
This transformation of the condition of the country from gloom
and distress to brightness and prosperity, has been mainly the work
of American legislation, fostering American industry, instead of
allowing it to be controlled by foreign legislation, cherishing foreign
industry. The foes of the American system, in 1824, with great
boldness and confidence, predicted, first, the ruin of the public
revenue, and the creation of a necessity to resort to direct taxation;
the gentleman from South Carolina (general Hayne), I believe,
thought that the tariff of 1824 would operate a reduction of revenue
to the large amount of eight millions of dollars; secondly, the
destruction of our navigation; thirdly, the desolation of commercial
cities; and, fourthly, the augmentation of the price of objects of
consumption, and further decline in that of the articles of our
exports. Every prediction which they made has failed, utterly failed.
Instead of the ruin of the public revenue, with which they then
sought to deter us from the adoption of the American system, we
are now threatened with its subversion, by the vast amount of the
public revenue produced by that system. Every branch of our
navigation has increased. As to the desolation of our cities, let us
take, as an example, the condition of the largest and most
commercial of all of them, the great northern capital. I have, in my
hands, the assessed value of real estate in the city of New York,
from 1817 to 1831. This value is canvassed, contested, scrutinized,
and adjudged, by the proper sworn authorities. It is, therefore,
entitled to full credence. During the first term, commencing with
1817, and ending in the year of the passage of the tariff of 1824, the
amount of the value of real estate was, the first year, fifty-seven
million seven hundred and ninety-nine thousand four hundred and
thirty-five dollars, and, after various fluctuations in the intermediate
period, it settled down at fifty-two million nineteen thousand seven
hundred and thirty dollars, exhibiting a decrease, in seven years, of
five million seven hundred and seventy-nine thousand seven
hundred and five dollars. During the first year, of 1825, after the
passage of the tariff, it rose, and, gradually ascending throughout
the whole of the latter period of seven years, it finally, in 1831,
reached the astonishing height of ninety-five million seven hundred
and sixteen thousand four hundred and eighty-five dollars! Now, if it
be said, that this rapid growth of the city of New York was the effect
of foreign commerce, then it was not correctly predicted, in 1824,
that the tariff would destroy foreign commerce, and desolate our
commercial cities. If, on the contrary, it be the effect of internal
trade, then internal trade cannot be justly chargeable with the evil
consequences imputed to it. The truth is, it is the joint effect of both
principles, the domestic industry nourishing the foreign trade, and
the foreign commerce in turn nourishing the domestic industry.
Nowhere more than in New York is the combination of both
principles so completely developed. In the progress of my argument,
I will consider the effect upon the price of commodities produced by
the American system, and show that the very reverse of the
prediction of its foes, in 1824, actually happened.
Whilst we thus behold the entire failure of all that was foretold
against the system, it is a subject of just felicitation to its friends,
that all their anticipations of its benefits have been fulfilled, or are in
progress of fulfilment. The honorable gentleman from South Carolina
has made an allusion to a speech made by me, in 1824, in the other
house, in support of the tariff, and to which, otherwise, I should not
have particularly referred. But I would ask any one, who can now
command the courage to peruse that long production, what principle
there laid down is not true? what prediction then made has been
falsified by practical experience?
It is now proposed to abolish the system, to which we owe so
much of the public prosperity, and it is urged that the arrival of the
period of the redemption of the public debt has been confidently
looked to as presenting a suitable occasion to rid the country of the
evils with which the system is alleged to be fraught. Not an
inattentive observer of passing events, I have been aware, that,
among those who were most early pressing the payment of the
public debt, and, upon that ground, were opposing appropriations to
other great interests, there were some who cared less about the
debt than the accomplishment of other objects. But the people of
the United States have not coupled the payment of their public debt
with the destruction of the protection of their industry, against
foreign laws and foreign industry. They have been accustomed to
regard the extinction of the public debt as relief from a burden, and
not as the infliction of a curse. If it is to be attended or followed by
the subversion of the American system, and an exposure of our
establishments and our productions to the unguarded consequences
of the selfish policy of foreign powers, the payment of the public
debt will be the bitterest of curses. Its fruit will be like the fruit
‘Of that forbidden tree, whose mortal taste
Brought death into the world, and all our woe,
With loss of Eden.’
If the system of protection be founded on principles erroneous in
theory, pernicious in practice, above all, if it be unconstitutional, as is
alleged, it ought to be forthwith abolished, and not a vestige of it
suffered to remain. But, before we sanction this sweeping
denunciation, let us look a little at this system, its magnitude, its
ramifications, its duration, and the high authorities which have
sustained it. We shall see that its foes will have accomplished
comparatively nothing, after having achieved their present aim of
breaking down our iron-founderies, our woollen, cotton, and hemp
manufactories, and our sugar-plantations. The destruction of these
would, undoubtedly, lead to the sacrifice of immense capital, the ruin
of many thousands of our fellow-citizens, and incalculable loss to the
whole community. But their prostration would not disfigure nor
produce greater effect upon the whole system of protection, in all its
branches, than the destruction of the beautiful domes upon the
capitol would occasion to the magnificent edifice which they
surmount. Why, sir, there is scarcely an interest, scarcely a vocation
in society, which is not embraced by the beneficence of this system.
It comprehends our coasting tonnage and trade, from which all
foreign tonnage is absolutely excluded.
It includes all our foreign tonnage, with the inconsiderable
exception made by treaties of reciprocity with a few foreign powers.
It embraces our fisheries, and all our hardy and enterprising
fishermen.
It extends to almost every mechanic art—to tanners,
cordwainers, tailors, cabinet-makers, hatters, tinners, brass-workers,
clock-makers, coach-makers, tallow-chandlers, trace-makers, rope-
makers, cork-cutters, tobacconists, whip-makers, paper-makers,
umbrella-makers, glass-blowers, stocking-weavers, butter-makers,
saddle and harness-makers, cutlers, brush-makers, book-binders,
dairy-men, milk-farmers, black-smiths, type-founders, musical
instrument-makers, basket-makers, milliners, potters, chocolate-
makers, floor-cloth-makers, bonnet-makers, hair-cloth-makers,
copper-smiths, pencil-makers, bellows-makers, pocket-book-makers,
card-makers, glue-makers, mustard-makers, lumber-sawyers, saw-
makers, scale-beam-makers, sithe-makers, wood-saw-makers, and
many others. The mechanics enumerated, enjoy a measure of
protection adapted to their several conditions, varying from twenty
to fifty per cent. The extent and importance of some of these
artisans, may be estimated by a few particulars. The tanners,
curriers, boot and shoe makers, and other workers in hides, skins,
and leather, produce an ultimate value per annum of forty millions of
dollars; the manufacturers of hats and caps, produce an annual
value of fifteen millions; the cabinet-makers, twelve millions; the
manufacturers of bonnets and hats for the female sex, lace, artificial
flowers, combs, and so forth, seven millions; and the manufacturers
of glass, five millions.
It extends to all lower Louisiana, the delta of which might as well
be submerged again in the Gulf of Mexico, from which it has been a
gradual conquest, as now to be deprived of the protecting duty upon
its great staple.
It affects the cotton-planter15 himself, and the tobacco-planter,
both of whom enjoy protection.
The total amount of the capital vested in sheep, the land to
sustain them, wool, woollen manufactures, and woollen fabrics, and
the subsistence of the various persons directly or indirectly employed
in the growth and manufacture of the article of wool, is estimated at
one hundred and sixty-seven millions of dollars, and the number of
persons at one hundred and fifty thousand.
The value of iron, considered as a raw material, and of its
manufactures, is estimated at twenty-six millions of dollars per
annum. Cotton goods, exclusive of the capital vested in the
manufacture, and of the cost of the raw material, are believed to
amount, annually, to about twenty millions of dollars.
These estimates have been carefully made, by practical men of
undoubted character, who have brought together and embodied
their information. Anxious to avoid the charge of exaggeration, they
have sometimes placed their estimates below what was believed to
be the actual amount of these interests. With regard to the quantity
of bar and other iron annually produced, it is derived from the
known works themselves; and I know some in western states which
they have omitted in their calculations.
Such are some of the items of this vast system of protection,
which it is now proposed to abandon. We might well pause and
contemplate, if human imagination could conceive the extent of
mischief and ruin from its total overthrow, before we proceed to the
work of destruction. Its duration is worthy also of serious
consideration. Not to go behind the constitution, its date is coeval
with that instrument. It began on the ever-memorable fourth day of
July—the fourth day of July, 1789. The second act which stands
recorded in the statute-book, bearing the illustrious signature of
George Washington, laid the corner-stone of the whole system. That
there might be no mistake about the matter, it was then solemnly
proclaimed to the American people and to the world, that it was
necessary for ‘the encouragement and protection of manufactures,’
that duties should be laid. It is in vain to urge the small amount of
the measure of the protection then extended. The great principle
was then established by the fathers of the constitution, with the
father of his country at their head. And it cannot now be questioned,
that, if the government had not then been new and the subject
untried, a greater measure of protection would have been applied, if
it had been supposed necessary. Shortly after, the master minds of
Jefferson and Hamilton were brought to act on this interesting
subject. Taking views of it appertaining to the departments of
foreign affairs and of the treasury, which they respectively filled,
they presented, severally, reports which yet remain monuments of
their profound wisdom, and came to the same conclusion of
protection to American industry. Mr. Jefferson argued that foreign
restrictions, foreign prohibitions, and foreign high duties, ought to be
met at home by American restrictions, American prohibitions, and
American high duties. Mr. Hamilton, surveying the entire ground, and
looking at the inherent nature of the subject, treated it with an
ability, which, if ever equalled, has not been surpassed, and
earnestly recommended protection.
The wars of the French revolution commenced about this period,
and streams of gold poured into the United States through a
thousand channels, opened or enlarged by the successful commerce
which our neutrality enabled us to prosecute. We forgot or
overlooked, in the general prosperity, the necessity of encouraging
our domestic manufactures. Then came the edicts of Napoleon, and
the British orders in council; and our embargo, non-intercourse, non-
importation, and war, followed in rapid succession. These national
measures, amounting to a total suspension, for the period of their
duration, of our foreign commerce, afforded the most efficacious
encouragement to American manufactures; and accordingly they
every where sprung up. While these measures of restriction and this
state of war continued, the manufacturers were stimulated in their
enterprise by every assurance of support, by public sentiment, and
by legislative resolves. It was about that period (1808) that South
Carolina bore her high testimony to the wisdom of the policy, in an
act of her legislature, the preamble of which, now before me, reads:
‘Whereas, the establishment and encouragement of domestic manufactures, is
conducive to the interests of a state, by adding new incentives to industry, and as
being the means of disposing to advantage the surplus productions of the
agriculturist: and whereas, in the present unexampled state of the world, their
establishment in our country is not only expedient, but politic, in rendering us
independent of foreign nations.’
The legislature, not being competent to afford the most
efficacious aid, by imposing duties on foreign rival articles,
proceeded to incorporate a company.
Peace, under the treaty of Ghent, returned in 1815 but there did
not return with it the golden days which preceded the edicts levelled
at our commerce by Great Britain and France. It found all Europe
tranquilly resuming the arts and the business of civil life. It found
Europe no longer the consumer of our surplus, and the employer of
our navigation, but excluding, or heavily burdening, almost all the
productions of our agriculture, and our rivals in manufactures, in
navigation, and in commerce. It found our country, in short, in a
situation totally different from all the past—new and untried. It
became necessary to adapt our laws, and especially our laws of
impost, to the new circumstances in which we found ourselves.
Accordingly, that eminent and lamented citizen, then at the head of
the treasury, (Mr. Dallas,) was required, by a resolution of the house
of representatives, under date of the twenty-third of February, 1815,
to prepare and report to the succeeding session of congress, a
system of revenue conformable with the actual condition of the
country. He had the circle of a whole year to perform the work,
consulted merchants, manufacturers, and other practical men, and
opened an extensive correspondence. The report which he made at
the session of 1816, was the result of his inquiries and reflections,
and embodies the principles which he thought applicable to the
subject. It has been said, that the tariff of 1816 was a measure of
mere revenue, and that it only reduced the war duties to a peace
standard. It is true, that the question then was, how much and in
what way should the double duties of the war be reduced? Now,
also, the question is, on what articles shall the duties be reduced so
as to subject the amounts of the future revenue to the wants of the
government? Then it was deemed an inquiry of the first importance,
as it should be now, how the reduction should be made, so as to
secure proper encouragement to our domestic industry. That this
was a leading object in the arrangement of the tariff of 1816, I well
remember, and it is demonstrated by the language of Mr. Dallas. He
says, in his report:
‘There are few, if any governments, which do not regard the establishment of
domestic manufactures as a chief object of public policy. The United States have
always so regarded it. * * * * * The demands of the country, while the
acquisitions of supplies from foreign nations was either prohibited or impracticable,
may have afforded a sufficient inducement for this investment of capital, and this
application of labor: but the inducement, in its necessary extent, must fail when
the day of competition returns. Upon that change in the condition of the country,
the preservation of the manufactures, which private citizens under favorable
auspices have constituted the property of the nation, becomes a consideration of
general policy, to be resolved by a recollection of past embarrassments; by the
certainty of an increased difficulty of reinstating, upon any emergency, the
manufactures which shall be allowed to perish and pass away,’ and so forth.
The measure of protection which he proposed was not adopted,
in regard to some leading articles, and there was great difficulty in
ascertaining what it ought to have been. But the principle was then
distinctly asserted and fully sanctioned.

More Related Content

PDF
Platform Engineering On Kubernetes Meap V09 All 9 Chapters Mauricio Salatino
PDF
Kubernetes up running
PDF
Managing Cloud Native Data On Kubernetes 1st Early Release Jeff Carpenter Pat...
PPTX
Best Kubernetes Consultant In USA.pptx
PPTX
Kubernetes.pptx
PPTX
Kubernetes.pptx
PDF
6 Steps Functionality Hacks To Kubernetes - 2023 Update.pdf
DOCX
Kubernetes - An introduction
Platform Engineering On Kubernetes Meap V09 All 9 Chapters Mauricio Salatino
Kubernetes up running
Managing Cloud Native Data On Kubernetes 1st Early Release Jeff Carpenter Pat...
Best Kubernetes Consultant In USA.pptx
Kubernetes.pptx
Kubernetes.pptx
6 Steps Functionality Hacks To Kubernetes - 2023 Update.pdf
Kubernetes - An introduction

Similar to Kubernetes Patterns: Reusable Elements for Designing Cloud Native Applications, 2nd Edition Bilgin Ibryam (20)

PDF
[Mobi] Kubernetes: Up & Running
PDF
Managing Kubernetes operating Kubernetes clusters in the real world First Edi...
PDF
Future of Kubernetes and its Impact on Technology Industry.pdf
PDF
Continuous Delivery For Kubernetes Chapters 1 2 Mauricio Salatino
PPTX
Why is Kubernetes considered the next generation application platform
PDF
How docker & kubernetes can optimize the cost of hosting
PPTX
How Kubernetes Consultants Help to Overcome Different Challenges.pptx
PDF
OpenShift for Developers: A Guide for Impatient Beginners 2nd Edition Joshua ...
PDF
Kubernetes Up Running Dive Into The Future Of Infrastructure Third Edition 3r...
PDF
Kubernetes in The Enterprise
PPTX
Kubernetes: A Top Notch Automation Solution
PDF
Download full Managing Kubernetes operating Kubernetes clusters in the real w...
DOCX
ROIESolutions /Why Kubernetes is Growing
PDF
Modern big data and machine learning in the era of cloud, docker and kubernetes
PDF
Certified Kubernetes Administrator Cka Study Guide Second Early Release Benja...
PDF
NET Microservices Architecture for Containerized NET Applications Cesar De La...
PPSX
Kubernetes in Action, Second Edition
PDF
GitOps Cookbook (Third Early Release) Natale Vinto
PDF
Cloud Native Infrastructure with Azure: Building and Managing Cloud Native Ap...
[Mobi] Kubernetes: Up & Running
Managing Kubernetes operating Kubernetes clusters in the real world First Edi...
Future of Kubernetes and its Impact on Technology Industry.pdf
Continuous Delivery For Kubernetes Chapters 1 2 Mauricio Salatino
Why is Kubernetes considered the next generation application platform
How docker & kubernetes can optimize the cost of hosting
How Kubernetes Consultants Help to Overcome Different Challenges.pptx
OpenShift for Developers: A Guide for Impatient Beginners 2nd Edition Joshua ...
Kubernetes Up Running Dive Into The Future Of Infrastructure Third Edition 3r...
Kubernetes in The Enterprise
Kubernetes: A Top Notch Automation Solution
Download full Managing Kubernetes operating Kubernetes clusters in the real w...
ROIESolutions /Why Kubernetes is Growing
Modern big data and machine learning in the era of cloud, docker and kubernetes
Certified Kubernetes Administrator Cka Study Guide Second Early Release Benja...
NET Microservices Architecture for Containerized NET Applications Cesar De La...
Kubernetes in Action, Second Edition
GitOps Cookbook (Third Early Release) Natale Vinto
Cloud Native Infrastructure with Azure: Building and Managing Cloud Native Ap...
Ad

Recently uploaded (20)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Classroom Observation Tools for Teachers
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Cell Structure & Organelles in detailed.
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Lesson notes of climatology university.
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Supply Chain Operations Speaking Notes -ICLT Program
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Chinmaya Tiranga quiz Grand Finale.pdf
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
History, Philosophy and sociology of education (1).pptx
Microbial disease of the cardiovascular and lymphatic systems
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
A systematic review of self-coping strategies used by university students to ...
Classroom Observation Tools for Teachers
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Cell Structure & Organelles in detailed.
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
2.FourierTransform-ShortQuestionswithAnswers.pdf
01-Introduction-to-Information-Management.pdf
Lesson notes of climatology university.
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Ad

Kubernetes Patterns: Reusable Elements for Designing Cloud Native Applications, 2nd Edition Bilgin Ibryam

  • 1. Kubernetes Patterns: Reusable Elements for Designing Cloud Native Applications, 2nd Edition Bilgin Ibryam install download https://ebookmeta.com/product/kubernetes-patterns-reusable- elements-for-designing-cloud-native-applications-2nd-edition- bilgin-ibryam/ Download more ebook from https://ebookmeta.com
  • 2. We believe these products will be a great fit for you. Click the link to download now, or visit ebookmeta.com to discover even more! Kubernetes Patterns Reusable Elements for Designing Cloud Native Applications 2nd Ed 2nd Edition Bilgin Ibryam https://ebookmeta.com/product/kubernetes-patterns-reusable- elements-for-designing-cloud-native-applications-2nd-ed-2nd- edition-bilgin-ibryam/ Cloud Native DevOps with Kubernetes, 2nd Edition Justin Domingus https://ebookmeta.com/product/cloud-native-devops-with- kubernetes-2nd-edition-justin-domingus/ Cloud Native Devops with Kubernetes: Building, Deploying, and Scaling Modern Applications in the Cloud, 2nd Edition Justin Domingus & John Arundel https://ebookmeta.com/product/cloud-native-devops-with- kubernetes-building-deploying-and-scaling-modern-applications-in- the-cloud-2nd-edition-justin-domingus-john-arundel/ Hoodwinking Hope 1st Edition Aditya Shah https://ebookmeta.com/product/hoodwinking-hope-1st-edition- aditya-shah/
  • 3. Psychoanalysis as an Ethical Process 1st Edition Robert P. Drozek https://ebookmeta.com/product/psychoanalysis-as-an-ethical- process-1st-edition-robert-p-drozek/ The Argentine Economy: An Economic History of Argentina Aldo Ferrer https://ebookmeta.com/product/the-argentine-economy-an-economic- history-of-argentina-aldo-ferrer/ Without a Stitch Monster Between the Sheets Book 14 Season 2 1st Edition Honey Phillips https://ebookmeta.com/product/without-a-stitch-monster-between- the-sheets-book-14-season-2-1st-edition-honey-phillips/ Machine Learning The Basics Machine Learning Foundations Methodologies and Applications Alexander Jung https://ebookmeta.com/product/machine-learning-the-basics- machine-learning-foundations-methodologies-and-applications- alexander-jung-2/ Modern Cryptography Applied Mathematics for Encryption and Information Security 1st Edition William Easttom https://ebookmeta.com/product/modern-cryptography-applied- mathematics-for-encryption-and-information-security-1st-edition- william-easttom/
  • 4. Health Norms and the Governance of Global Development The Invention of Global Health 1st Edition Anders Granmo https://ebookmeta.com/product/health-norms-and-the-governance-of- global-development-the-invention-of-global-health-1st-edition- anders-granmo/
  • 6. Kubernetes Patterns SECOND EDITION Reusable Elements for Designing Cloud Native Applications Bilgin Ibryam and Roland Huß
  • 7. Kubernetes Patterns by Bilgin Ibryam and Roland Huß Copyright © 2023 Bilgin Ibryam and Roland Huß. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Acquisitions Editor: John Devins Development Editor: Rita Fernando Production Editor: Beth Kelly Copyeditor: Piper Editorial Consulting, LLC Proofreader: Sharon Wilkey Indexer: Judy McConville Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Kate Dullea April 2019: First Edition March 2023: Second Edition
  • 8. Revision History for the Second Edition 2023-03-25: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781098131685 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Kubernetes Patterns, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the authors and do not represent the publisher’s views. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. This work is part of a collaboration between O’Reilly and Red Hat. See our statement of editorial independence. 978-1-098-13168-5 [LSI]
  • 9. Foreword When Craig, Joe, and I started Kubernetes nearly eight years ago, I think we all recognized its power to transform the way the world developed and delivered software. I don’t think we knew, or even hoped to believe, how quickly this transformation would come. Kubernetes is now the foundation for the development of portable, reliable systems spanning the major public clouds, private clouds, and bare-metal environments. However, even as Kubernetes has become ubiquitous to the point where you can spin up a cluster in the cloud in less than five minutes, it is still far less obvious to determine where to go once you have created that cluster. It is fantastic that we have seen such significant strides forward in the operationalization of Kubernetes itself, but it is only a part of the solution. It is the foundation on which applications will be built, and it provides a large library of APIs and tools for building these applications, but it does little to provide the application architect or developer with any hints or guidance for how these various pieces can be combined into a complete, reliable system that satisfies their business needs and goals. Although the necessary perspective and experience for what to do with your Kubernetes cluster can be achieved through past experience with similar systems, or via trial and error, this is expensive both in terms of time and the quality of systems delivered to our end users. When you are starting to deliver mission-critical services on top of a system like Kubernetes, learning your way via trial and error simply takes too much time and results in very real problems of downtime and disruption. This then is why Bilgin and Roland’s book is so valuable. Kubernetes Patterns enables you to learn from the previous experience that we have encoded into the APIs and tools that make up Kubernetes. Kubernetes is the by-product of the community’s experience building and delivering many different, reliable distributed systems in a variety of different environments. Each object and capability added
  • 10. to Kubernetes represents a foundational tool that has been designed and purpose-built to solve a specific need for the software designer. This book explains how the concepts in Kubernetes solve real-world problems and how to adapt and use these concepts to build the system that you are working on today. In developing Kubernetes, we always said that our North Star was making the development of distributed systems a CS 101 exercise. If we have managed to achieve that goal successfully, it is books like this one that are the textbooks for such a class. Bilgin and Roland have captured the essential tools of the Kubernetes developer and distilled them into segments that are easy to approach and consume. As you finish this book, you will become aware not just of the components available to you in Kubernetes but also the “why” and “how” of building systems with those components. Brendan Burns Cofounder, Kubernetes
  • 11. Preface With the mainstream adoption of microservices and containers in recent years, the way we design, develop, and run software has changed radically. Today’s applications are optimized for availability, scalability, and speed-to-market. Driven by these new requirements, today’s modern applications require a different set of patterns and practices. This book aims to help developers discover and learn about the most common patterns for creating cloud native applications with Kubernetes. First, let’s take a brief look at the two primary ingredients of this book: Kubernetes and design patterns. Kubernetes Kubernetes is a container orchestration platform. The origin of Kubernetes lies somewhere in the Google data centers where Google’s internal container orchestration platform, Borg, was born. Google used Borg for many years to run its applications. In 2014, Google decided to transfer its experience with Borg into a new open source project called “Kubernetes” (Greek for “helmsman” or “pilot”). In 2015, it became the first project donated to the newly founded Cloud Native Computing Foundation (CNCF). From the start, Kubernetes gained a whole community of users, and the number of contributors grew incredibly fast. Today, Kubernetes is considered one of the most popular projects on GitHub. It is fair to claim that Kubernetes is the most commonly used and feature-rich container orchestration platform. Kubernetes also forms the foundation of other platforms built on top of it. The most prominent of those Platform-as-a-Service systems is Red Hat OpenShift, which provides various additional capabilities to Kubernetes. These are only
  • 12. some reasons we chose Kubernetes as the reference platform for the cloud native patterns in this book. This book assumes you have some basic knowledge of Kubernetes. In Chapter 1, we recapitulate the core Kubernetes concepts and lay the foundation for the following patterns. Design Patterns The concept of design patterns dates back to the 1970s and is from the field of architecture. Christopher Alexander, an architect and system theorist, and his team published the groundbreaking A Pattern Language (Oxford University Press) in 1977, which describes architectural patterns for creating towns, buildings, and other construction projects. Sometime later, this idea was adopted by the newly formed software industry. The most famous book in this area is Design Patterns—Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides— the Gang of Four (Addison-Wesley). When we talk about the famous Singleton, Factories, or Delegation patterns, it’s because of this defining work. Many other great pattern books have been written since then for various fields with different levels of granularity, like Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf (Addison-Wesley) or Patterns of Enterprise Application Architecture by Martin Fowler (Addison-Wesley). In short, a pattern describes a repeatable solution to a problem.1 This definition works for the patterns we describe in this book, except that we probably don’t have as much variability in our solutions. A pattern is different from a recipe because instead of giving step-by-step instructions to solve a problem, it provides a blueprint for solving a whole class of similar problems. For example, the Alexandrian pattern Beer Hall describes how public drinking halls should be constructed where “strangers and friends are drinking companions” and not “anchors of the lonely.” All halls built after this
  • 13. pattern look different but share common characteristics, such as open alcoves for groups of four to eight and a place where a hundred people can meet to enjoy beverages, music, and other activities. However, a pattern does more than provide a solution. It is also about forming a language. The patterns in this book form a dense, noun-centric language in which each pattern carries a unique name. When this language is established, these names automatically evoke similar mental representations when people speak about these patterns. For example, when we talk about a table, anyone speaking English assumes we are talking about a piece of wood with four legs and a top on which you can put things. The same thing happens in software engineering when discussing a “factory.” In an object- oriented programming language context, we immediately associate with a “factory” an object that produces other objects. Because we immediately know the solution behind the pattern, we can move on to tackle yet-unsolved problems. There are also other characteristics of a pattern language. For example, patterns are interconnected and can overlap so that they cover most of the problem space. Also, as already laid out in the original A Pattern Language, patterns have a different level of granularity and scope. More general patterns cover an extensive problem space and provide rough guidance on how to solve the problem. Granular patterns have a very concrete solution proposal but are less widely applicable. This book contains all sorts of patterns, and many patterns reference other patterns or may even include other patterns as part of the solution. Another feature of patterns is that they follow a rigid format. However, each author defines a different form; unfortunately, there is no common standard for how patterns should be laid out. Martin Fowler gives an excellent overview of the formats used for pattern languages at “Writing Software Patterns”.
  • 15. How This Book Is Structured We chose a simple pattern format for this book. We do not follow any particular pattern description language. For each pattern, we use the following structure: Name Each pattern carries a name, which is also the chapter’s title. The name is the center of the pattern’s language. Problem This section gives the broader context and describes the pattern space in detail. Solution This section shows how the pattern solves the problem in a Kubernetes-specific way. This section also contains cross- references to other patterns that are either related or part of the given pattern. Discussion This section includes a discussion about the advantages and disadvantages of the solution for the given context. More Information This final section contains additional information sources related to the pattern. We organized the patterns in this book as follows: Part I, “Foundational Patterns”, covers the core concepts of Kubernetes. These are the underlying principles and practices
  • 16. for building container-based cloud native applications. Part II, “Behavioral Patterns”, describes patterns that build on top of foundational patterns and add the runtime aspect concepts of managing various types of containers. Part III, “Structural Patterns”, contains patterns related to organizing containers within a Pod, which is the atom of the Kubernetes platform. Part IV, “Configuration Patterns”, gives insight into the various ways application configuration can be handled in Kubernetes. These are granular patterns, including concrete recipes for connecting applications to their configuration. Part V, “Security Patterns”, addresses various security concerns that arise when an application is containerized and deployed on Kubernetes. Part VI, “Advanced Patterns”, is a collection of advanced concepts, such as how the platform itself can be extended or how to build container images directly within the cluster. Depending on the context, the same pattern might fit into several categories. Every pattern chapter is self-contained; you can read chapters in isolation and in any order.
  • 17. Who This Book Is For This book is for developers who want to design and develop cloud native applications and use Kubernetes as the platform. It is most suitable for readers who have some basic familiarity with containers and Kubernetes concepts and want to take it to the next level. However, you don’t need to know the low-level details of Kubernetes to understand the use cases and patterns. Architects, consultants, and other technical personnel will also benefit from the repeatable patterns described here. The book is based on use cases and lessons learned from real-world projects. It is an accumulation of best practices and patterns after years of working in this space. We want to help you understand the Kubernetes-first mindset and create better cloud native applications —not reinvent the wheel. It is written in a relaxed style and is similar to a series of essays that can be read independently. Let’s briefly look at what this book is not: This book is not an introduction to Kubernetes, nor is it a reference manual. We touch on many Kubernetes features and explain them in some detail, but we are focusing on the concepts behind those features. Chapter 1, “Introduction”, offers a brief refresher on Kubernetes basics. If you are looking for a comprehensive book on Kubernetes, we highly recommend Kubernetes in Action by Marko Lukša (Manning Publications). This book is not a step-by-step guide on how to set up a Kubernetes cluster itself. Every example assumes you have Kubernetes up and running. You have several options for trying out the examples. If you are interested in learning how to set up a Kubernetes cluster, we recommend Kubernetes: Up and Running by Brendan Burns, Joe Beda, Kelsey Hightower, and Lachlan Evenson (O’Reilly).
  • 18. This book is not about operating and governing a Kubernetes cluster for other teams. We deliberately skipped administrative and operational aspects of Kubernetes and took a developer- first view into Kubernetes. This book can help operations teams understand how a developer uses Kubernetes, but it is not sufficient for administering and automating a Kubernetes cluster. If you are interested in learning how to operate a Kubernetes cluster, we recommend Kubernetes Best Practices by Brendan Burns, Eddie Villalba, Dave Strebel, and Lachlan Evenson (O’Reilly). What You Will Learn There’s a lot to discover in this book. Some patterns may read like excerpts from a Kubernetes manual at first glance, but upon closer look, you’ll see the patterns are presented from a conceptual angle not found in other books on the topic. Other patterns are explained with detailed steps to solve a concrete problem, as in Part IV, “Configuration Patterns”. In some chapters, we explain Kubernetes features that don’t fit nicely into a pattern definition. Don’t get hung up on whether it is a pattern or a feature. In all chapters, we look at the forces involved from the first principles and focus on the use cases, lessons learned, and best practices. That is the valuable part. Regardless of the pattern granularity, you will learn everything Kubernetes offers for each particular pattern, with plenty of examples to illustrate the concepts. All these examples have been tested, and we tell you how to get the complete source code in “Using Code Examples”. What’s New in the Second Edition The Kubernetes ecosystem has continued to grow since the first edition came out four years ago. As a result, there have been many
  • 19. Kubernetes releases, and more tools and patterns for using Kubernetes have become de facto standards. Fortunately, most of the patterns described in our book have stood the test of time and remain valid. Therefore, we have updated these patterns, added new features up to Kubernetes 1.26, and removed obsolete and deprecated parts. For the most part, only minor changes were necessary, except for Chapter 29, “Elastic Scale”, and Chapter 30, “Image Builder”, which underwent significant changes due to new developments in these areas. Additionally, we have included five new patterns and introduced a new category, Part V, “Security Patterns”, which addresses a gap in the first edition and provides important security-related patterns for developers. Our GitHub examples have been updated and extended. And, lastly, we added 50% more content for our readers to enjoy. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. As mentioned, patterns form a simple, interconnected language. To emphasize this web of patterns, each pattern is capitalized and set in italics, (e.g., Sidecar). When a pattern name is also a Kubernetes
  • 20. core concept (such as Init Container or Controller), we use this specific formatting only when we directly reference the pattern itself. Where it makes sense, we also interlink pattern chapters for ease of navigation. We also use the following conventions: Everything you can type in a shell or editor is rendered in constant width font. Kubernetes resource names are always rendered in uppercase (e.g., Pod). If the resource is a combined name like ConfigMap, we keep it like this in favor of the more natural “config map” for clarity and to make it clear that it refers to a Kubernetes concept. Sometimes, a Kubernetes resource name is identical to a common concept like “service” or “node.” In these cases, we use the resource name format only when referring to the resource itself. TIP This element signifies a tip or suggestion. NOTE This element signifies a general note. WARNING This element indicates a warning or caution.
  • 21. Using Code Examples Every pattern is backed with fully executable examples, which you can find on the accompanying web page. You can find the link to each pattern’s example in each chapter’s “More Information” section. The “More Information” section also contains links to further information related to the pattern. We keep these lists updated in the example repository. The source code for all examples in this book is available on GitHub. The repository and the website also have pointers and instructions on how to get a Kubernetes cluster to try out the examples. Please look at the provided resource files when you go through the examples. They contain many valuable comments that will further your understanding of the example code. Many examples use a REST service called random-generator that returns random numbers when called. It is uniquely crafted to play well with the examples in this book. Its source can be found on GitHub as well, and its container image k8spatterns/random- generator is hosted on Docker Hub. We use a JSON path notation to describe resource fields (e.g., .spec.replicas points to the replicas field of the resource’s spec section). If you find an issue in the example code or documentation or have a question, don’t hesitate to open a ticket at the GitHub issue tracker. We monitor these GitHub issues and are happy to answer any questions. All example code is distributed under the Creative Commons Attribution 4.0 (CC BY 4.0) license. The code is free to use, and you can share and adapt it for commercial and noncommercial projects. However, you should give attribution back to this book if you copy or redistribute the example code.
  • 22. This attribution can be a reference to the book, including title, author, publisher, and ISBN, as in “Kubernetes Patterns, 2nd Edition, by Bilgin Ibryam and Roland Huß (O’Reilly). Copyright 2023 Bilgin Ibryam and Roland Huß, 978-1-098-13168-5.” Alternatively, add a link to the accompanying website along with a copyright notice and link to the license. We love code contributions too! If you think we can improve our examples, we are happy to hear from you. Just open a GitHub issue or create a pull request, and let’s start a conversation. O’Reilly Online Learning NOTE For almost 40 years, O’Reilly Media has provided technology and business training, knowledge, and insight to help companies succeed. Our unique network of experts and innovators share their knowledge and expertise through books, articles, conferences, and our online learning platform. O’Reilly’s online learning platform gives you on- demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from O’Reilly and 200+ other publishers. For more information, please visit http://oreilly.com. How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc.
  • 23. 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) We have a web page for this book where we list errata, examples, and additional information. You can access this page at https://oreil.ly/kubernetes_patterns-2e. Email bookquestions@oreilly.com to comment or ask technical questions about this book. For news and information about our books and courses, visit https://oreilly.com. Find us on LinkedIn: https://linkedin.com/company/oreilly-media Follow us on Twitter: https://twitter.com/oreillymedia Watch us on YouTube: https://youtube.com/oreillymedia Follow the authors on Twitter: https://twitter.com/bibryam, https://twitter.com/ro14nd Follow the authors on Mastodon: https://fosstodon.org/@bilgin, https://hachyderm.io/@ro14nd Find the authors on GitHub: https://github.com/bibryam, https://github.com/rhuss Follow their blogs: https://www.ofbizian.com, https://ro14nd.de
  • 24. Acknowledgments Bilgin is forever grateful to his wonderful wife, Ayshe, for her endless support and patience as he worked on yet another book. He is also thankful for his adorable daughters, Selin and Esin, who always know how to bring a smile to his face. You mean the world to him. Finally, Bilgin would like to thank his fantastic coauthor, Roland, for making this project a reality. Roland is deeply grateful for his wife Tanja’s unwavering support and forbearance throughout the writing process, and he also thanks his son Jakob for his encouragement. Furthermore, Roland wishes to extend special recognition to Bilgin for his exceptional insights and writing, without which the book would not have come to fruition. Creating two editions of this book was a long multiyear journey, and we want to thank our reviewers who kept us on the right track. For the first edition, special kudos to Paolo Antinori and Andrea Tarocchi for helping us through the journey. Big thanks to Marko Lukša, Brandon Philips, Michael Hüttermann, Brian Gracely, Andrew Block, Jiri Kremser, Tobias Schneck, and Rick Wagner, who supported us with their expertise and advice. Last but not least, big thanks to our editors Virginia Wilson, John Devins, Katherine Tozer, Christina Edwards, and all the awesome folks at O’Reilly for helping us push this book over the finish line. Completing the second edition was no easy feat, and we are grateful to all who supported us in finishing it. We extend our thanks to our technical reviewers, Ali Ok, Dávid Šimanský, Zbyněk Roubalík, Erkan Yanar, Christoph Stäbler, Andrew Block, and Adam Kaplan, as well as to our development editor, Rita Fernando, for her patience and encouragement throughout the whole process. Many kudos go out to the O’Reilly production team, especially Beth Kelly, Kim Sandoval, and Judith McConville, for their meticulous attention in finalizing the book.
  • 25. We want to express a special thank you to Abhishek Koserwal for his tireless and dedicated efforts in Chapter 26, “Access Control”. His contributions came at a time when we needed them the most and made an impact. 1 Alexander and his team defined the original meaning in the context of architecture as follows: “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.” (A Pattern Language, Christopher Alexander et al., 1977.)
  • 26. Chapter 1. Introduction In this introductory chapter, we set the scene for the rest of the book by explaining a few of the core Kubernetes concepts used for designing and implementing cloud native applications. Understanding these new abstractions, and the related principles and patterns from this book, is key to building distributed applications that can be automatable by Kubernetes. This chapter is not a prerequisite for understanding the patterns described later. Readers familiar with Kubernetes concepts can skip it and jump straight into the pattern category of interest. The Path to Cloud Native Microservices is among the most popular architectural styles for creating cloud native applications. They tackle software complexity through modularization of business capabilities and trading development complexity for operational complexity. That is why a key prerequisite for becoming successful with microservices is to create applications that can be operated at scale through Kubernetes. As part of the microservices movement, there is a tremendous amount of theory, techniques, and supplemental tools for creating microservices from scratch or for splitting monoliths into microservices. Most of these practices are based on Domain-Driven Design by Eric Evans (Addison-Wesley) and the concepts of bounded contexts and aggregates. Bounded contexts deal with large models by dividing them into different components, and aggregates help to further group bounded contexts into modules with defined transaction boundaries. However, in addition to these business domain considerations, for each distributed system—whether it is
  • 27. based on microservices or not—there are also technical concerns around its external structure, and runtime coupling. Containers and container orchestrators such as Kubernetes bring in new primitives and abstractions to address the concerns of distributed applications, and here we discuss the various options to consider when putting a distributed system into Kubernetes. Throughout this book, we look at container and platform interactions by treating the containers as black boxes. However, we created this section to emphasize the importance of what goes into containers. Containers and cloud native platforms bring tremendous benefits to your distributed applications, but if all you put into containers is rubbish, you will get distributed rubbish at scale. Figure 1-1 shows the mixture of the skills required for creating good cloud native applications and where Kubernetes patterns fit in.
  • 28. Figure 1-1. The path to cloud native At a high level, creating good cloud native applications requires familiarity with multiple design techniques: At the lowest code level, every variable you define, every method you create, and every class you decide to instantiate plays a role in the long-term maintenance of the application. No matter what container technology and orchestration platform you use, the development team and the artifacts they create will have the most impact. It is important to grow developers who
  • 29. strive to write clean code, have the right number of automated tests, constantly refactor to improve code quality, and are guided by Software Craftsmanship principles at heart. Domain-driven design is about approaching software design from a business perspective with the intention of keeping the architecture as close to the real world as possible. This approach works best for object-oriented programming languages, but there are also other good ways to model and design software for real-world problems. A model with the right business and transaction boundaries, easy-to-consume interfaces, and rich APIs is the foundation for successful containerization and automation later. The hexagonal architecture and its variations, such as Onion and Clean architectures, improve the flexibility and maintainability of applications by decoupling the application components and providing standardized interfaces for interacting with them. By decoupling the core business logic of a system from the surrounding infrastructure, hexagonal architecture makes it easier to port the system to different environments or platforms. These architectures complement domain-driven design and help arrange application code with distinct boundaries and externalized infrastructure dependencies. The microservices architectural style and the twelve-factor app methodology very quickly evolved to become the norm for creating distributed applications and they provide valuable principles and practices for designing changing distributed applications. Applying these principles lets you create implementations that are optimized for scale, resiliency, and pace of change, which are common requirements for any modern software today.
  • 30. Containers were very quickly adopted as the standard way of packaging and running distributed applications, whether these are microservices or functions. Creating modular, reusable containers that are good cloud native citizens is another fundamental prerequisite. Cloud native is a term used to describe principles, patterns, and tools to automate containerized applications at scale. We use cloud native interchangeably with Kubernetes, which is the most popular open source cloud native platform available today. In this book, we are not covering clean code, domain-driven design, hexagonal architecture, or microservices. We are focusing only on the patterns and practices addressing the concerns of the container orchestration. But for these patterns to be effective, your application needs to be designed well from the inside by using clean code practices, domain-driven design, hexagonal architecture-like isolation of external dependencies, microservices principles, and other relevant design techniques. Distributed Primitives To explain what we mean by new abstractions and primitives, here we compare them with the well-known object-oriented programming (OOP), and Java specifically. In the OOP universe, we have concepts such as class, object, package, inheritance, encapsulation, and polymorphism. Then the Java runtime provides specific features and guarantees on how it manages the lifecycle of our objects and the application as a whole. The Java language and the Java Virtual Machine (JVM) provide local, in-process building blocks for creating applications. Kubernetes adds an entirely new dimension to this well-known mindset by offering a new set of distributed primitives and runtime for building distributed systems that spread across multiple nodes and processes. With
  • 31. Kubernetes at hand, we don’t rely only on the local primitives to implement the whole application behavior. We still need to use the object-oriented building blocks to create the components of the distributed application, but we can also use Kubernetes primitives for some of the application behaviors. Table 1- 1 shows how various development concepts are realized differently with local and distributed primitives in the JVM and Kubernetes, respectively.
  • 32. Table 1-1. Local and distributed primitives Concept Local primitive Distributed primitive Behavior encapsulation Class Container image Behavior instance Object Container Unit of reuse .jar Container image Composition Class A contains Class B Sidecar pattern Inheritance Class A extends Class B A container’s FROM parent image Deployment unit .jar/.war/.ear Pod Buildtime/Runtime isolation Module, package, class Namespace, Pod, container Initialization preconditions Constructor Init container Postinitialization trigger Init-method postStart Predestroy trigger Destroy-method preStop Cleanup procedure finalize(), shutdown hook -
  • 33. Concept Local primitive Distributed primitive Asynchronous and parallel execution ThreadPoolExecutor, ForkJoinPool Job Periodic task Timer, ScheduledExec utorService CronJob Background task Daemon thread DaemonSet Configuration management System.getenv(), Pro perties ConfigMap, Secret The in-process primitives and the distributed primitives have commonalities, but they are not directly comparable and replaceable. They operate at different abstraction levels and have different preconditions and guarantees. Some primitives are supposed to be used together. For example, we still have to use classes to create objects and put them into container images. However, some other primitives such as CronJob in Kubernetes can completely replace the ExecutorService behavior in Java. Next, let’s see a few distributed abstractions and primitives from Kubernetes that are especially interesting for application developers. Containers Containers are the building blocks for Kubernetes-based cloud native applications. If we make a comparison with OOP and Java, container images are like classes, and containers are like objects. The same way we can extend classes to reuse and alter behavior, we can have
  • 34. container images that extend other container images to reuse and alter behavior. The same way we can do object composition and use functionality, we can do container compositions by putting containers into a Pod and using collaborating containers. If we continue the comparison, Kubernetes would be like the JVM but spread over multiple hosts, and it would be responsible for running and managing the containers. Init containers would be something like object constructors; DaemonSets would be similar to daemon threads that run in the background (like the Java Garbage Collector, for example). A Pod would be something similar to an Inversion of Control (IoC) context (Spring Framework, for example), where multiple running objects share a managed lifecycle and can access one another directly. The parallel doesn’t go much further, but the point is that containers play a fundamental role in Kubernetes, and creating modularized, reusable, single-purpose container images is fundamental to the long-term success of any project and even the containers’ ecosystem as a whole. Apart from the technical characteristics of a container image that provide packaging and isolation, what does a container represent, and what is its purpose in the context of a distributed application? Here are a few suggestions on how to look at containers: A container image is the unit of functionality that addresses a single concern. A container image is owned by one team and has its own release cycle. A container image is self-contained and defines and carries its runtime dependencies. A container image is immutable, and once it is built, it does not change; it is configured.
  • 35. A container image defines its resource requirements and external dependencies. A container image has well-defined APIs to expose its functionality. A container typically runs as a single Unix process. A container is disposable and safe to scale up or down at any moment. In addition to all these characteristics, a proper container image is modular. It is parameterized and created for reuse in the different environments in which it is going to run. Having small, modular, and reusable container images leads to the creation of more specialized and stable container images in the long term, similar to a great reusable library in the programming language world. Pods Looking at the characteristics of containers, we can see that they are a perfect match for implementing the microservices principles. A container image provides a single unit of functionality, belongs to a single team, has an independent release cycle, and provides deployment and runtime isolation. Most of the time, one microservice corresponds to one container image. However, most cloud native platforms offer another primitive for managing the lifecycle of a group of containers—in Kubernetes, it is called a Pod. A Pod is an atomic unit of scheduling, deployment, and runtime isolation for a group of containers. All containers in a Pod are always scheduled to the same host, are deployed and scaled together, and can also share filesystem, networking, and process namespaces. This joint lifecycle allows the containers in a Pod to interact with one another over the filesystem or through networking via localhost or host interprocess communication mechanisms if desired (for performance reasons, for example). A Pod also
  • 36. represents a security boundary for an application. While it is possible to have containers with varying security parameters in the same Pod, typically all containers would have the same access level, network segmentation, and identity. As you can see in Figure 1-2, at development and build time, a microservice corresponds to a container image that one team develops and releases. But at runtime, a microservice is represented by a Pod, which is the unit of deployment, placement, and scaling. The only way to run a container—whether for scale or migration—is through the Pod abstraction. Sometimes a Pod contains more than one container. In one such example, a containerized microservice uses a helper container at runtime, as Chapter 16, “Sidecar”, demonstrates. Figure 1-2. A Pod as the deployment and management unit Containers, Pods, and their unique characteristics offer a new set of patterns and principles for designing microservices-based
  • 37. applications. We saw some of the characteristics of well-designed containers; now let’s look at some characteristics of a Pod: A Pod is the atomic unit of scheduling. That means the scheduler tries to find a host that satisfies the requirements of all containers that belong to the Pod (we cover some specifics around init containers in Chapter 15, “Init Container”). If you create a Pod with many containers, the scheduler needs to find a host that has enough resources to satisfy all container demands combined. This scheduling process is described in Chapter 6, “Automated Placement”. A Pod ensures colocation of containers. Thanks to the colocation, containers in the same Pod have additional means to interact with one another. The most common ways of communicating include using a shared local filesystem for exchanging data, using the localhost network interface, or using some host interprocess communication (IPC) mechanism for high-performance interactions. A Pod has an IP address, name, and port range that are shared by all containers belonging to it. That means containers in the same Pod have to be carefully configured to avoid port clashes, in the same way that parallel, running Unix processes have to take care when sharing the networking space on a host. A Pod is the atom of Kubernetes where your application lives, but you don’t access Pods directly—that is where Services enter the scene. Services Pods are ephemeral. They come and go at any time for all sorts of reasons (e.g., scaling up and down, failing container health checks, node migrations). A Pod IP address is known only after it is scheduled and started on a node. A Pod can be rescheduled to a
  • 38. different node if the existing node it is running on is no longer healthy. This means the Pod’s network address may change over the life of an application, and there is a need for another primitive for discovery and load balancing. That’s where the Kubernetes Services come into play. The Service is another simple but powerful Kubernetes abstraction that binds the Service name to an IP address and port number permanently. So a Service represents a named entry point for accessing an application. In the most common scenario, the Service serves as the entry point for a set of Pods, but that might not always be the case. The Service is a generic primitive, and it may also point to functionality provided outside the Kubernetes cluster. As such, the Service primitive can be used for Service discovery and load balancing, and it allows altering implementations and scaling without affecting Service consumers. We explain Services in detail in Chapter 13, “Service Discovery”. Labels We have seen that a microservice is a container image at build time but is represented by a Pod at runtime. So what is an application that consists of multiple microservices? Here, Kubernetes offers two more primitives that can help you define the concept of an application: labels and namespaces. Before microservices, an application corresponded to a single deployment unit with a single versioning scheme and release cycle. There was a single file for an application in a .war, .ear, or some other packaging format. But then, applications were split into microservices, which are independently developed, released, run, restarted, or scaled. With microservices, the notion of an application diminishes, and there are no key artifacts or activities that we have to perform at the application level. But if you still need a way to indicate that some independent services belong to an application, labels can be used. Let’s imagine that we have split one monolithic
  • 39. application into three microservices and another one into two microservices. We now have five Pod definitions (and maybe many more Pod instances) that are independent of the development and runtime points of view. However, we may still need to indicate that the first three Pods represent an application and the other two Pods represent another application. Even the Pods may be independent, to provide a business value, but they may depend on one another. For example, one Pod may contain the containers responsible for the frontend, and the other two Pods are responsible for providing the backend functionality. If either of these Pods is down, the application is useless from a business point of view. Using label selectors gives us the ability to query and identify a set of Pods and manage it as one logical unit. Figure 1-3 shows how you can use labels to group the parts of a distributed application into specific subsystems. Figure 1-3. Labels used as an application identity for Pods Here are a few examples where labels can be useful: Labels are used by ReplicaSets to keep some instances of a specific Pod running. That means every Pod definition needs to have a unique combination of labels used for scheduling.
  • 40. Labels are also heavily used by the scheduler. The scheduler uses labels for colocating or spreading Pods to the nodes that satisfy the Pods’ requirements. A label can indicate a logical grouping of a set of Pods and give an application identity to them. In addition to the preceding typical use cases, labels can be used to store metadata. It may be difficult to predict what a label could be used for, but it is best to have enough labels to describe all important aspects of the Pods. For example, having labels to indicate the logical group of an application, the business characteristics and criticality, the specific runtime platform dependencies such as hardware architecture, or location preferences are all useful. Later, these labels can be used by the scheduler for more fine- grained scheduling, or the same labels can be used from the command line for managing the matching Pods at scale. However, you should not go overboard and add too many labels in advance. You can always add them later if needed. Removing labels is much riskier as there is no straightforward way of finding out what a label is used for and what unintended effect such an action may cause.
  • 41. ANNOTATIONS Another primitive very similar to labels is the annotation. Like labels, annotations are organized as a map, but they are intended for specifying nonsearchable metadata and for machine usage rather than human. The information on the annotations is not intended for querying and matching objects. Instead, it is intended for attaching additional metadata to objects from various tools and libraries we want to use. Some examples of using annotations include build IDs, release IDs, image information, timestamps, Git branch names, pull request numbers, image hashes, registry addresses, author names, tooling information, and more. So while labels are used primarily for query matching and performing actions on the matching resources, annotations are used to attach metadata that can be consumed by a machine. Namespaces Another primitive that can also help manage a group of resources is the Kubernetes namespace. As we have described, a namespace may seem similar to a label, but in reality, it is a very different primitive with different characteristics and purposes. Kubernetes namespaces allow you to divide a Kubernetes cluster (which is usually spread across multiple hosts) into a logical pool of resources. Namespaces provide scopes for Kubernetes resources and a mechanism to apply authorizations and other policies to a subsection of the cluster. The most common use case of namespaces is representing different software environments such as development, testing, integration testing, or production. Namespaces can also be used to achieve multitenancy and provide isolation for team workspaces, projects, and even specific applications. But ultimately, for a greater isolation of certain
  • 42. environments, namespaces are not enough, and having separate clusters is common. Typically, there is one nonproduction Kubernetes cluster used for some environments (development, testing, and integration testing) and another production Kubernetes cluster to represent performance testing and production environments. Let’s look at some of the characteristics of namespaces and how they can help us in different scenarios: A namespace is managed as a Kubernetes resource. A namespace provides scope for resources such as containers, Pods, Services, or ReplicaSets. The names of resources need to be unique within a namespace but not across them. By default, namespaces provide scope for resources, but nothing isolates those resources and prevents access from one resource to another. For example, a Pod from a development namespace can access another Pod from a production namespace as long as the Pod IP address is known. “Network isolation across namespaces for creating a lightweight multitenancy solution is described in Chapter 24, “Network Segmentation”. Some other resources, such as namespaces, nodes, and PersistentVolumes, do not belong to namespaces and should have unique cluster-wide names. Each Kubernetes Service belongs to a namespace and gets a corresponding Domain Name Service (DNS) record that has the namespace in the form of <service-name>.<namespace- name>.svc.cluster.local. So the namespace name is in the URL of every Service belonging to the given namespace. That’s one reason it is vital to name namespaces wisely. ResourceQuotas provide constraints that limit the aggregated resource consumption per namespace. With ResourceQuotas, a
  • 43. cluster administrator can control the number of objects per type that are allowed in a namespace. For example, a developer namespace may allow only five ConfigMaps, five Secrets, five Services, five ReplicaSets, five PersistentVolumeClaims, and ten Pods. ResourceQuotas can also limit the total sum of computing resources we can request in a given namespace. For example, in a cluster with a capacity of 32 GB RAM and 16 cores, it is possible to allocate 16 GB RAM and 8 cores for the production namespace, 8 GB RAM and 4 cores for the staging environment, 4 GB RAM and 2 cores for development, and the same amount for testing namespaces. The ability to impose resource constraints decoupled from the shape and the limits of the underlying infrastructure is invaluable. Discussion We’ve only briefly covered a few of the main Kubernetes concepts we use in this book. However, there are more primitives used by developers on a day-by-day basis. For example, if you create a containerized service, there are plenty of Kubernetes abstractions you can use to reap all the benefits of Kubernetes. Keep in mind, these are only a few of the objects used by application developers to integrate a containerized service into Kubernetes. There are plenty of other concepts used primarily by cluster administrators for managing Kubernetes. Figure 1-4 gives an overview of the main Kubernetes resources that are useful for developers.
  • 44. Figure 1-4. Kubernetes concepts for developers With time, these new primitives give birth to new ways of solving problems, and some of these repetitive solutions become patterns. Throughout this book, rather than describing each Kubernetes resource in detail, we will focus on concepts that are proven as patterns. More Information The Twelve-Factor App CNCF Cloud Native Definition v1.0 Hexagonal Architecture
  • 45. Domain-Driven Design: Tackling Complexity in the Heart of Software Best Practices for Writing Dockerfiles Principles of Container-Based Application Design General Container Image Guidelines
  • 46. Part I. Foundational Patterns Foundational patterns describe a number of fundamental principles that containerized applications must comply with in order to become good cloud-native citizens. Adhering to these principles will help ensure that your applications are suitable for automation in cloud- native platforms such as Kubernetes. The patterns described in the following chapters represent the foundational building blocks of distributed container-based Kubernetes-native applications: Chapter 2, “Predictable Demands”, explains why every container should declare its resource requirements and stay confined to the indicated resource boundaries. Chapter 3, “Declarative Deployment”, describes the different application deployment strategies that can be expressed in a declarative way. Chapter 4, “Health Probe”, dictates that every container should implement specific APIs to help the platform observe and maintain the application healthily. Chapter 5, “Managed Lifecycle”, explains why a container should have a way to read the events coming from the platform and conform by reacting to those events. Chapter 6, “Automated Placement”, introduces the Kubernetes scheduling algorithm and the ways to influence the placement decisions from the outside.
  • 47. Chapter 2. Predictable Demands The foundation of successful application deployment, management, and coexistence on a shared cloud environment is dependent on identifying and declaring the application resource requirements and runtime dependencies. This Predictable Demands pattern indicates how you should declare application requirements, whether they are hard runtime dependencies or resource requirements. Declaring your requirements is essential for Kubernetes to find the right place for your application within the cluster. Problem Kubernetes can manage applications written in different programming languages as long as the application can be run in a container. However, different languages have different resource requirements. Typically, a compiled language runs faster and often requires less memory compared to just-in-time runtimes or interpreted languages. Considering that many modern programming languages in the same category have similar resource requirements, from a resource consumption point of view, more important aspects are the domain, the business logic of an application, and the actual implementation details. Besides resource requirements, application runtimes also have dependencies on platform-managed capabilities like data storage or application configuration.
  • 48. Solution Knowing the runtime requirements for a container is important mainly for two reasons. First, with all the runtime dependencies defined and resource demands envisaged, Kubernetes can make intelligent decisions about where to place a container on the cluster for the most efficient hardware utilization. In an environment with shared resources among a large number of processes with different priorities, the only way to ensure a successful coexistence is to know the demands of every process in advance. However, intelligent placement is only one side of the coin. Container resource profiles are also essential for capacity planning. Based on the particular service demands and the total number of services, we can do some capacity planning for different environments and come up with the most cost-effective host profiles to satisfy the entire cluster demand. Service resource profiles and capacity planning go hand in hand for successful cluster management in the long term. Before diving into resource profiles, let’s look at declaring runtime dependencies. Runtime Dependencies One of the most common runtime dependencies is file storage for saving application state. Container filesystems are ephemeral and are lost when a container is shut down. Kubernetes offers volume as a Pod-level storage utility that survives container restarts. The most straightforward type of volume is emptyDir, which lives as long as the Pod lives. When the Pod is removed, its content is also lost. The volume needs to be backed by another kind of storage mechanism to survive Pod restarts. If your application needs to read or write files to such long-lived storage, you must declare that
  • 49. dependency explicitly in the container definition using volumes, as shown in Example 2-1. Example 2-1. Dependency on a PersistentVolume apiVersion: v1 kind: Pod metadata: name: random-generator spec: containers: - image: k8spatterns/random-generator:1.0 name: random-generator volumeMounts: - mountPath: "/logs" name: log-volume volumes: - name: log-volume persistentVolumeClaim: claimName: random-generator-log Dependency of a PersistentVolumeClaim (PVC) to be present and bound. The scheduler evaluates the kind of volume a Pod requires, which affects where the Pod gets placed. If the Pod needs a volume that is not provided by any node on the cluster, the Pod is not scheduled at all. Volumes are an example of a runtime dependency that affects what kind of infrastructure a Pod can run and whether the Pod can be scheduled at all. A similar dependency happens when you ask Kubernetes to expose a container port on a specific port on the host system through hostPort. The usage of a hostPort creates another runtime dependency on the nodes and limits where a Pod can be scheduled. hostPort reserves the port on each node in the cluster and is limited to a maximum of one Pod scheduled per node. Because of port conflicts, you can scale to as many Pods as there are nodes in the Kubernetes cluster.
  • 50. Another Random Scribd Document with Unrelated Content
  • 51. hundred and twenty-seven thousand six hundred and twenty-seven dollars and thirty-eight cents, and the second, twenty-four million eight hundred and forty-four thousand one hundred and sixteen dollars and fifty-one cents, differing only about seventeen thousand dollars. The mode recommended by the secretary for the modification of the tariff is, to reduce no part of the duties on the unprotected articles prior to March, 1833, and then to retain a considerable portion of them. And as to the protected class, he would make a gradual but prospective reduction of the duties. The effect of this would be, to destroy the protecting system, by a slow but certain poison. The object being to reduce the revenue, every descending degree in the scale of his plan of gradual reduction, by letting in more of the foreign article to displace the domestic rival fabric, would increase the revenue, and create the necessity for further and further reduction of duties, until they would be carried so low as to end in the entire subversion of the system of protection. For the reasons which have been assigned, it would, I think, be unwise in congress at this time to assume for the future, that there would be a greater amount of net annual revenue from all sources, including the public lands, than twenty-five millions of dollars. Deducting from that sum the amount of seven millions of dollars, which it has been supposed ought to be subtracted, if the resolution before you should be adopted, there would remain eighteen millions of dollars, as the probable revenue for future years. This includes the sum of three millions of dollars, estimated as the future annual receipt from the sale of the public lands—an estimate which I presume will be demonstrated by experience to be much too large. If a reduction so large as seven millions be made at this session, and if the necessary measures be also adopted to detect and punish frauds, and insure a faithful execution of the laws, we may safely make a temporary pause, and await the development of the effect of these arrangements upon the revenue. That the authority of the
  • 52. laws should be vindicated, all ought to agree. Now the fraudulent importer, after an exposure of his fraud, by a most strange treasury construction of the law, (made, I understand, however, not by the present secretary,) eludes all punishment, and is only required to pay those very duties which he was originally bound for, but which he dishonestly sought to evade. Other measures, with a view to a further reduction of the revenue, may be adopted. In some instances there might be an augmentation of duties for that purpose. I will mention the article of foreign distilled spirits. In no other country upon earth is there so much of the foreign article imported, as in this. The duties ought to be doubled, and the revenue thereby further reduced from six hundred thousand, to a million of dollars. The public morals, the grain-growing country, the fruit-raising and the cane-planting country, would be all benefited by rendering the duty prohibitory. I have not proposed the measure, because it ought to originate, perhaps, in the other house. That the measure which I have proposed may be adopted, without interfering with the plan of the secretary of the treasury for the payment of the public debt by the fourth of March next, I will now proceed to show. The secretary estimates that the receipts of the present year, after meeting all other just engagements, will leave a surplus of fourteen millions of dollars, applicable to the payment of the principal of the debt. With this sum, eight millions of dollars, which he proposes to derive from the sale of the bank stock, and two millions of dollars, which he would anticipate from the revenue of the next year, he suggests that the whole of the debt remaining, may be discharged by the time indicated. The fourteen millions, I understand, (although on this subject the report is not perfectly explicit,) are receipts anticipated this year, from duties which accrued last year. If this be the secretary’s meaning, it is evident that he wants no part of the duties which may accrue during the current year, to execute his plan. But if his meaning be, that the fourteen millions will be composed, in part, of duties accruing and payable within the present year, then the measure proposed might prevent the payment of the whole of the remnant of the debt by the exact
  • 53. day which has been stated. If, however, the entire seven millions embraced by the resolution on your table were subtracted from the fourteen, it would still leave him seven millions, besides the bank stock to be applied to the debt, and that, of itself, would be three millions more than can be properly applied to the object in the course of this year, as I have already endeavored to show. I came here, sir, most anxiously desiring that an arrangement of the public revenue should be made, which, without sacrificing any of the great interests of the country, would reconcile and satisfy all its parts. I thought I perceived, in the class of objects not produced within the country, a field on which we could all enter, in a true and genuine spirit of compromise and harmony, and agree upon an amicable adjustment. Why should it not be done? Why should those who are opposed to the American system, demand of its friends an unconditional surrender? Our common object should be, so to reduce the public revenue as to relieve the burdens of the people, if the people of this country can be truly said to be burdened. The government must have a certain amount of revenue, and that amount must be collected from the imports. Is it material to the consumer, wherever situated, whether the collection be made upon a few, or many objects, provided, whatever be the mode, the amount of his contribution to the public exchequer remains the same? If the assessment can be made on objects which will greatly benefit large portions of the union, without injury to him, why should he object to the selection of those objects? Yes, sir, I came here in a spirit of warm attachment to all parts of our beloved country, with a lively solicitude to restore and preserve its harmony, and with a firm determination to pour oil and balm into existing wounds, rather than further to lacerate them. For the truth and sincerity of these declarations, I appeal to Him whom none can deceive. I expected to be met by corresponding dispositions, and hoped that our deliberations, guided by fraternal sentiments and feelings, would terminate in diffusing contentment and satisfaction throughout the land. And that such may be the spirit presiding over them, and such their issue, I yet most fervently hope.
  • 54. ON THE NOMINATION OF MR. VAN BUREN AS MINISTER TO GREAT BRITAIN. IN SECRET SESSION IN THE U. S. SENATE, JANUARY 24, 1832. [IN April, 1831, a rupture in the cabinet of president Jackson terminated in the resignation of the four secretaries, and the attorney general. Among them was Mr. Martin Van Buren, who resigned the office of secretary of state, which he had held a little over two years. General Jackson soon afterwards appointed Mr. Van Buren minister to Great Britain, and he took his departure for London during the recess of the senate; of course, before the nomination could be submitted to that body, for their action. At the ensuing session of congress, the president sent in his name to the senate, and the subject was as usual acted upon in secret session, but the injunction of secrecy was afterwards removed, which enables us to give Mr. Clay’s brief but pointed remarks on the occasion. The principal ground of opposition to the confirmation of the nomination, was that Mr. Van Buren, while secretary of state, in July, 1829, had instructed Mr. McLane, then minister to Great Britain, to represent to the British government that a change of administration in the United States had produced a change of policy; thus bringing our party politics into our negotiations with a foreign power. The senate, therefore, rebuked Mr. Van Buren and the president, by rejecting his nomination on this occasion, by an equal vote of the senators, and the casting vote of the vice-president (Mr. Calhoun)]. MR. PRESIDENT,
  • 55. I regret that I find myself utterly unable to reconcile with the duty I owe to my country a vote in favor of this nomination. I regret it, because in all the past strife of party the relations of ordinary civility and courtesy were never interrupted between the gentleman whose name is before us and myself. But I regard my obligations to the people of the United States, and to the honor and character of their government, as paramount to every private consideration. There was no necessity known to us for the departure of this gentleman from the United States, prior to the submission of his name to the senate. Great Britain was represented here by a diplomatic agent, having no higher rank than that of a chargé des affaires. We were represented in England by one of equal rank; one who had shed lustre upon his country by his high literary character, and of whom it may be justly said, that in no respect was he inferior to the gentleman before us. Although I shall not controvert the right of the president, in an extraordinary case, to send abroad a public minister without the advice and consent of the senate, I do not admit that it ever ought to be done without the existence of some special cause, to be communicated to the senate. We have received no communication of the existence of any such special cause. This view of the matter might not have been sufficient alone to justify a rejection of this nomination; but it is sufficient to authorize us to examine the subject with as perfect freedom as we could have done if the minister had remained in the United States, and awaited the decision of the senate. I consider myself, therefore, not committed by the separate and unadvised act of the president in despatching Mr. Van Buren in the vacation of the senate, and not a very long time before it was to assemble. My main objection to the confirmation of his appointment arises out of his instructions to the late minister of the United States at the court of Great Britain. The attention of the senate has been already called to parts of those instructions, but there are other parts of them, in my opinion, highly reprehensible. Speaking of the colonial question, he says, ‘in reviewing the events which have preceded, and more or less contributed, to a result so much to be regretted,
  • 56. there will be found three grounds, on which we are most assailable. First, in our too long and too tenaciously resisting the right of Great Britain to impose protecting duties in her colonies.’ * * * * ‘And, thirdly, in omitting to accept the terms offered by the act of parliament of July, 1825, after the subject had been brought before congress, and deliberately acted upon by our government. * * * * You will, therefore, see the propriety of possessing yourself of all the explanatory and mitigating circumstances connected with them, that you may be enabled to obviate, as far as practicable, the unfavorable impression which they have produced.’ And after reproaching the late administration with setting up claims for the first time, which they explicitly abandoned, he says, in conclusion, ‘I will add nothing as to the impropriety of suffering any feelings, that find their origin in the past pretensions of this government, to have adverse influence upon the present conduct of Great Britain.’ On our side, according to Mr. Van Buren, all was wrong; on the British side, all was right. We brought forward nothing but claims and pretensions. The British government asserted, on the other hand, a clear and incontestable right. We erred in too tenaciously and too long insisting upon our pretensions, and not yielding at once to the force of their just demands. And Mr. McLane was commanded to avail himself of all the circumstances in his power to mitigate our offence, and to dissuade the British government from allowing their feelings, justly incurred by the past conduct of the party driven from power, to have an adverse influence towards the American party now in power. Sir, was this becoming language from one independent nation to another? Was it proper, in the mouth of an American minister? Was it in conformity with the high, unsullied, and dignified character of our previous diplomacy? Was it not, on the contrary, the language of an humble vassal to a proud and haughty lord? Was it not prostrating and degrading the American eagle before the British lion?
  • 57. Let us examine a little those pretensions which the American government so unjustly put forward, and so pertinaciously maintain. The American government contended, that the produce of the United States ought to be admitted into the British West Indies, on the same terms as similar produce of the British American continental possessions; that without this equality our produce could not maintain in the British West Indies a fair competition with the produce of Canada, and that British preference given to the Canadian produce in the West Indies would draw from the western part of New York, and the northern part of Ohio, American produce into Canada, aggrandizing Montreal and Quebec, and giving employment to British shipping, to the prejudice of the canals of New York, the port of New York, and American shipping. This was the offence of the American government, and we are at this moment realizing the evils which it foresaw. Our produce is passing into Canada, enriching her capitals, and nourishing British navigation. Our own wheat is transported from the western part of New York into Canada, there manufactured, and then transported in British ships in the form of Canadian flour. We are thus deprived of the privilege even of manufacturing our own grain. And when the produce of the United States, shipped from the Atlantic ports, arrives at the British West Indies, it is unable, in consequence of the heavy duties with which most of it is burdened, to sustain a competition with British or colonial produce, freely admitted. The general rule may be admitted, that every nation has a right to favor its own productions, by protecting duties, or other regulations; but, like all general rules, it must have its exceptions. And the relation in which Great Britain stands to her continental and West India colonies, from which she is separated by a vast sea, and the relations in which the United States stand to those colonies, some of which are in juxtaposition with them, constitute a fit case for such an exception.
  • 58. It is true, that the late administration did authorize Mr. Gallatin to treat with Great Britain on the basis of the rule which has been stated, but it was with the express understanding, that some competent provision should be made in the treaty to guard against the British monopoly of the transportation of our own produce passing through Canada. Mr. Gallatin was informed, ‘that the United States consent to the demand which they have heretofore made of the admission of their productions into British colonies, at the same and no higher rate of duty as similar productions are chargeable with when imported from one into another British colony, with the exception of our produce descending the St. Lawrence and the Sorell.’ There was no abandonment of our right, no condemnation of the previous conduct of our government, no humiliating admission, that we had put forth and too tenaciously clung to unsustainable pretensions, and that Great Britain had all along been in the right. We only forebore for the present to assert a right, leaving ourselves at liberty subsequently to resume it. What Mr. Gallatin was authorized to do was, to make a temporary concession, and it was proposed with this preliminary annunciation. ‘But, notwithstanding on a full consideration of the whole subject, the president, anxious to give a strong proof to Great Britain of the desire of the government of the United States to arrange this long contested matter of the colonial intercourse in a manner mutually satisfactory, authorizes you,’ &c. And Mr. Gallatin was required ‘to endeavor to make a lively impression on the British government of the conciliatory spirit of that of the United States, which has dictated the present liberal offer, and of their expectation to meet, in the progress of the negotiations, with a corresponding friendly disposition.’ Now, sir, keeping sight of the object which the late secretary of state had in view, the opening of the trade with the British colonies, which was the best mode to accomplish it—to send our minister to prostrate himself as a suppliant before the British throne, and to say
  • 59. to the British king, we have offended your majesty! the late American administration brought forward pretensions which we cannot sustain, and they too long and too tenaciously adhered to them! your majesty was always in the right; but we hope that your majesty will be graciously pleased to recollect, that it was not we who are now in possession of the American power, but those who have been expelled from it, that wronged your majesty, and that we, when out of power, were on the side of your majesty; and we do humbly pray, that your majesty, taking all mitigating circumstances into consideration, will graciously condescend to extend to us the privileges of the British act of parliament of 1825, and to grant us the boon of a trade with your majesty’s West India colonies—or to have presented himself before the British monarch in the manly and dignified attitude of a minister of this republic, and, abstaining from all condemnation or animadversion upon the past conduct of his own government, to have placed the withdrawal of our former demand upon the ground of concession in a spirit of amity and compromise? But the late secretary of state, the appointed organ of the American people to vindicate their rights with all foreign powers, and to expose the injustice of any unfounded demands which they might assert, was not content to exert his own ingenuity to put his own country in the wrong, and the British government in the right. He endeavored to attach to the late administration the discredit of bringing forward unfounded pretensions, and by disclaiming them, to propitiate the favor of the British king. He says, that the views of the present administration upon the subject of the colonial trade ‘have been submitted to the people of the United States, and the counsels by which your conduct is now directed are the result of the judgment expressed by the only earthly tribunal to which the late administration was amenable for its acts. It should be sufficient, that the claims set up by them, and what caused the interruption of the trade in question, have been explicitly abandoned by those who first asserted them, and are not revived by their successors.’ The late secretary of state—the gentleman under consideration—here makes the statement, that the late administration were the first to set up
  • 60. the claims to which he refers. Now, under all the high responsibility which belongs to the seat which I occupy, I deliberately pronounce that this statement is untrue, and that the late secretary either must have known it to be untrue, or he was culpably negligent of his duty in not ascertaining what had been done under prior administrations. I repeat the charge, the statement must have been known to be untrue, or there was culpable negligence. If it were material, I believe it could be shown, that the claim in question—the right to the admission into the British West Indies of the produce of the United States upon an equal footing with similar produce of the British continental colonies—is coeval with the existence of our present constitution, and that whenever the occasion arose for asserting the claim, it was asserted. But I shall go no further back than to Mr. Madison’s administration. Mr. Monroe, the then secretary of state, instructed our then minister at London upon this subject. He negotiated with lord Castlereagh in respect to it, and this very claim prevented an adjustment at that time of the colonial question. It was again brought forward under Mr. Monroe’s administration, when Mr. Rush was our minister at London. He opened a long and protracted negotiation upon this and other topics, which was suspended in the summer of 1824, principally because the parties could not agree on any satisfactory arrangement of this very colonial question. Thus, at least, two administrations prior to that of Mr. Adams’s had brought forward this identical claim or pretension, which his was the first to assert, according to the late secretary of state. The next charge which the late secretary of state—the official defender of the rights of the American people—preferred against his own government, was that of ‘omitting to accept the terms offered by the act of parliament, of July, 1825, after the subject had been brought before congress, and deliberately acted upon by our government.’ Never was there a more unfounded charge brought forward by any native against his own government, and never was there a more unwarranted apology set up for a foreign government;
  • 61. and a plain, historical narrative, will demonstrate the truth of both these propositions. It has been already stated, that the negotiations of Mr. Rush, embracing the precise colonial claim under consideration, was suspended in 1824, with an understanding between the two governments, that it was to be resumed on all points, at some future convenient period. Early in July, 1825, neither government having then proposed a resumption of the negotiation, the British parliament passed an act to regulate the colonial trade with foreign powers. This act was never, during the late administration, either at London or Washington, officially communicated by the British to the American government, and we only obtained it through other channels. Now if it had been the purpose of the British government, by the passage of that act, to withdraw the colonial question from the negotiation, it ought to have communicated that purpose to this government, and at the same time, the act of parliament, as supplanting and substituting the negotiation. But it never did communicate such purpose. The act itself did not specifically embrace the United States, and offered terms, which, upon the face of the act, it was impossible for the United States to accede to. It required, for example, that, to entitle powers not possessing colonies, to the benefit of the act, they must place the navigation and commerce of Great Britain upon the footing of the most favored nations. To have done this, would have admitted British shipping to import into the United States, on the same conditions with native shipping, the productions of any quarter of the globe, without a reciprocal liberty, on the part of the shipping of the United States, in British ports. The act itself was differently construed, in different colonial ports of Great Britain, and an order of the local government of Halifax, closing that port against our vessels from the fifth of January, was subsequently revoked, thereby confirming the impression, that the act of parliament was not intended to dispense with the previous negotiation. And to conclude this part of the narrative, as late as the twentieth of October, 1826, Mr. Vaughan, the British minister, upon being interrogated by the then secretary of
  • 62. state, was totally uninstructed to afford any information, as to the meaning or intent of the act of July, 1825. Meantime, in March, more than six months after the passage of the act of parliament, Mr. Vaughan notified the department of state, that he had ‘received instructions from his majesty’s government, to acquaint you that it is preparing to proceed to the important negotiations between that country and the United States, now placed in the hands of the American minister, in London.’ * * * ‘The negotiations will therefore be forthwith resumed.’ * * * Here the negotiations were spoken of without exception of the colonial question, the most important of them. If it had been intended to withdraw that, no time could have been more suitable to announce that intention, but no such annunciation was made. Mr. Vaughan was informed, that we also would prepare for the negotiation, (including, of course, the colonial question,) and Mr. Gallatin was accordingly shortly after sent out, with full powers and instructions, amicably to settle that question. On his arrival in England, in the summer of 1826, he was told by the British government, that they would not negotiate on the colonial question; that they had made up their mind, from the passage of the act of July, 1825, not to negotiate about it; and he was informed by the sarcastic Mr. Canning, that as we had failed to accept the boon which the British government had then offered, we were then too late! Such is the state of the case on which the late secretary of state so authoritatively pronounces judgment against his own government, for ‘omitting to accept the terms offered by the act of parliament, of July, 1825!’ He adds, indeed, ‘after the subject had been brought before congress, and deliberately acted upon by our government.’ It was brought before congress in the session of 1825– 6, not at the instance of the American executive, but upon the spontaneous and ill-judged motion of the gentleman from Maryland, (Mr. Smith), and Mr. Gallatin was informed that if the bill proposed
  • 63. by that gentleman had been passed, it would have been unsatisfactory to the British government. I have another objection to this nomination. I believe, upon circumstances which satisfy my mind, that to this gentleman is principally to be ascribed the introduction of the odious system of proscription, for the exercise of the elective franchise, in the government of the United States. I understand that it is the system on which the party in his own state, of which he is the reputed head, constantly acts. He was among the first of the secretaries, to apply that system to the dismission of clerks in his department, known to me to be highly meritorious, and among them one who is now a representative in the other house. It is a detestable system, drawn from the worst periods of the Roman republic, and if it were to be perpetuated—if the offices, honors, and dignities of the people were to be put up to a scramble, and to be decided by the results of every presidential election—our government and institutions, becoming intolerable, would finally end in a despotism as inexorable as that at Constantinople. Sir, the necessity under which we are placed is painful. But it is no fault of the senate, whose consent and advice are required by the constitution, to consummate this appointment, that the minister has been sent out of the United States, without their concurrence. I hope that the public will not be prejudiced by his rejection, if he should be rejected. And I feel perfectly assured, that if the government to which he has been deputed, shall learn that he has been rejected, because he has there, by his instructions to Mr. McLane, stained the character of our country, the moral effect of our decision will greatly outweigh any advantages to be derived from his negotiations, whatever they may have been intended to be. END OF VOLUME FIRST.
  • 64. THE LIFE AND SPEECHES OF THE HON. HENRY CLAY. COMPILED AND EDITED BY DANIEL MALLORY. EMBRACING AN EPITOME OF THE COMPROMISE MEASURES. AND A FULL REPORT OF The Obituary Addresses and Funeral Sermon, DELIVERED IN THE SENATE AND HOUSE OF REPRESENTATIVES OF THE UNITED STATES. VOLUME II. A. S. BARNES & COMPANY,
  • 65. NEW YORK AND CHICAGO
  • 66. CONTENTS OF VOLUME II. ◆ Speech in Defence of the American System. ◆ Speech on the Public Lands. ◆ Speech on the North-eastern Boundary of the United States. ◆ Speech on President Jackson’s Veto of the Bill to Re-charter the United States Bank. ◆ Speech on introducing the Compromise Tariff Bill. ◆ Speech in Support of the Compromise Tariff Act. ◆ Speech in Support of the Compromise Act. ◆ Speech on the President’s Message returning the Public Land Bill. ◆ Speech on the Removal of the Public Deposits from the Bank of the United States. ◆ Speech on the Public Distress caused by the Removal of the Deposits.
  • 67. ◆ Speech on the State of the Country from the Effects of the Removal of the Deposits. ◆ Speech on the State of the Country. ◆ Speech on our Relations with France. ◆ Speech on our Relations with the Cherokee Indians. ◆ Speech on the Cumberland Road Bill. ◆ Speech on the Appointing and Removing Power. ◆ Speech on the Public Land Bill. ◆ Speech on our Relations with France. ◆ Speech on the Admission of Arkansas into the Union. ◆ Speech on the Fortification Bill. ◆ Speech on Recognising the Independence of Texas. ◆ Speech on the Expunging Resolution. ◆ Speech on the Sub-treasury Bill. ◆ Speech on the Pre-emption Bill. ◆ Speech on the Sub-treasury Scheme. ◆ Speech on the Doctrine of Instruction. ◆ Speech on Petition for the Abolition of Slavery. ◆ Speech at Buffalo, New York. ◆ Speech on the Land Bill proposed by Mr. Calhoun.
  • 68. ◆ Speech on the Sub-treasury Bill. ◆ Speech at the Whig National Convention of Young Men. ◆ Speech on the State of the Country under Van Buren’s Administration. ◆ Speech at the Harrison Convention. ◆ Speech on the Repeal of the Sub-treasury Law. ◆ Speech on the Distribution of Proceeds of the Public Lands. ◆ Speech in Defence of Mr. Webster. ◆ Speech on the Veto of the Fiscal Bank Bill by President Tyler. ◆ Speech on the Bank Veto. ◆ Speech on a General Bankrupt Law. ◆ Speech on the Amendment of the Constitution, respecting the Veto Power. ◆ Speech on the Compromise Tariff. ◆ Speech on the Tariff and other Measures of Public Policy. ◆ Valedictory Address to the Senate. ◆ Speech on his Retirement to Private Life. ◆ Speech on Slavery and Abolitionism. ◆ Speech on the Admission of California, &c. ◆ Speech on the Constitution of California, &c. ◆ Speech on the Compromise Measures.
  • 69. ◆ Correspondence, embracing Letters on Various Subjects.
  • 70. SPEECHES. IN DEFENCE OF THE AMERICAN SYSTEM. IN THE SENATE OF THE UNITED STATES, FEB. 2D, 3D, AND 6TH, 1832. [DURING the session of congress in 1832, in consequence of the violent opposition to the protective tariff then in operation, by South Carolina and other southern states, various propositions were introduced for the reduction of duties on imported articles, which finally resulted in the passage of a new tariff law, in July, 1832. This bill, which was reported in the house of representatives by Mr. John Quincy Adams, although it was voted for by many southern members, on the ground of its being a reduction of the former scale of duties, was not satisfactory to them, and the controversy on the subject of the tariff was not settled until the following year, when Mr. Clay’s compromise bill was adopted, providing for a gradual diminution of the tariff of 1832. In the following speech, Mr. Clay, in reply to Mr. Hayne, of South Carolina, and others, enters into a minute and careful examination of the American system, and
  • 71. its effects on the interests of the country; defending, with his usual skill and eloquence, the doctrine of protection to domestic industry. This effort adds another monument to his wisdom and fame, which will, we believe, be referred to by statesmen, who seek the true interests of the country, through all future ages of the republic. The resolution offered by Mr. Clay in January, proposing a reduction of duties on certain imported articles not coming in competition with our manufactures, which he had supported in the foregoing speech of January eleventh, was still under consideration.] IN one sentiment, Mr. President, expressed by the honorable gentleman from South Carolina (general Hayne), though perhaps not in the sense intended by him, I entirely concur. I agree with him, that the decision on the system of policy embraced in this debate, involves the future destiny of this growing country. One way, I verily believe, it would lead to deep and general distress, general bankruptcy, and national ruin, without benefit to any part of the union; the other, the existing prosperity will be preserved and augmented, and the nation will continue rapidly to advance in wealth, power, and greatness, without prejudice to any section of the confederacy. Thus viewing the question, I stand here as the humble but zealous advocate, not of the interests of one state, or seven states only, but of the whole union. And never before have I felt, more intensely, the overpowering weight of that share of responsibility which belongs to me in these deliberations. Never before have I had more occasion than I now have, to lament my want of those intellectual powers, the possession of which might enable me to unfold to this senate and to illustrate to this people great truths, intimately connected with the lasting welfare of my country. I should, indeed, sink overwhelmed and subdued beneath the appalling magnitude of the task which lies before me, if I did not feel myself sustained and fortified by a thorough consciousness of the justness of the cause which I have espoused, and by a persuasion, I hope not presumptuous, that it has the approbation of that Providence who has so often smiled upon these United States.
  • 72. Eight years ago, it was my painful duty to present to the other house of congress an unexaggerated picture of the general distress pervading the whole land. We must all yet remember some of its frightful features. We all know that the people were then oppressed, and borne down by an enormous load of debt; that the value of property was at the lowest point of depression; that ruinous sales and sacrifices were every where made of real estate; that stop laws, and relief laws, and paper money were adopted, to save the people from impending destruction; that a deficit in the public revenue existed, which compelled government to seize upon, and divert from its legitimate object, the appropriations to the sinking fund, to redeem the national debt; and that our commerce and navigation were threatened with a complete paralysis. In short, sir, if I were to select any term of seven years since the adoption of the present constitution which exhibited a scene of the most wide-spread dismay and desolation, it would be exactly that term of seven years which immediately preceded the establishment of the tariff of 1824. I have now to perform the more pleasing task of exhibiting an imperfect sketch of the existing state of the unparalleled prosperity of the country. On a general survey, we behold cultivation extended, the arts flourishing, the face of the country improved, our people fully and profitably employed, and the public countenance exhibiting tranquillity, contentment, and happiness. And if we descend into particulars, we have the agreeable contemplation of a people out of debt; land rising slowly in value, but in a secure and salutary degree; a ready though not extravagant market for all the surplus productions of our industry; innumerable flocks and herds browsing and gamboling on ten thousand hills and plains, covered with rich and verdant grasses; our cities expanded, and whole villages springing up, as it were, by enchantment; our exports and imports increased and increasing; our tonnage, foreign and coastwise, swelling and fully occupied; the rivers of our interior animated by the perpetual thunder and lightning of countless steamboats; the currency sound and abundant; the public debt of two wars nearly redeemed; and, to crown all, the public treasury overflowing,
  • 73. embarrassing congress, not to find subjects of taxation, but to select the objects which shall be liberated from the impost. If the term of seven years were to be selected, of the greatest prosperity which this people have enjoyed since the establishment of their present constitution, it would be exactly that period of seven years which immediately followed the passage of the tariff of 1824. This transformation of the condition of the country from gloom and distress to brightness and prosperity, has been mainly the work of American legislation, fostering American industry, instead of allowing it to be controlled by foreign legislation, cherishing foreign industry. The foes of the American system, in 1824, with great boldness and confidence, predicted, first, the ruin of the public revenue, and the creation of a necessity to resort to direct taxation; the gentleman from South Carolina (general Hayne), I believe, thought that the tariff of 1824 would operate a reduction of revenue to the large amount of eight millions of dollars; secondly, the destruction of our navigation; thirdly, the desolation of commercial cities; and, fourthly, the augmentation of the price of objects of consumption, and further decline in that of the articles of our exports. Every prediction which they made has failed, utterly failed. Instead of the ruin of the public revenue, with which they then sought to deter us from the adoption of the American system, we are now threatened with its subversion, by the vast amount of the public revenue produced by that system. Every branch of our navigation has increased. As to the desolation of our cities, let us take, as an example, the condition of the largest and most commercial of all of them, the great northern capital. I have, in my hands, the assessed value of real estate in the city of New York, from 1817 to 1831. This value is canvassed, contested, scrutinized, and adjudged, by the proper sworn authorities. It is, therefore, entitled to full credence. During the first term, commencing with 1817, and ending in the year of the passage of the tariff of 1824, the amount of the value of real estate was, the first year, fifty-seven million seven hundred and ninety-nine thousand four hundred and thirty-five dollars, and, after various fluctuations in the intermediate
  • 74. period, it settled down at fifty-two million nineteen thousand seven hundred and thirty dollars, exhibiting a decrease, in seven years, of five million seven hundred and seventy-nine thousand seven hundred and five dollars. During the first year, of 1825, after the passage of the tariff, it rose, and, gradually ascending throughout the whole of the latter period of seven years, it finally, in 1831, reached the astonishing height of ninety-five million seven hundred and sixteen thousand four hundred and eighty-five dollars! Now, if it be said, that this rapid growth of the city of New York was the effect of foreign commerce, then it was not correctly predicted, in 1824, that the tariff would destroy foreign commerce, and desolate our commercial cities. If, on the contrary, it be the effect of internal trade, then internal trade cannot be justly chargeable with the evil consequences imputed to it. The truth is, it is the joint effect of both principles, the domestic industry nourishing the foreign trade, and the foreign commerce in turn nourishing the domestic industry. Nowhere more than in New York is the combination of both principles so completely developed. In the progress of my argument, I will consider the effect upon the price of commodities produced by the American system, and show that the very reverse of the prediction of its foes, in 1824, actually happened. Whilst we thus behold the entire failure of all that was foretold against the system, it is a subject of just felicitation to its friends, that all their anticipations of its benefits have been fulfilled, or are in progress of fulfilment. The honorable gentleman from South Carolina has made an allusion to a speech made by me, in 1824, in the other house, in support of the tariff, and to which, otherwise, I should not have particularly referred. But I would ask any one, who can now command the courage to peruse that long production, what principle there laid down is not true? what prediction then made has been falsified by practical experience? It is now proposed to abolish the system, to which we owe so much of the public prosperity, and it is urged that the arrival of the period of the redemption of the public debt has been confidently
  • 75. looked to as presenting a suitable occasion to rid the country of the evils with which the system is alleged to be fraught. Not an inattentive observer of passing events, I have been aware, that, among those who were most early pressing the payment of the public debt, and, upon that ground, were opposing appropriations to other great interests, there were some who cared less about the debt than the accomplishment of other objects. But the people of the United States have not coupled the payment of their public debt with the destruction of the protection of their industry, against foreign laws and foreign industry. They have been accustomed to regard the extinction of the public debt as relief from a burden, and not as the infliction of a curse. If it is to be attended or followed by the subversion of the American system, and an exposure of our establishments and our productions to the unguarded consequences of the selfish policy of foreign powers, the payment of the public debt will be the bitterest of curses. Its fruit will be like the fruit ‘Of that forbidden tree, whose mortal taste Brought death into the world, and all our woe, With loss of Eden.’ If the system of protection be founded on principles erroneous in theory, pernicious in practice, above all, if it be unconstitutional, as is alleged, it ought to be forthwith abolished, and not a vestige of it suffered to remain. But, before we sanction this sweeping denunciation, let us look a little at this system, its magnitude, its ramifications, its duration, and the high authorities which have sustained it. We shall see that its foes will have accomplished comparatively nothing, after having achieved their present aim of breaking down our iron-founderies, our woollen, cotton, and hemp manufactories, and our sugar-plantations. The destruction of these would, undoubtedly, lead to the sacrifice of immense capital, the ruin of many thousands of our fellow-citizens, and incalculable loss to the whole community. But their prostration would not disfigure nor
  • 76. produce greater effect upon the whole system of protection, in all its branches, than the destruction of the beautiful domes upon the capitol would occasion to the magnificent edifice which they surmount. Why, sir, there is scarcely an interest, scarcely a vocation in society, which is not embraced by the beneficence of this system. It comprehends our coasting tonnage and trade, from which all foreign tonnage is absolutely excluded. It includes all our foreign tonnage, with the inconsiderable exception made by treaties of reciprocity with a few foreign powers. It embraces our fisheries, and all our hardy and enterprising fishermen. It extends to almost every mechanic art—to tanners, cordwainers, tailors, cabinet-makers, hatters, tinners, brass-workers, clock-makers, coach-makers, tallow-chandlers, trace-makers, rope- makers, cork-cutters, tobacconists, whip-makers, paper-makers, umbrella-makers, glass-blowers, stocking-weavers, butter-makers, saddle and harness-makers, cutlers, brush-makers, book-binders, dairy-men, milk-farmers, black-smiths, type-founders, musical instrument-makers, basket-makers, milliners, potters, chocolate- makers, floor-cloth-makers, bonnet-makers, hair-cloth-makers, copper-smiths, pencil-makers, bellows-makers, pocket-book-makers, card-makers, glue-makers, mustard-makers, lumber-sawyers, saw- makers, scale-beam-makers, sithe-makers, wood-saw-makers, and many others. The mechanics enumerated, enjoy a measure of protection adapted to their several conditions, varying from twenty to fifty per cent. The extent and importance of some of these artisans, may be estimated by a few particulars. The tanners, curriers, boot and shoe makers, and other workers in hides, skins, and leather, produce an ultimate value per annum of forty millions of dollars; the manufacturers of hats and caps, produce an annual value of fifteen millions; the cabinet-makers, twelve millions; the manufacturers of bonnets and hats for the female sex, lace, artificial
  • 77. flowers, combs, and so forth, seven millions; and the manufacturers of glass, five millions. It extends to all lower Louisiana, the delta of which might as well be submerged again in the Gulf of Mexico, from which it has been a gradual conquest, as now to be deprived of the protecting duty upon its great staple. It affects the cotton-planter15 himself, and the tobacco-planter, both of whom enjoy protection. The total amount of the capital vested in sheep, the land to sustain them, wool, woollen manufactures, and woollen fabrics, and the subsistence of the various persons directly or indirectly employed in the growth and manufacture of the article of wool, is estimated at one hundred and sixty-seven millions of dollars, and the number of persons at one hundred and fifty thousand. The value of iron, considered as a raw material, and of its manufactures, is estimated at twenty-six millions of dollars per annum. Cotton goods, exclusive of the capital vested in the manufacture, and of the cost of the raw material, are believed to amount, annually, to about twenty millions of dollars. These estimates have been carefully made, by practical men of undoubted character, who have brought together and embodied their information. Anxious to avoid the charge of exaggeration, they have sometimes placed their estimates below what was believed to be the actual amount of these interests. With regard to the quantity of bar and other iron annually produced, it is derived from the known works themselves; and I know some in western states which they have omitted in their calculations. Such are some of the items of this vast system of protection, which it is now proposed to abandon. We might well pause and contemplate, if human imagination could conceive the extent of mischief and ruin from its total overthrow, before we proceed to the
  • 78. work of destruction. Its duration is worthy also of serious consideration. Not to go behind the constitution, its date is coeval with that instrument. It began on the ever-memorable fourth day of July—the fourth day of July, 1789. The second act which stands recorded in the statute-book, bearing the illustrious signature of George Washington, laid the corner-stone of the whole system. That there might be no mistake about the matter, it was then solemnly proclaimed to the American people and to the world, that it was necessary for ‘the encouragement and protection of manufactures,’ that duties should be laid. It is in vain to urge the small amount of the measure of the protection then extended. The great principle was then established by the fathers of the constitution, with the father of his country at their head. And it cannot now be questioned, that, if the government had not then been new and the subject untried, a greater measure of protection would have been applied, if it had been supposed necessary. Shortly after, the master minds of Jefferson and Hamilton were brought to act on this interesting subject. Taking views of it appertaining to the departments of foreign affairs and of the treasury, which they respectively filled, they presented, severally, reports which yet remain monuments of their profound wisdom, and came to the same conclusion of protection to American industry. Mr. Jefferson argued that foreign restrictions, foreign prohibitions, and foreign high duties, ought to be met at home by American restrictions, American prohibitions, and American high duties. Mr. Hamilton, surveying the entire ground, and looking at the inherent nature of the subject, treated it with an ability, which, if ever equalled, has not been surpassed, and earnestly recommended protection. The wars of the French revolution commenced about this period, and streams of gold poured into the United States through a thousand channels, opened or enlarged by the successful commerce which our neutrality enabled us to prosecute. We forgot or overlooked, in the general prosperity, the necessity of encouraging our domestic manufactures. Then came the edicts of Napoleon, and the British orders in council; and our embargo, non-intercourse, non-
  • 79. importation, and war, followed in rapid succession. These national measures, amounting to a total suspension, for the period of their duration, of our foreign commerce, afforded the most efficacious encouragement to American manufactures; and accordingly they every where sprung up. While these measures of restriction and this state of war continued, the manufacturers were stimulated in their enterprise by every assurance of support, by public sentiment, and by legislative resolves. It was about that period (1808) that South Carolina bore her high testimony to the wisdom of the policy, in an act of her legislature, the preamble of which, now before me, reads: ‘Whereas, the establishment and encouragement of domestic manufactures, is conducive to the interests of a state, by adding new incentives to industry, and as being the means of disposing to advantage the surplus productions of the agriculturist: and whereas, in the present unexampled state of the world, their establishment in our country is not only expedient, but politic, in rendering us independent of foreign nations.’ The legislature, not being competent to afford the most efficacious aid, by imposing duties on foreign rival articles, proceeded to incorporate a company. Peace, under the treaty of Ghent, returned in 1815 but there did not return with it the golden days which preceded the edicts levelled at our commerce by Great Britain and France. It found all Europe tranquilly resuming the arts and the business of civil life. It found Europe no longer the consumer of our surplus, and the employer of our navigation, but excluding, or heavily burdening, almost all the productions of our agriculture, and our rivals in manufactures, in navigation, and in commerce. It found our country, in short, in a situation totally different from all the past—new and untried. It became necessary to adapt our laws, and especially our laws of impost, to the new circumstances in which we found ourselves. Accordingly, that eminent and lamented citizen, then at the head of the treasury, (Mr. Dallas,) was required, by a resolution of the house of representatives, under date of the twenty-third of February, 1815, to prepare and report to the succeeding session of congress, a
  • 80. system of revenue conformable with the actual condition of the country. He had the circle of a whole year to perform the work, consulted merchants, manufacturers, and other practical men, and opened an extensive correspondence. The report which he made at the session of 1816, was the result of his inquiries and reflections, and embodies the principles which he thought applicable to the subject. It has been said, that the tariff of 1816 was a measure of mere revenue, and that it only reduced the war duties to a peace standard. It is true, that the question then was, how much and in what way should the double duties of the war be reduced? Now, also, the question is, on what articles shall the duties be reduced so as to subject the amounts of the future revenue to the wants of the government? Then it was deemed an inquiry of the first importance, as it should be now, how the reduction should be made, so as to secure proper encouragement to our domestic industry. That this was a leading object in the arrangement of the tariff of 1816, I well remember, and it is demonstrated by the language of Mr. Dallas. He says, in his report: ‘There are few, if any governments, which do not regard the establishment of domestic manufactures as a chief object of public policy. The United States have always so regarded it. * * * * * The demands of the country, while the acquisitions of supplies from foreign nations was either prohibited or impracticable, may have afforded a sufficient inducement for this investment of capital, and this application of labor: but the inducement, in its necessary extent, must fail when the day of competition returns. Upon that change in the condition of the country, the preservation of the manufactures, which private citizens under favorable auspices have constituted the property of the nation, becomes a consideration of general policy, to be resolved by a recollection of past embarrassments; by the certainty of an increased difficulty of reinstating, upon any emergency, the manufactures which shall be allowed to perish and pass away,’ and so forth. The measure of protection which he proposed was not adopted, in regard to some leading articles, and there was great difficulty in ascertaining what it ought to have been. But the principle was then distinctly asserted and fully sanctioned.