From 90a78fb22fc884c0756c6185e06bbd14e291b851 Mon Sep 17 00:00:00 2001 From: 42Atomys Date: Sat, 2 Jul 2022 00:39:58 +0200 Subject: [PATCH] feat: implement webhooks-processor scaling (#161) * feat: implement webhooks-processor scaling * refactor: webhooks-processor ressource --- .../webhooks-processor/base/deployment.yaml | 7 +++++-- internal/webhooks/serve.go | 20 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/deploy/app/webhooks-processor/base/deployment.yaml b/deploy/app/webhooks-processor/base/deployment.yaml index 605f46c5..2b3217e3 100644 --- a/deploy/app/webhooks-processor/base/deployment.yaml +++ b/deploy/app/webhooks-processor/base/deployment.yaml @@ -77,9 +77,12 @@ spec: mountPath: /config readOnly: true resources: + requests: + cpu: 20m + memory: 10Mi limits: - memory: "42Mi" - cpu: "200m" + memory: "20Mi" + cpu: "30m" volumes: - name: config configMap: diff --git a/internal/webhooks/serve.go b/internal/webhooks/serve.go index 593a6f45..0de385b1 100644 --- a/internal/webhooks/serve.go +++ b/internal/webhooks/serve.go @@ -3,6 +3,7 @@ package webhooks import ( "context" "encoding/json" + "os" "github.com/rs/zerolog/log" "github.com/streadway/amqp" @@ -46,14 +47,19 @@ func (p *processor) Serve(amqpUrl, channel string) error { return err } + consumerID := "webhooks-processor" + if os.Getenv("POD_IP") != "" { + consumerID = "webhooks-processor-" + os.Getenv("POD_IP") + } + msgs, err := ch.Consume( - channel, // queue - "webhooks-processor", // consumer - false, // auto-ack - false, // exclusive - false, // no-local - false, // no-wait - nil, // args + channel, // queue + consumerID, // consumer + false, // auto-ack + false, // exclusive + false, // no-local + false, // no-wait + nil, // args ) if err != nil { return err