Book Image

Learn Docker - Fundamentals of Docker 18.x

By : Dr. Gabriel N. Schenker
Book Image

Learn Docker - Fundamentals of Docker 18.x

By: Dr. Gabriel N. Schenker

Overview of this book

Docker containers have revolutionized the software supply chain in small and big enterprises. Never before has a new technology so rapidly penetrated the top 500 enterprises worldwide. Companies that embrace containers and containerize their traditional mission-critical applications have reported savings of at least 50% in total maintenance cost and a reduction of 90% (or more) of the time required to deploy new versions of those applications. Furthermore they are benefitting from increased security just by using containers as opposed to running applications outside containers. This book starts from scratch, introducing you to Docker fundamentals and setting up an environment to work with it. Then we delve into concepts such as Docker containers, Docker images, Docker Compose, and so on. We will also cover the concepts of deployment, orchestration, networking, and security. Furthermore, we explain Docker functionalities on public clouds such as AWS. By the end of this book, you will have hands-on experience working with Docker containers and orchestrators such as SwarmKit and Kubernetes.
Table of Contents (21 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Chapter 13


  1. Assuming we have a Docker image in a registry for the two application services, the web API and Mongo DB, we then need to do the following:
    • Define a deployment for Mongo DB using a  StatefulSet; let's call this deployment db-deployment. The StatefulSet should have one replica (replicating Mongo DB is a bit more involved and is outside of the scope of this book).
    • Define a Kubernetes service called db of type ClusterIP for the db-deployment.
    • Define a deployment for the web API; let's call it web-deployment. Let's scale this service to three instances.
    • Define a Kubernetes service called api of type NodePort for web-deployment.
    • If we use secrets, then define those secrets directly in the cluster using kubectl.
    • Deploy the application using kubectl.
  1. To implement layer 7 routing for an application, we ideally use an IngressController. The IngressController is a reverse proxy such as Nginx that has a sidecar listening on the Kubernetes Server API for relevant changes and updating the reverse proxy's configuration and restarting it, if such a change has been detected. We then need to define Ingress resources in the cluster which define the routing, for example from a context-based route such as  https://example.com/pets  to <a service name>/<port> pair such as  api/32001. The moment Kubernetes creates or changes this Ingress object, the IngressController's sidecar picks it up and updates the proxy's routing configuration.
  2. Assuming this is a cluster internal inventory service:
    • When deploying version 1.0 we define a deployment called inventory-deployment-blue and label the pods with a label color: blue.
    • We deploy the Kubernetes service of type ClusterIP called inventory for the preceding deployment with the selector containing color: blue.
    • When ready to deploy the new version of the payments service, we first define a deployment for version 2.0 of the service and call it inventory-deployment-green. We add a label color: green to the pods. 
    • We can now smoke test the "green" service and when everything is OK, we can update the inventory service such as the selector contains color: green.
  3. Some type of information that is confidential and thus should be provided to services through Kubernetes secrets include: passwords, certificates, API key IDs, API key secrets or tokens.
  4. Sources for secret values can be files or base64 encoded values.