Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to blue-green deployment #500

Merged
merged 36 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
acba436
Adding deployment
ausias-armesto Apr 12, 2024
9135b17
quoting
ausias-armesto Apr 12, 2024
e411727
change
ausias-armesto Apr 12, 2024
69064e9
Revert
ausias-armesto Apr 12, 2024
25941ee
adding green
ausias-armesto Apr 12, 2024
c1fd794
Change GCP Bucket
ausias-armesto Apr 12, 2024
da5e38b
adding environment
ausias-armesto Apr 12, 2024
3e565a9
adding annotation
ausias-armesto Apr 12, 2024
fdff90a
Adding config map
ausias-armesto Apr 12, 2024
4151522
Scale down
ausias-armesto Apr 12, 2024
ee700fb
update replicas
ausias-armesto Apr 12, 2024
0b9d41d
fixing
ausias-armesto Apr 12, 2024
3bbccd0
change format
ausias-armesto Apr 12, 2024
b0b7b42
adding quotes
ausias-armesto Apr 12, 2024
16e7c3e
fixing
ausias-armesto Apr 12, 2024
34b8a9f
update python sdk used version
jeandemeusy Apr 15, 2024
c84c38e
Changing rpc provider
ausias-armesto Apr 16, 2024
036d2d0
Merge branch 'ausias/blue-green' of https://github.com/hoprnet/ct-res…
ausias-armesto Apr 16, 2024
dfbd80e
Fix url
ausias-armesto Apr 16, 2024
609fdb7
Update data
ausias-armesto Apr 16, 2024
211020b
Scale up
ausias-armesto Apr 16, 2024
80e6e3b
Enable
ausias-armesto Apr 16, 2024
d132eab
Change version
ausias-armesto Apr 16, 2024
244373d
increase threshold
ausias-armesto Apr 16, 2024
445031d
bump ct staging to rc.4
jeandemeusy Apr 18, 2024
1d06bcf
ct staging to 2.1.0-rc.4-commit.4b864fc1
jeandemeusy Apr 18, 2024
d89015d
scale 0
ausias-armesto Apr 19, 2024
37289d8
Merge branch 'ausias/blue-green' of https://github.com/hoprnet/ct-res…
ausias-armesto Apr 19, 2024
90cb731
Merge branch 'main' into ausias/blue-green
ausias-armesto Apr 23, 2024
1cffcc1
update staging blue nodes to rc.4-pr.6206
jeandemeusy Apr 24, 2024
e548b72
update identities
ausias-armesto Apr 25, 2024
cd901b3
Merge branch 'ausias/blue-green' of https://github.com/hoprnet/ct-res…
ausias-armesto Apr 25, 2024
ddef72a
fix typo
ausias-armesto Apr 25, 2024
88c78d2
Fix review
ausias-armesto Apr 25, 2024
d50f775
revert
ausias-armesto Apr 25, 2024
0d33c57
fix review
ausias-armesto Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ct-app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
git+https://github.com/hoprnet/hoprd-sdk-python.git@v2.0.5
git+https://github.com/hoprnet/hoprd-sdk-python.git@v2.1.0-rc.3
aiohttp==3.8.4
numpy==1.25.0
pytest==7.1.3
Expand Down
5 changes: 5 additions & 0 deletions helm/ctdapp/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: ctdapp
description: Cover Traffic dApp
type: application
version: 0.1.0
62 changes: 62 additions & 0 deletions helm/ctdapp/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ctdapp.name" -}}
{{- default .Chart.Name .Values.ctdapp.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "ctdapp.fullname" -}}
{{- if .Values.ctdapp.fullnameOverride }}
{{- .Values.ctdapp.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.ctdapp.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "ctdapp.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ctdapp.labels" -}}
helm.sh/chart: {{ include "ctdapp.chart" . }}
{{ include "ctdapp.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ctdapp.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ctdapp.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "ctdapp.serviceAccountName" -}}
{{- if .Values.ctdapp.serviceAccount.create }}
{{- default (include "ctdapp.fullname" .) .Values.ctdapp.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.ctdapp.serviceAccount.name }}
{{- end }}
{{- end }}
46 changes: 46 additions & 0 deletions helm/ctdapp/templates/configmap-core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
name: core-config
data:
FLAG_CORE_HEALTHCHECK: "60"
FLAG_CORE_CHECK_SUBGRAPH_URLS: "200"
FLAG_CORE_GET_FUNDINGS: "600"
FLAG_CORE_AGGREGATE_PEERS: "30"
FLAG_CORE_GET_TOPOLOGY_DATA: "30"
FLAG_CORE_GET_SUBGRAPH_DATA: "30"
FLAG_CORE_APPLY_ECONOMIC_MODEL: "20"
FLAG_CORE_DISTRIBUTE_REWARDS: "1"
FLAG_CORE_GET_TICKET_PRICE: "60"
FLAG_NODE_HEALTHCHECK: "60"
FLAG_NODE_RETRIEVE_PEERS: "60"
FLAG_NODE_RETRIEVE_OUTGOING_CHANNELS: "60"
FLAG_NODE_RETRIEVE_INCOMING_CHANNELS: "60"
FLAG_NODE_RETRIEVE_BALANCES: "900"
FLAG_NODE_OPEN_CHANNELS: "60"
_FLAG_NODE_CLOSE_OLD_CHANNELS: "900"
_FLAG_NODE_CLOSE_PENDING_CHANNELS: "900"
FLAG_NODE_FUND_CHANNELS: "60"
FLAG_NODE_GET_TOTAL_CHANNEL_FUNDS: "60"
DISTRIBUTION_MIN_ELIGIBLE_PEERS: "5"
DISTRIBUTION_MAX_APR_PERCENTAGE: "100.0"
PEER_MIN_VERSION: "0.0.0"
GCP_FILE_PREFIX: expected_reward
GCP_FOLDER: expected_rewards
GCP_BUCKET: hoprnet-ctdapp-{{ .Values.environmentName }}
ECONOMIC_MODEL_FILENAME: parameters-staging.json
ECONOMIC_MODEL_MIN_SAFE_ALLOWANCE: "0.000000001"
CHANNEL_MIN_BALANCE: "0.05"
CHANNEL_FUNDING_AMOUNT: "0.2"
CHANNEL_MAX_AGE_SECONDS: "172800"
RABBITMQ_TASK_NAME: send_1_hop_message
RABBITMQ_PROJECT_NAME: ct-app
SUBGRAPH_PAGINATION_SIZE: "1000"
SUBGRAPH_SAFES_BALANCE_QUERY: "{ safes(first: valfirst, skip: valskip) { registeredNodesInNetworkRegistry { node { id } safe { id balance { wxHoprBalance } allowance { wxHoprAllowance } } } } }"
SUBGRAPH_WXHOPR_TXS_QUERY: "{ transactions(where: { from: valfrom, to: valto }) { from to amount }} "
SUBGRAPH_FROM_ADDRESS: "0xd9a00176cf49dfb9ca3ef61805a2850f45cb1d05"
{{- if .Values.ctdapp.core.extraEnvVars }}
{{ .Values.ctdapp.core.extraEnvVars | toYaml | nindent 2 }}
{{- end }}
14 changes: 14 additions & 0 deletions helm/ctdapp/templates/configmap-nodes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
name: hoprd-nodes
data:
NODE_ADDRESS_1: http://hoprd-ctdapp-1:3001
NODE_ADDRESS_2: http://hoprd-ctdapp--2:3001
NODE_ADDRESS_3: http://hoprd-ctdapp--3:3001
NODE_ADDRESS_4: http://hoprd-ctdapp--4:3001
NODE_ADDRESS_5: http://hoprd-ctdapp--5:3001


15 changes: 15 additions & 0 deletions helm/ctdapp/templates/configmap-postman.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
name: postman-config
data:
PARAM_BATCH_SIZE: "100"
PARAM_DELAY_BETWEEN_TWO_MESSAGES: "0.3"
PARAM_MESSAGE_DELIVERY_TIMEOUT: "20"
PARAM_MAX_ATTEMPTS: "4"
RABBITMQ_PROJECT_NAME: ct-app
{{- if .Values.ctdapp.postman.extraEnvVars }}
{{ .Values.ctdapp.postman.extraEnvVars | toYaml | nindent 2 }}
{{- end }}
53 changes: 53 additions & 0 deletions helm/ctdapp/templates/deployment-core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
argocd.argoproj.io/sync-wave: "4"
name: {{ include "ctdapp.fullname" . }}-core
labels:
{{- include "ctdapp.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.ctdapp.core.replicas }}
selector:
matchLabels:
{{- include "ctdapp.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: core
template:
metadata:
{{- with .Values.ctdapp.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/component: core
{{- include "ctdapp.labels" . | nindent 8 }}
{{- with .Values.ctdapp.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "ctdapp.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.ctdapp.image.core.repository }}:{{ .Values.ctdapp.image.core.tag }}"
imagePullPolicy: {{ .Values.ctdapp.image.core.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.ctdapp.service.port }}
protocol: TCP
envFrom:
- configMapRef:
name: core-config
- configMapRef:
name: hoprd-nodes
- secretRef:
name: hoprd-nodes
- secretRef:
name: subgraph
- secretRef:
name: rabbitmq-ctdapp
args:
- python
- '-m'
- core
resources:
{{- toYaml .Values.ctdapp.core.resources | nindent 12 }}
50 changes: 50 additions & 0 deletions helm/ctdapp/templates/deployment-postman.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
argocd.argoproj.io/sync-wave: "4"
name: {{ include "ctdapp.fullname" . }}-postman
labels:
{{- include "ctdapp.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.ctdapp.postman.replicas }}
selector:
matchLabels:
{{- include "ctdapp.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: postman
template:
metadata:
{{- with .Values.ctdapp.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/component: postman
{{- include "ctdapp.labels" . | nindent 8 }}
{{- with .Values.ctdapp.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "ctdapp.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.ctdapp.image.postman.repository }}:{{ .Values.ctdapp.image.postman.tag }}"
imagePullPolicy: {{ .Values.ctdapp.image.postman.pullPolicy }}
envFrom:
- configMapRef:
name: postman-config
- configMapRef:
name: hoprd-nodes
- secretRef:
name: hoprd-nodes
- secretRef:
name: postgres
- secretRef:
name: rabbitmq-ctdapp
args:
- /bin/sh
- -c
- |
celery -A postman.postman_tasks.app worker -c 4 -n worker@%h -l info -E -Q "send_messages"
resources:
{{- toYaml .Values.ctdapp.postman.resources | nindent 12 }}
18 changes: 18 additions & 0 deletions helm/ctdapp/templates/permission.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: rabbitmq.com/v1beta1
kind: Permission
metadata:
name: ctdapp
namespace: rabbitmq
annotations:
argocd.argoproj.io/sync-wave: "3"
spec:
permissions:
configure: .*
read: .*
write: .*
userReference:
name: ctdapp
vhost: ctdapp
rabbitmqClusterReference:
name: rabbitmq-ha-cluster
14 changes: 14 additions & 0 deletions helm/ctdapp/templates/secret-nodes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Secret
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
name: hoprd-nodes
data:
NODE_KEY_1: {{ .Values.wallet.hoprdApiToken | b64enc }}
NODE_KEY_2: {{ .Values.wallet.hoprdApiToken | b64enc }}
NODE_KEY_3: {{ .Values.wallet.hoprdApiToken | b64enc }}
NODE_KEY_4: {{ .Values.wallet.hoprdApiToken | b64enc }}
NODE_KEY_5: {{ .Values.wallet.hoprdApiToken | b64enc }}
Comment on lines +8 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security concern: Using the same API token for all node keys.

It appears that the same API token is used for all node keys (NODE_KEY_1 to NODE_KEY_5). This could lead to security issues where compromise of one key could affect all nodes. Consider using unique tokens for each node to enhance security.



12 changes: 12 additions & 0 deletions helm/ctdapp/templates/secret-postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
name: postgres
data:
PGDATABASE: {{ .Values.ctdapp.postgres.database | b64enc }}
PGHOST: {{ .Values.ctdapp.postgres.host | b64enc }}
PGPASSWORD: {{ .Values.ctdapp.postgres.password | b64enc }}
PGPORT: {{ .Values.ctdapp.postgres.port | b64enc }}
PGUSER: {{ .Values.ctdapp.postgres.username | b64enc }}
15 changes: 15 additions & 0 deletions helm/ctdapp/templates/secret-rabbitmq.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Secret
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
replicator.v1.mittwald.de/replicate-to: rabbitmq
name: rabbitmq-ctdapp
data:
CELERY_BROKER_URL: {{ .Values.ctdapp.rabbitmq.celeryBrokerUrl | b64enc }}
RABBITMQ_HOST: {{ .Values.ctdapp.rabbitmq.host | b64enc }}
RABBITMQ_PASSWORD: {{ .Values.ctdapp.rabbitmq.password | b64enc }}
RABBITMQ_USERNAME: {{ .Values.ctdapp.rabbitmq.username | b64enc }}
RABBITMQ_VIRTUALHOST: {{ .Values.ctdapp.rabbitmq.virtualhost | b64enc }}
password: {{ .Values.ctdapp.rabbitmq.password | b64enc }}
username: {{ .Values.ctdapp.rabbitmq.username | b64enc }}
10 changes: 10 additions & 0 deletions helm/ctdapp/templates/secret-subgraph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
name: subgraph
data:
SUBGRAPH_SAFES_BALANCE_URL: {{ .Values.ctdapp.subgraph.safesBalanceUrl | b64enc }}
SUBGRAPH_SAFES_BALANCE_URL_BACKUP: {{ .Values.ctdapp.subgraph.safesBalanceUrlBackup | b64enc }}
SUBGRAPH_WXHOPR_TXS_URL: {{ .Values.ctdapp.subgraph.wxhporTxsUrl | b64enc }}
18 changes: 18 additions & 0 deletions helm/ctdapp/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
annotations:
argocd.argoproj.io/sync-wave: "5"
name: {{ include "ctdapp.fullname" . }}
labels:
{{- include "ctdapp.labels" . | nindent 4 }}
spec:
type: {{ .Values.ctdapp.service.type }}
ports:
- port: {{ .Values.ctdapp.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "ctdapp.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: core
15 changes: 15 additions & 0 deletions helm/ctdapp/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.ctdapp.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "ctdapp.serviceAccountName" . }}
labels:
{{- include "ctdapp.labels" . | nindent 4 }}
annotations:
argocd.argoproj.io/sync-wave: "1"
iam.gke.io/gcp-service-account: ctdapp@hopr-{{ .Values.environmentName }}.iam.gserviceaccount.com
{{- with .Values.ctdapp.serviceAccount.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.ctdapp.serviceAccount.automount }}
{{- end }}
13 changes: 13 additions & 0 deletions helm/ctdapp/templates/user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: rabbitmq.com/v1beta1
kind: User
metadata:
annotations:
argocd.argoproj.io/sync-wave: "2"
name: ctdapp
namespace: rabbitmq
spec:
importCredentialsSecret:
name: rabbitmq-ctdapp
rabbitmqClusterReference:
name: rabbitmq-ha-cluster
12 changes: 12 additions & 0 deletions helm/ctdapp/templates/vhost.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: rabbitmq.com/v1beta1
kind: Vhost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "2"
name: ctdapp
namespace: rabbitmq
spec:
name: ctdapp
rabbitmqClusterReference:
name: rabbitmq-ha-cluster
Loading
Loading