万本电子书0元读

万本电子书0元读

顶部广告

Kubernetes for Developers电子书

售       价:¥

20人正在读 | 0人评论 9.8

作       者:Joseph Heck

出  版  社:Packt Publishing

出版时间:2018-04-09

字       数:43.1万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
A developer's field-guide to designing scalable services using Kubernetes About This Book ? Develop and run your software using containers within a Kubernetes environment ? Get hands-on experience of using Kubernetes with DevOps concepts such as continuous integration, benchmark testing, monitoring, and so on ? Pragmatic example-based approach showing how to use Kubernetes in the development process Who This Book Is For If you are a full-stack or back-end software developers interested, curious, or being asked to test as well as run the code you're creating, you can leverage Kubernetes to make that process simpler and consistent regardless of where you deploy. If you're looking for developer focused examples in NodeJS and Python for how to build, test, deploy, and run your code with Kubernetes, this is perfect for you. What You Will Learn ? Build your software into containers ? Deploy and debug software running in containers within Kubernetes ? Declare and add configuration through Kubernetes ? Define how your application fits together, using internal and external services ? Add feedback to your code to help Kubernetes manage your services ? Monitor and measure your services through integration testing and in production deployments In Detail Kubernetes is documented and typically approached from the perspective of someone running software that has already been built. Kubernetes may also be used to enhance the development process, enabling more consistent testing and analysis of code to help developers verify not only its correctness, but also its efficiency. This book introduces key Kubernetes concepts, coupled with examples of how to deploy and use them with a bit of Node.js and Python example code, so that you can quickly replicate and use that knowledge. You will begin by setting up Kubernetes to help you develop and package your code. We walk you through the setup and installation process before working with Kubernetes in the development environment. We then delve into concepts such as automating your build process, autonomic computing, debugging, and integration testing. This book covers all the concepts required for a developer to work with Kubernetes. By the end of this book, you will be in a position to use Kubernetes in development ecosystems. Style and approach This book will cover examples using NodeJS and Python that walk you through building containers, defining your deployments, deploying, debugging, testing, and generally interacting with your code running on Kubernetes. The examples are focused on common development needs, and include pragmatic advice and the explanations behind that advice.
目录展开

Title Page

Copyright and Credits

Kubernetes for Developers

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewers

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Conventions used

Get in touch

Reviews

Setting Up Kubernetes for Development

What you need for development

Optional tools

Getting a local cluster up and running

Resetting and restarting your cluster

Looking at what's built-in and included with Minikube

Verifying Docker

Clearing and cleaning Docker images

Kubernetes concept – container

Kubernetes resource – Pod

Namespaces

Writing your code for Pods and Containers

Kubernetes resource – Node

Networks

Controllers

Kubernetes resource – ReplicaSet

Kubernetes resource – Deployment

Representing Kubernetes resources

Summary

Packaging Your Code to Run in Kubernetes

Container images

Container registries

Making your first container

Dockerfile commands

Example – Python/Flask container image

Building the container

Running your container

Pod name

Port forwarding

Proxy

How did the proxy know to connect to port 5000 on the container?

Getting logs from your application

Example – Node.js/Express container image

Building the container

Running your container

Port forwarding

Proxy

Getting logs from your application

Tagging your container images

Summary

Interacting with Your Code in Kubernetes

Practical notes for writing software to run in a container

Getting options for your executable code

Practical notes for building container images

Sending output from your program

Logs

Pods with more than one container

Streaming the logs

Previous logs

Timestamps

More debugging techniques

Interactive deployment of an image

Attaching to a running Pod

Running a second process in a container

Kubernetes concepts – labels

Organization of labels

Kubernetes concepts – selectors

Viewing labels

Listing resources with labels using kubectl

Automatic labels and selectors

Kubernetes resources – service

Defining a service resource

Endpoints

Service type – ExternalName

Headless service

Discovering services from within your Pod

DNS for services

Exposing services outside the cluster

Service type – LoadBalancer

Service type – NodePort

Minikube service

Example service – Redis

Finding the Redis service

Using Redis from Python

Updating the Flask deployment

Deployments and rollouts

Rollout history

Rollout undo

Updating with the kubectl set command

Summary

Declarative Infrastructure

Imperative versus declarative commands

A wall of YAML

Creating a simple deployment

Declaring your first application

ImagePullPolicy

Audit trail

Kubernetes resource – Annotations

Exposing labels and annotations in Pods

Kubernetes resource – ConfigMap

Creating a ConfigMap

Managing ConfigMaps

Exposing the configuration into your container images

Environment variables

Exposing ConfigMap as files inside the container

Dependencies on ConfigMaps

Kubernetes resource – Secrets

Exposing Secrets into a container

Secrets and security – how secret are the secrets?

Example – Python/Flask deployment with ConfigMap

SIDEBAR – JSONPATH

Using the ConfigMap within Python/Flask

Summary

Pod and Container Lifecycles

Pod lifecycle

Container lifecycle

Deployments, ReplicaSets, and Pods

Getting a snapshot of the current state

Probes

Liveness probe

Readiness probe

Adding a probe to our Python example

Running the Python probes example

Adding a probe to our Node.js example

Container lifecycle hooks

Initialization containers

Quick interactive testing

Handling a graceful shutdown

SIGTERM in Python

SIGTERM in Node.js

Summary

Background Processing in Kubernetes

Job

CronJob

A worker queue example with Python and Celery

Celery worker example

RabbitMQ and configuration

Celery worker

Persistence with Kubernetes

Volumes

PersistentVolume and PersistentVolumeClaim

Stateful Sets

A Node.js example using Stateful Set

Custom Resource Definition

Summary

Monitoring and Metrics

Built-in metrics with Kubernetes

Kubernetes concept – Quality of Service

Choosing requests and limits for your containers

Capturing metrics with Prometheus

Installing Helm

Installing Prometheus using Helm

Viewing metrics with Prometheus

Installing Grafana

Using Prometheus to view application metrics

Flask metrics with Prometheus

Node.js metrics with Prometheus

Service signals in Prometheus

Summary

Logging and Tracing

A Kubernetes concept – DaemonSet

Installing and using Elasticsearch, Fluentd, and Kibana

Log aggregation with EFK

Viewing logs using Kibana

Filtering by app

Lucene query language

Running Kibana in production

Distributed tracing with Jaeger

Spans and traces

Architecture of Jaeger distributed tracing

Trying out Jaeger

Example – adding tracing to your application

Adding a tracing collector to your pod

Add the libraries and code to generate traces

Considerations for adding tracing

Summary

Integration Testing

Testing strategies using Kubernetes

Reviewing resources needed for testing

Patterns of using Kubernetes with testing

Tests local and system-under-test in Kubernetes

Tests local and system-under-test in Kubernetes namespaces

Tests in Kubernetes and system-under-test in Kubernetes namespaces

Simple validation with Bats

Example – integration testing with Python

PyTest and pytest-dependency

PyTest fixtures and the python-kubernetes client

Waiting for state changes

Accessing the deployment

Example – integration testing with Node.js

Node.js tests and dependencies with mocha and chai

Validating the cluster health

Deploying with kubectl

Waiting for the pods to become available

Interacting with the deployment

Continuous integration with Kubernetes

Example – using Minikube with Travis.CI

Next steps

Example – using Jenkins and the Kubernetes plugin

Installing Jenkins using Helm

Accessing Jenkins

Updating Jenkins

Example pipeline

Next steps with pipelines

Summary

Troubleshooting Common Problems and Next Steps

Common errors and how to resolve them

Error validating data

Navigating the documentation

ErrImagePull

CrashLoopBackOff

Starting and inspecting the image

Adding your own setup to the container

No endpoints available for service

Stuck in PodInitializing

Missing resources

Emerging projects for developers

Linters

Helm

ksonnet

Brigade

skaffold

img

Draft

ksync

Telepresence

Interacting with the Kubernetes project

Slack

YouTube

Stack Overflow

Mailing lists and forums

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部