Kubernetes指南
Linux性能优化实战eBPF 核心技术与实战SDN指南个人博客
EN
EN
  • Overview
  • Introduction
    • Kubernetes Introduction
    • Kubernetes Concepts
    • Kubernetes 101
    • Kubernetes 201
    • Kubernetes Cluster
  • Concepts
    • Concepts
    • Architecture
    • Design Principles
    • Components
      • etcd
      • kube-apiserver
      • kube-scheduler
      • kube-controller-manager
      • kubelet
      • kube-proxy
      • kube-dns
      • Federation
      • kubeadm
      • hyperkube
      • kubectl
    • Objects
      • Autoscaling
      • ConfigMap
      • CronJob
      • CustomResourceDefinition
      • DaemonSet
      • Deployment
      • Ingress
      • Job
      • LocalVolume
      • Namespace
      • NetworkPolicy
      • Node
      • PersistentVolume
      • Pod
      • PodPreset
      • ReplicaSet
      • Resource Quota
      • Secret
      • SecurityContext
      • Service
      • ServiceAccount
      • StatefulSet
      • Volume
  • Setup
    • Setup Guidance
    • kubectl Install
    • Single Machine
    • Feature Gates
    • Best Practice
    • Version Support
    • Setup Cluster
      • kubeadm
      • kops
      • Kubespray
      • Azure
      • Windows
      • LinuxKit
      • kubeasz
    • Setup Addons
      • Addon-manager
      • DNS
      • Dashboard
      • Monitoring
      • Logging
      • Metrics
      • GPU
      • Cluster Autoscaler
      • ip-masq-agent
  • Extension
    • API Extension
      • Aggregation
      • CustomResourceDefinition
    • Access Control
      • Authentication
      • RBAC Authz
      • Admission
    • Scheduler Extension
    • Network Plugin
      • CNI
      • Flannel
      • Calico
      • Weave
      • Cilium
      • OVN
      • Contiv
      • SR-IOV
      • Romana
      • OpenContrail
      • Kuryr
    • Container Runtime
      • CRI-tools
      • Frakti
    • Storage Driver
      • CSI
      • FlexVolume
      • glusterfs
    • Network Policy
    • Ingress Controller
      • Ingress + Letsencrypt
      • minikube Ingress
      • Traefik Ingress
      • Keepalived-VIP
    • Cloud Provider
    • Device Plugin
  • Cloud Native Apps
    • Apps Management
      • Patterns
      • Rolling Update
      • Helm
      • Operator
      • Service Mesh
      • Linkerd
      • Linkerd2
    • Istio
      • Deploy
      • Traffic Management
      • Security
      • Policy
      • Metrics
      • Troubleshooting
      • Community
    • Devops
      • Draft
      • Jenkins X
      • Spinnaker
      • Kompose
      • Skaffold
      • Argo
      • Flux GitOps
  • Practices
    • Overview
    • Resource Management
    • Cluster HA
    • Workload HA
    • Debugging
    • Portmap
    • Portforward
    • User Management
    • GPU
    • HugePage
    • Security
    • Audit
    • Backup
    • Cert Rotation
    • Large Cluster
    • Big Data
      • Spark
      • Tensorflow
    • Serverless
  • Troubleshooting
    • Overview
    • Cluster Troubleshooting
    • Pod Troubleshooting
    • Network Troubleshooting
    • PV Troubleshooting
      • AzureDisk
      • AzureFile
    • Windows Troubleshooting
    • Cloud Platform Troubleshooting
      • Azure
    • Troubleshooting Tools
  • Community
    • Development Guide
    • Unit Test and Integration Test
    • Community Contribution
  • Appendix
    • Ecosystem
    • Learning Resources
    • Domestic Mirrors
    • How to Contribute
    • Reference Documents
由 GitBook 提供支持
在本页
  • General Principles of Application High Availability
  • Graceful Shutdown
  • Reference Documents
  1. Practices

Workload HA

上一页Cluster HA下一页Debugging

最后更新于1年前

General Principles of Application High Availability

  • Applications adhere to

  • Employ Services and deploy applications with multiple replica Pods

  • Multiple replicas use anti-affinity to avoid application failure due to single node faults

  • Utilize PodDisruptionBudget to prevent application downtime resulting from evictions

  • Use preStopHook and health check probes to ensure smooth service updates

Graceful Shutdown

Configure terminationGracePeriodSeconds for Pods and use a preStop hook to delay the shutting down of container applications to avoid application interruptions during events such as kubectl drain:

restartPolicy: Always
terminationGracePeriodSeconds: 30
containers:
- image: nginx
  lifecycle:
    preStop:
      exec:
        command: [
          "sh", "-c",
          # Introduce a delay to the shutdown sequence to wait for the
          # pod eviction event to propagate. Then, gracefully shutdown
          # nginx.
          "sleep 5 && /usr/sbin/nginx -s quit",
        ]

For the detailed principle, you can refer to the following series of articles:

Reference Documents


Ensuring that your apps never miss a beat, even while you update your digital orchestra, is what high availability is all about. Let's consider the finely-tuned best practices:

  • Set up your software symphony using Services and a chorus of multiple replica Pods, each singing the same tune.

  • Should one Pod face the music alone, anti-affinity keeps the performance going by avoiding single node failures that hit a sour note.

  • Employ PodDisruptionBudget like a metronome, keeping rhythm and preventing evictions from throwing you off-beat.

  • PreStopHook and health check probes act like the meticulous conductor, guaranteeing each transition is as smooth as the last.

When it's time for a swan song, here's how you can bring the curtain down on your Pods with elegance and poise:

Set the stage with terminationGracePeriodSeconds and cue the preStop hook to dim the lights gently. This way, when the crowd gets rowdy with kubectl drain commands, your application can exit stage left without dropping a line.

restartPolicy: Always
terminationGracePeriodSeconds: 30
containers:
- image: nginx
  lifecycle:
    preStop:
      exec:
        command: [
          "sh", "-c",
          # This little intermission gives your Pods time to pass the news
          # of their departure. Then, like the grand finale of a symphony,
          # Nginx takes a graceful bow.
          "sleep 5 && /usr/sbin/nginx -s quit",
        ]

Intrigued by the mechanics behind the show? Curtain up! Peek behind the scenes with this enlightening series of articles:

For the theory and technical know-how that underpins your application's resilience, sift through these reference documents:

Treat your applications to the modern methodology of , ensuring they're as resilient as they are refined.

Enlightening : No intermissions in your server performance.

Graceful : Pods that know how to exit the stage properly.

Timely : Ensuring every Pod gets the memo before the lights go out.

Safeguarding : Keep the show going, no matter what happens offstage.

: The biology of your digital creatures.

: When the digital seas get rough, keep your Pods afloat.

The Twelve-Factor App
1. Zero Downtime Server Updates For Your Kubernetes Cluster
2. Gracefully Shutting Down Pods in a Kubernetes Cluster
3. Delaying Shutdown to Wait for Pod Deletion Propagation
4. Avoiding Outages in Your Kubernetes Cluster Using PodDisruptionBudgets
Kubernetes Pod Lifecycle
Kubernetes PodDisruptionBudget
The Twelve-Factor App
Series 1
Series 2
Series 3
Series 4
Understanding Pod Lifecycle
Navigating Pod Disruptions