-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add consumers to consume rabbitmq queue for users and locations…
… queues (#150) * feat(cluster): install secrets for webhooked * feat(cluster): install webhooked 🎉 * feat(cluster): configure the webhook routing and enable intra settings * feat(cluster): add prometheus scrape on webhooked & set a rollout strategy * fix(cluster): disable istio sidecar for cronjob * feat: implement a basic consumer * feat: implement webhook rabbitmq consumer for all campus * feat: add webhhoks-processor on production * fix: check the qos error of rmq channel * fix: log of webhooks have wrong type
- Loading branch information
Showing
25 changed files
with
804 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
Copyright © 2022 42Atomys | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/rs/zerolog/log" | ||
"github.com/spf13/cobra" | ||
|
||
"atomys.codes/stud42/internal/webhooks" | ||
) | ||
|
||
// webhooksCmd represents the webhooks command | ||
var webhooksCmd = &cobra.Command{ | ||
Use: "webhooks", | ||
Short: "A brief description of your command", | ||
Long: `A longer description that spans multiple lines and likely contains examples | ||
and usage of using your command. For example: | ||
Cobra is a CLI library for Go that empowers applications. | ||
This application is a tool to generate the needed files | ||
to quickly create a Cobra application.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var amqpURL = os.Getenv("AMQP_URL") | ||
if amqpURL == "" { | ||
log.Fatal().Msg("AMQP_URL not set") | ||
} | ||
|
||
if err := webhooks.New().Serve(amqpURL, "webhooks-deliveries"); err != nil { | ||
log.Fatal().Err(err).Msg("failed to start rabbitmq consumer") | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
jobsCmd.AddCommand(webhooksCmd) | ||
|
||
// Here you will define your flags and configuration settings. | ||
|
||
// Cobra supports Persistent Flags which will work for this command | ||
// and all subcommands, e.g.: | ||
// webhooksCmd.PersistentFlags().String("foo", "", "A help for foo") | ||
|
||
// Cobra supports local flags which will only run when this command | ||
// is called directly, e.g.: | ||
// webhooksCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: webhooks-processor | ||
spec: | ||
selector: {} | ||
revisionHistoryLimit: 1 | ||
template: | ||
spec: | ||
imagePullSecrets: | ||
- name: ghcr-creds | ||
containers: | ||
- name: service | ||
image: app | ||
args: [ '--config', '/config/stud42.yaml', jobs, webhooks ] | ||
command: [ stud42cli ] | ||
env: | ||
- name: GO_ENV | ||
value: production | ||
- name: APP_VERSION | ||
value: latest | ||
- name: SENTRY_DSN | ||
valueFrom: | ||
secretKeyRef: | ||
key: 'WEBHOOKS_PROCESSOR_DSN' | ||
name: 'sentry-dsns' | ||
- name: DATABASE_URL | ||
value: postgresql://$(DATABASE_USERNAME):$(DATABASE_PASSWORD)@$(DATABASE_HOST):5432/$(DATABASE_NAME)?sslmode=disable | ||
- name: DATABASE_HOST | ||
value: primary-postgres | ||
- name: DATABASE_USERNAME | ||
value: postgres | ||
- name: DATABASE_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
key: POSTGRES_PASSWORD | ||
name: primary-postgres-credentials | ||
- name: DATABASE_NAME | ||
value: s42 | ||
- name: AMQP_URL | ||
value: amqp://$(AMQP_USERNAME):$(AMQP_PASSWORD)@$(AMQP_HOST):$(AMQP_PORT)/ | ||
- name: AMQP_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
key: username | ||
name: prod-primary-rabbitmq-default-user | ||
- name: AMQP_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
key: password | ||
name: prod-primary-rabbitmq-default-user | ||
- name: AMQP_HOST | ||
valueFrom: | ||
secretKeyRef: | ||
key: host | ||
name: prod-primary-rabbitmq-default-user | ||
- name: AMQP_PORT | ||
valueFrom: | ||
secretKeyRef: | ||
key: port | ||
name: prod-primary-rabbitmq-default-user | ||
volumeMounts: | ||
- name: config | ||
mountPath: /config | ||
readOnly: true | ||
resources: | ||
limits: | ||
memory: "42Mi" | ||
cpu: "200m" | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: stud42-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resources: | ||
- deployment.yaml | ||
|
||
commonLabels: | ||
kubernetes.io/name: webhooks-processor | ||
app.kubernetes.io/version: '0.1' | ||
app.kubernetes.io/component: micro-service | ||
app.kubernetes.io/part-of: s42-app | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/created-by: github-actions |
17 changes: 17 additions & 0 deletions
17
deploy/app/webhooks-processor/overlays/live/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
namePrefix: prod- | ||
resources: | ||
- ../../base | ||
namespace: production | ||
|
||
commonAnnotations: | ||
sidecar.istio.io/inject: "false" | ||
|
||
images: | ||
- name: app | ||
newName: ghcr.io/42atomys/stud42 | ||
newTag: latest | ||
|
||
patchesStrategicMerge: | ||
- ./use-live-primary-postgres.yaml |
14 changes: 14 additions & 0 deletions
14
deploy/app/webhooks-processor/overlays/live/use-live-primary-postgres.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: webhooks-processor | ||
spec: | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: service | ||
env: | ||
- name: DATABASE_HOST | ||
value: prod-primary-postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.