0%

Book Description

In this practical guide, four Kubernetes professionals with deep experience in distributed systems, enterprise application development, and open source will guide you through the process of building applications with this container orchestration system. Based on the experiences of companies that are running Kubernetes in production successfully, many of the methods are also backed by concrete code examples.

This book is ideal for those already familiar with basic Kubernetes concepts who want to learn common best practices. You’ll learn exactly what you need to know to build your best app with Kubernetes the first time.

  • Set up and develop applications in Kubernetes
  • Learn patterns for monitoring, securing your systems, and managing upgrades, rollouts, and rollbacks
  • Understand Kubernetes networking policies and where service mesh fits in
  • Integrate services and legacy applications and develop higher-level platforms on top of Kubernetes
  • Run machine learning workloads in Kubernetes

Table of Contents

  1. Preface
    1. Who Should Read This Book
    2. Why We Wrote This Book
    3. Navigating This Book
    4. Conventions Used in This Book
    5. Using Code Examples
    6. O’Reilly Online Learning
    7. How to Contact Us
    8. Acknowledgments
  2. 1. Setting Up a Basic Service
    1. Application Overview
    2. Managing Configuration Files
    3. Creating a Replicated Service Using Deployments
      1. Best Practices for Image Management
      2. Creating a Replicated Application
    4. Setting Up an External Ingress for HTTP Traffic
    5. Configuring an Application with ConfigMaps
    6. Managing Authentication with Secrets
    7. Deploying a Simple Stateful Database
    8. Creating a TCP Load Balancer by Using Services
    9. Using Ingress to Route Traffic to a Static File Server
    10. Parameterizing Your Application by Using Helm
    11. Deploying Services Best Practices
    12. Summary
  3. 2. Developer Workflows
    1. Goals
    2. Building a Development Cluster
    3. Setting Up a Shared Cluster for Multiple Developers
      1. Onboarding Users
      2. Creating and Securing a Namespace
      3. Managing Namespaces
      4. Cluster-Level Services
    4. Enabling Developer Workflows
    5. Initial Setup
    6. Enabling Active Development
    7. Enabling Testing and Debugging
    8. Setting Up a Development Environment Best Practices
    9. Summary
  4. 3. Monitoring and Logging in Kubernetes
    1. Metrics Versus Logs
    2. Monitoring Techniques
    3. Monitoring Patterns
    4. Kubernetes Metrics Overview
      1. cAdvisor
      2. Metrics Server
      3. kube-state-metrics
    5. What Metrics Do I Monitor?
    6. Monitoring Tools
    7. Monitoring Kubernetes Using Prometheus
    8. Logging Overview
    9. Tools for Logging
    10. Logging by Using an EFK Stack
    11. Alerting
    12. Best Practices for Monitoring, Logging, and Alerting
      1. Monitoring
      2. Logging
      3. Alerting
    13. Summary
  5. 4. Configuration, Secrets, and RBAC
    1. Configuration Through ConfigMaps and Secrets
      1. ConfigMaps
      2. Secrets
    2. Common Best Practices for the ConfigMap and Secrets APIs
    3. RBAC
      1. RBAC Primer
      2. RBAC Best Practices
    4. Summary
  6. 5. Continuous Integration, Testing, and Deployment
    1. Version Control
    2. Continuous Integration
    3. Testing
    4. Container Builds
    5. Container Image Tagging
    6. Continuous Deployment
    7. Deployment Strategies
    8. Testing in Production
    9. Setting Up a Pipeline and Performing a Chaos Experiment
      1. Setting Up CI
      2. Setting Up CD
      3. Performing a Rolling Upgrade
      4. A Simple Chaos Experiment
    10. Best Practices for CI/CD
    11. Summary
  7. 6. Versioning, Releases, and Rollouts
    1. Versioning
    2. Releases
    3. Rollouts
    4. Putting It All Together
      1. Best Practices for Versioning, Releases, and Rollouts
    5. Summary
  8. 7. Worldwide Application Distribution and Staging
    1. Distributing Your Image
    2. Parameterizing Your Deployment
    3. Load-Balancing Traffic Around the World
    4. Reliably Rolling Out Software Around the World
      1. Pre-Rollout Validation
      2. Canary Region
      3. Identifying Region Types
      4. Constructing a Global Rollout
    5. When Something Goes Wrong
    6. Worldwide Rollout Best Practices
    7. Summary
  9. 8. Resource Management
    1. Kubernetes Scheduler
      1. Predicates
      2. Priorities
    2. Advanced Scheduling Techniques
      1. Pod Affinity and Anti-Affinity
      2. nodeSelector
      3. Taints and Tolerations
    3. Pod Resource Management
      1. Resource Request
      2. Resource Limits and Pod Quality of Service
      3. PodDisruptionBudgets
      4. Managing Resources by Using Namespaces
      5. ResourceQuota
      6. LimitRange
      7. Cluster Scaling
      8. Application Scaling
      9. Scaling with HPA
      10. HPA with Custom Metrics
      11. Vertical Pod Autoscaler
    4. Resource Management Best Practices
    5. Summary
  10. 9. Networking, Network Security, and Service Mesh
    1. Kubernetes Network Principles
    2. Network Plug-ins
      1. Kubenet
      2. Kubenet Best Practices
      3. The CNI Plug-in
      4. CNI Best Practices
    3. Services in Kubernetes
      1. Service Type ClusterIP
      2. Service Type NodePort
      3. Service Type ExternalName
      4. Service Type LoadBalancer
      5. Ingress and Ingress Controllers
      6. Services and Ingress Controllers Best Practices
    4. Network Security Policy
      1. Network Policy Best Practices
    5. Service Meshes
      1. Service Mesh Best Practices
    6. Summary
  11. 10. Pod and Container Security
    1. PodSecurityPolicy API
      1. Enabling PodSecurityPolicy
      2. Anatomy of a PodSecurityPolicy
      3. PodSecurityPolicy Challenges
      4. PodSecurityPolicy Best Practices
      5. PodSecurityPolicy Next Steps
    2. Workload Isolation and RuntimeClass
      1. Using RuntimeClass
      2. Runtime Implementations
      3. Workload Isolation and RuntimeClass Best Practices
    3. Other Pod and Container Security Considerations
      1. Admission Controllers
      2. Intrusion and Anomaly Detection Tooling
    4. Summary
  12. 11. Policy and Governance for Your Cluster
    1. Why Policy and Governance Are Important
    2. How Is This Policy Different?
    3. Cloud-Native Policy Engine
    4. Introducing Gatekeeper
      1. Example Policies
      2. Gatekeeper Terminology
      3. Defining Constraint Templates
      4. Defining Constraints
      5. Data Replication
      6. UX
    5. Audit
      1. Becoming Familiar with Gatekeeper
      2. Gatekeeper Next Steps
    6. Policy and Governance Best Practices
    7. Summary
  13. 12. Managing Multiple Clusters
    1. Why Multiple Clusters?
    2. Multicluster Design Concerns
    3. Managing Multiple Cluster Deployments
      1. Deployment and Management Patterns
    4. The GitOps Approach to Managing Clusters
    5. Multicluster Management Tools
    6. Kubernetes Federation
    7. Managing Multiple Clusters Best Practices
    8. Summary
  14. 13. Integrating External Services and Kubernetes
    1. Importing Services into Kubernetes
      1. Selector-Less Services for Stable IP Addresses
      2. CNAME-Based Services for Stable DNS Names
      3. Active Controller-Based Approaches
    2. Exporting Services from Kubernetes
      1. Exporting Services by Using Internal Load Balancers
      2. Exporting Services on NodePorts
      3. Integrating External Machines and Kubernetes
    3. Sharing Services Between Kubernetes
    4. Third-Party Tools
    5. Connecting Cluster and External Services Best Practices
    6. Summary
  15. 14. Running Machine Learning in Kubernetes
    1. Why Is Kubernetes Great for Machine Learning?
    2. Machine Learning Workflow
    3. Machine Learning for Kubernetes Cluster Admins
      1. Model Training on Kubernetes
      2. Distributed Training on Kubernetes
      3. Resource Constraints
      4. Specialized Hardware
      5. Libraries, Drivers, and Kernel Modules
      6. Storage
      7. Networking
      8. Specialized Protocols
    4. Data Scientist Concerns
    5. Machine Leaning on Kubernetes Best Practices
    6. Summary
  16. 15. Building Higher-Level Application Patterns on Top of Kubernetes
    1. Approaches to Developing Higher-Level Abstractions
    2. Extending Kubernetes
      1. Extending Kubernetes Clusters
      2. Extending the Kubernetes User Experience
    3. Design Considerations When Building Platforms
      1. Support Exporting to a Container Image
      2. Support Existing Mechanisms for Service and Service Discovery
    4. Building Application Platforms Best Practices
    5. Summary
  17. 16. Managing State and Stateful Applications
    1. Volumes and Volume Mounts
      1. Volume Best Practices
    2. Kubernetes Storage
      1. PersistentVolume
      2. PersistentVolumeClaims
      3. Storage Classes
      4. Kubernetes Storage Best Practices
    3. Stateful Applications
      1. StatefulSets
      2. Operators
      3. StatefulSet and Operator Best Practices
    4. Summary
  18. 17. Admission Control and Authorization
    1. Admission Control
      1. What Are They?
      2. Why Are They Important?
      3. Admission Controller Types
      4. Configuring Admission Webhooks
      5. Admission Control Best Practices
    2. Authorization
      1. Authorization Modules
      2. Authorization Best Practices
    3. Summary
  19. 18. Conclusion
  20. Index