microservices with dockers and kubernetes

4
Microservices - Docker & Kubernetes Study Guide

Upload: manish-chopra

Post on 22-Jan-2018

96 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Microservices with Dockers and Kubernetes

Microservices - Docker & Kubernetes Study Guide

Page 2: Microservices with Dockers and Kubernetes

MICROSERVICES - DOCKER & KUBERNETES __________________________________________________________________________________

Page 1

Microservices - Dockers and Kubernetes

Table of Contents

Preface ................................................................................................................................................ 3

1 Monolithic and Microservices ............................................................................................................... 4

1.1 Introduction to Microservices ................................................................................................. 5

1.2 Monolithic vs. Microservices vs. SOA ..................................................................................... 7

1.3 Moving from Monolithic to Microservices ............................................................................. 9

1.4 Microservices Architecture and Best Practices ..................................................................... 10

1.5 Microservices Design Patterns and Strategies ...................................................................... 13

Lab Exercise 1 .................................................................................................................................... 17

Lab Exercise 2 .................................................................................................................................... 22

Lab Exercise 3 .................................................................................................................................... 29

2 Starting with Linux Containers ............................................................................................................ 32

2.1 Introduction to Linux Containers .......................................................................................... 33

2.2 Containers vs. Virtual Machines ........................................................................................... 36

2.3 Docker Basics - Components and Architecture ..................................................................... 37

2.4 Docker Installation and Configuration .................................................................................. 41

2.5 Application considerations ................................................................................................... 41

Lab Exercise 1 .................................................................................................................................... 45

Lab Exercise 2 .................................................................................................................................... 47

Lab Exercise 3 .................................................................................................................................... 49

3 Working with Docker - Part 1 .............................................................................................................. 50

3.1 Running Docker Images ........................................................................................................ 51

3.2 Transaction Management in Microservices .......................................................................... 52

3.3 Managing Containerized Applications .................................................................................. 53

3.4 Container Lifecycle ................................................................................................................ 55

4 Working with Docker - Part 2 .............................................................................................................. 57

4.1 Accessing Images from Docker Hub ...................................................................................... 58

4.2 Building Images using Dockerfile .......................................................................................... 59

4.3 Docker Networking ............................................................................................................... 68

4.4 Docker Volumes .................................................................................................................... 74

4.5 Container migration and packaging ...................................................................................... 79

4.6 Challenges in Deploying Docker Containers ......................................................................... 80

Lab Exercise 1 .................................................................................................................................... 83

Page 3: Microservices with Dockers and Kubernetes

MICROSERVICES - DOCKER & KUBERNETES __________________________________________________________________________________

Page 2

Lab Exercise 2 .................................................................................................................................... 84

Lab Exercise 3 .................................................................................................................................... 84

Lab Exercise 4 .................................................................................................................................... 86

Lab Exercise 5 .................................................................................................................................... 87

Lab Exercise 6 .................................................................................................................................... 88

5 Working with Docker - Part 3 .............................................................................................................. 91

5.1 Using Docker Compose ......................................................................................................... 92

5.2 Monitoring Docker ................................................................................................................ 93

5.3 Docker Security ..................................................................................................................... 95

5.4 Docker Registry ..................................................................................................................... 98

Lab Exercise (Optional) ..................................................................................................................... 99

6 Working with Docker - Part 4 ............................................................................................................ 101

6.1 Using Security tools for Docker ........................................................................................... 102

6.2 Docker's Built-in Security Features ..................................................................................... 102

6.3 Docker security best practices ............................................................................................ 102

7 Starting with Kubernetes .................................................................................................................. 104

7.1 Key Concepts in Kubernetes ............................................................................................... 105

7.2 Kubernetes Cluster Architecture......................................................................................... 105

7.3 Networking models (CNI vs CNM)....................................................................................... 107

7.4 Kubernetes Cluster Planning ............................................................................................... 110

7.5 Installing and Configuring Master Controller...................................................................... 112

7.6 Installing and Configuring Nodes/Minions ......................................................................... 115

7.7 Kubernetes Commands ....................................................................................................... 118

Lab Exercise ..................................................................................................................................... 119

8 Advanced Kubernetes ....................................................................................................................... 122

8.1 Kubernetes Cluster Management ....................................................................................... 123

8.2 Create and Deploy Pod Definitions ..................................................................................... 123

8.3 Configure Pods and Containers ........................................................................................... 124

8.4 Volume management with PODs ........................................................................................ 126

8.5 Networking In Kubernetes .................................................................................................. 127

8.6 Commands in Kubernetes ................................................................................................... 130

8.7 Run Applications on Kubernetes Cluster ............................................................................ 132

8.8 Kubernetes vs. Docker Swarm ............................................................................................ 137

Page 4: Microservices with Dockers and Kubernetes

MICROSERVICES - DOCKER & KUBERNETES __________________________________________________________________________________

Page 3

PREFACE

Microservices have been a growing trend in the last few years and organizations have felt the need to adopt them to keep up with the changing IT landscape. The Docker project started in 2013 is a Linux based service and forms a foundation for running Microservices. Later, the Kubernetes project was developed by Google for deploying, automating, scaling and managing containerized applications in a cluster.

This is a customized study guide to get started with Microservices - Docker and Kubernetes.

About two decades ago, IT and computing industry had a limited set of matured technologies. Further back in time, there were still lesser technologies available to explore for our projects.

At present, there are numerous technologies, standards, computing languages and platforms, among others available to choose from. Present day projects require the right planning and execution to last long.

There are numerous open source applications available in the opensource doman. Github.com and Hub.docker.com are very popular among the developer community, and you can branch out one or more of project available there to get started with your project, without reinventing the wheel.

This guide attempts to bridge the gap in the least possible time, and covers the essentials features to get started with Microservices, Docker, and Kubernetes. After reading through the text, and by practicilng the examples, you will get familiarised with developing and deploying Microservices on Docker and Kubernetes platforms.

Author

Manish Chopra (December 2017)