Skip to content

Commit

Permalink
fix env rabbitmq
Browse files Browse the repository at this point in the history
  • Loading branch information
YvannPONCE committed Oct 14, 2024
1 parent 0d4988b commit 9bace21
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 15 deletions.
15 changes: 12 additions & 3 deletions gateway/adapter/mqttClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ func (client *RabbitMQClient) init() {
log.Fatal("RABBITMQ_SERVER environment variable is not set")
return
}

endpoint := os.Getenv("RABBITMQ_SERVER")
endpoint := os.Getenv("RABBITMQ_USERNAME")
if os.Getenv("RABBITMQ_USERNAME") == "" {
log.Fatal("RABBITMQ_USERNAME environment variable is not set")
return
}
username := os.Getenv("RABBITMQ_USERNAME")
if os.Getenv("RABBITMQ_PASSWORD") == "" {
log.Fatal("RABBITMQ_PASSWORD environment variable is not set")
return
}
password := os.Getenv("RABBITMQ_PASSWORD")
var err error
client.conn, err = amqp.Dial("amqp://guest:guest@"+endpoint)
client.conn, err = amqp.Dial("amqp://"+username+":"+password+"@"+endpoint)
failOnError(err, "Failed to connect to RabbitMQ")
}

Expand Down
17 changes: 13 additions & 4 deletions gateway/dataManager/mqttClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ func (rabbitMQClient *RabbitMQClient) init(alerter *Alerter) {
log.Fatal("RABBITMQ_SERVER environment variable is not set")
return
}

endpoint := os.Getenv("RABBITMQ_SERVER")
var err error
rabbitMQClient.conn, err = amqp.Dial("amqp://guest:guest@"+endpoint)
endpoint := os.Getenv("RABBITMQ_USERNAME")
if os.Getenv("RABBITMQ_USERNAME") == "" {
log.Fatal("RABBITMQ_USERNAME environment variable is not set")
return
}
username := os.Getenv("RABBITMQ_USERNAME")
if os.Getenv("RABBITMQ_PASSWORD") == "" {
log.Fatal("RABBITMQ_PASSWORD environment variable is not set")
return
}
password := os.Getenv("RABBITMQ_PASSWORD")
var err error
client.conn, err = amqp.Dial("amqp://"+username+":"+password+"@"+endpoint)
failOnError(err, "Failed to connect to RabbitMQ")
rabbitMQClient.alerter = alerter
}
Expand Down
7 changes: 7 additions & 0 deletions gateway/manifests/base/adapter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ spec:
value: "8080"
- name: RABBITMQ_SERVER
value: "rabbitmq:5672"
- name: RABBITMQ_USERNAME
value: user
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: rabbitmq
key: rabbitmq-password
ports:
- name: http
containerPort: 8080
Expand Down
7 changes: 7 additions & 0 deletions gateway/manifests/base/dataManager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ spec:
env:
- name: RABBITMQ_SERVER
value: "rabbitmq:5672"
- name: RABBITMQ_USERNAME
value: user
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: rabbitmq
key: rabbitmq-password
resources:
requests:
cpu: "100m"
Expand Down
3 changes: 2 additions & 1 deletion gateway/manifests/base/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- adapter.yaml
- dataManager.yaml
- dataManager.yaml
- rabbitMQ.yaml
15 changes: 15 additions & 0 deletions gateway/manifests/base/rabbitMQ.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: rabbitmq
spec:
interval: 60m
chart:
spec:
chart: rabbitmq
version: "15.0.3"
sourceRef:
kind: HelmRepository
name: bitnami
interval: 12h
values: {}
2 changes: 1 addition & 1 deletion manifests/base/bitnami-helm-repository.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: source.toolkit.fluxcd.io/v1beta2
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: bitnami
Expand Down
12 changes: 6 additions & 6 deletions manifests/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resources:
- bitnami-helm-repository.yaml
- mongodb
- prometheus
- grafana
- keycloak
- ../../cloud/backend/alert-management/manifests/base
- ../../cloud/backend/patient-management/manifests/base
#- mongodb
#- prometheus
#- grafana
#- keycloak
#- ../../cloud/backend/alert-management/manifests/base
#- ../../cloud/backend/patient-management/manifests/base
- ../../gateway/manifests/base

0 comments on commit 9bace21

Please sign in to comment.