Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

How to best run Symfony Messenger Worker on Kubernetes

$
0
0

What's the best way to run the messenger:consume task on Kubernetes?

Deployment?

If we do it with a deployment with a certain number of replicas this could work, but what if we do a rolling update of the deployment which then results in a pod to be replaced although a long running message is handled by it right now?

To prevent this we could probably set a high terminationGracePeriodSeconds and use lifecycle.preStop in combination?

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    run: deploy
  name: deploy
spec:
  replicas: 1
  selector:
    matchLabels:
      run: deploy
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: deploy
    spec:
      terminationGracePeriodSeconds: 6000
      containers:
      - command:
        - sh
        - -c
        - sleep 1d # bin/console messenger:consume
        image: bash
        name: deploy
        lifecycle:
          preStop:
            exec:
              command:
              - sh
              - -c
              - echo "Test if a message is consumed at the moment and prevent POD shutdown till then?"

But during my tests, even if the lifecycle.preStop tasks stops early, the full time defined by terminationGracePeriodSeconds is still waited till the pod is terminated.

Anyone got a good idea out there?


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>