concept

Graceful termination

Understand Kubernetes Pod termination, preStop hooks, grace periods, stop signals and EndpointSlice draining through offline shutdown scenarios.

Formal Syntax & Structure

kubernetes syntaxkubernetes
Graceful termination

Working Example

Example Snippetkubernetes
apiVersion: v1kind: Podmetadata:  name: catalog-shutdown  namespace: book-lab  labels:    app: catalogspec:  terminationGracePeriodSeconds: 30  containers:    - name: catalog      image: registry.invalid/bytemind/catalog:demo      resources:        requests:          cpu: 250m          memory: 128Mi        limits:          cpu: 500m          memory: 256Mi      lifecycle:        preStop:          httpGet:            path: /drain            port: 8080      readinessProbe:        httpGet:          path: /ready          port: 8080        periodSeconds: 5        timeoutSeconds: 2
Kubernetes Reference