Skip to content

Cannot Restart Deployment using preStop.sleep Lifecycle Hook #394

@pinkfloydx33

Description

@pinkfloydx33

Kubernetes now supports a dedicated sleep pre-stop lifecycle hook instead of the old exec-based shell script approach. When any of my deployments include a pod with this new setting, Kubernetic prevents me from restarting them using the 'restart resource' button. Pressing it does nothing at all and there's no indication of anything happening.

Some other notes:

  • I can restart the deployment using kubectl rollout restart on the command line
  • I can scale the deployment up/down via Kubernetic without an issue
  • FreeLens can also restart the deployment

Using Kubernetic 4.4.0 on Azure Kubernetes 1.33.1. Here's a sample manifest, Kubernetic cannot restart it. Comment out the hook or replace it with the already commented bits and Kubernetic will restart it as expected.

kind: Deployment
apiVersion: apps/v1
metadata:
  name: test-deployment
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: test-it
  template:
    metadata:
      labels:
        app.kubernetes.io/name: test-it
    spec:      
      containers:
        - name: nginx
          image: nginx:latest
          lifecycle:
            preStop:
              sleep:
                seconds: 5  # <---------- new feature, prevents Kubernetic from restarting a deployment
            # "old way" works just fine
            # exec:
            #   command: ["/bin/bash", "-c", "sleep 5"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions