Skip to content

Commit

Permalink
Adapt to blue-green deployment (#500)
Browse files Browse the repository at this point in the history
* Adding deployment

* quoting

* change

* Revert

* adding green

* Change GCP Bucket

* adding environment

* adding annotation

* Adding config map

* Scale down

* update replicas

* fixing

* change format

* adding quotes

* fixing

* update python sdk used version

* Changing rpc provider

* Fix url

* Update data

* Scale up

* Enable

* Change version

* increase threshold

* bump ct staging to rc.4

* ct staging to 2.1.0-rc.4-commit.4b864fc1

* scale 0

* update staging blue nodes to rc.4-pr.6206

* update identities

* fix typo

* Fix review

* revert

* fix review

---------

Co-authored-by: Jean Demeusy <[email protected]>
  • Loading branch information
ausias-armesto and jeandemeusy authored Apr 29, 2024
1 parent c5cd31d commit ed019e0
Show file tree
Hide file tree
Showing 29 changed files with 862 additions and 197 deletions.
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 }}


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

0 comments on commit ed019e0

Please sign in to comment.