Skip to content

Commit

Permalink
chore: update papyrus non crates folders and files
Browse files Browse the repository at this point in the history
  • Loading branch information
dafnamatsry committed Jul 16, 2024
1 parent d4e2454 commit 68f52e7
Show file tree
Hide file tree
Showing 35 changed files with 17,316 additions and 124 deletions.
File renamed without changes.
14 changes: 7 additions & 7 deletions Monitoring/grafana.json → Monitoring/papyrus/grafana.json
Original file line number Diff line number Diff line change
Expand Up @@ -9247,8 +9247,8 @@
{
"current": {
"selected": true,
"text": "V0_5",
"value": "V0_5"
"text": "V0_7",
"value": "V0_7"
},
"hide": 0,
"includeAll": false,
Expand All @@ -9257,16 +9257,16 @@
"options": [
{
"selected": false,
"text": "V0_4",
"value": "V0_4"
"text": "V0_6",
"value": "V0_6"
},
{
"selected": false,
"text": "V0_5",
"value": "V0_5"
"text": "V0_7",
"value": "V0_7"
}
],
"query": "V0_4,V0_5",
"query": "V0_6,V0_7",
"queryValue": "None",
"skipUrlSync": false,
"type": "custom"
Expand Down
12 changes: 0 additions & 12 deletions deployments/helm/templates/grafanadashboard.yaml

This file was deleted.

94 changes: 0 additions & 94 deletions deployments/install_papyrus.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ spec:
memory: {{ .Values.deployment.resources.requests.memory }}
{{- if not .Values.backup.enabled }}
args:
- --config_file
- /app/config/presets/{{ .Values.starknet.preset }}
- --base_layer.node_url
- {{ .Values.base_layer_node_url }}
- --config_file
- /app/config/presets/{{ .Values.starknet.preset }}
- --base_layer.node_url
- {{ .Values.base_layer_node_url }}
{{ range $key, $value := .Values.deployment.extraArgs }}
{{- if $value }}
- --{{ $key }}
- {{ $value | quote }}
{{- else }}
- --{{ $key }}
{{- end }}
{{ end }}
{{- if .Values.services }}
ports:
- containerPort: {{ .Values.services.rpc.port }}
Expand Down
12 changes: 12 additions & 0 deletions deployments/papyrus/helm/templates/grafana-alerts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.grafanaAlerts.enabled }}
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
name: {{ .Release.Namespace }}-alerts
namespace: {{ .Release.Namespace | quote }}
labels:
app: grafana-dashboard
spec:
json: |
{{- (.Files.Get "Monitoring/grafana_alerts.json") | nindent 4 }}
{{- end }}
12 changes: 12 additions & 0 deletions deployments/papyrus/helm/templates/grafana-dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.grafanaDashboard.enabled }}
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
name: {{ .Release.Namespace }}-dashboard
namespace: {{ .Release.Namespace | quote }}
labels:
app: grafana-dashboard
spec:
json: |
{{- (.Files.Get "Monitoring/grafana_dashboard.json") | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "papyrus.labels" . | nindent 4 }}
{{- if .Values.ingress.annotations }}
{{- with .Values.ingress.annotations }}
annotations:
{{ tpl .Values.ingress.annotations . | nindent 4 | trim }}
{{- end }}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
rules:
- host: {{ .Values.ingress.host }}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ deployment:
# The container image
image:
repository: ghcr.io/starkware-libs/papyrus
tag: 0.2.0
tag: 0.4.0
# The container's pullPolicy
pullPolicy: Always
# Optional - nodeSelector
Expand All @@ -34,6 +34,8 @@ deployment:
requests:
cpu: 500m
memory: 1Gi
extraArgs: {} # Optional additional deployment args
# collect_metrics: "true"

# Service variables for a papyrus pod.
services:
Expand Down Expand Up @@ -73,13 +75,15 @@ ingress:
# Ingress path type.
pathType:
# Annotations to apply to the node ingress.
annotations:
annotations: {}

# GrafanaDashboad CRD configuration
# This is relevant for Grafana Operator users https://grafana.github.io/grafana-operator/docs/
grafanadashboard:
grafanaDashboard:
# Should the GrafanaDashboard object be installed
enabled: false
grafanaAlerts:
enabled: false

# Backup mode
backup:
Expand Down
71 changes: 71 additions & 0 deletions deployments/papyrus/install_papyrus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import argparse
import json
import subprocess
import sys

GRAFANA_DASHBOARD_TEMPLATE_FILE_PATH = "monitoring/templates/grafana_dashboard.json"
GRAFANA_ALERTS_TEMPLATE_FILE_PATH = "monitoring/templates/grafana_alerts.json"
GRAFANA_DASHBOARD_DESTINATION_FILE_PATH = "helm/Monitoring/grafana_dashboard.json"
GRAFANA_ALERTS_DESTINATION_FILE_PATH = "helm/Monitoring/grafana_alerts.json"

# TODO: Add function to deploy monitoring dashboard.
def parse_command_line_args():
parser = argparse.ArgumentParser(description="Install Papyrus node.")
parser.add_argument("--release_name", type=str, required=True, help="Name for the helm release.")
parser.add_argument("--namespace", type=str, required=True, help="Target namespace for the Papyrus node.")
parser.add_argument("--create_namespace", action="store_true", default=False, help="Enabling this option will install a new namespace with the given name.")
parser.add_argument("--values_file", action="store", default=None, help="Add additional values file.")
parser.add_argument("--with_alerts", action="store_true", default=False, help="Enabling this option will also deploy a grafana alerts deashboard with the pod.")
parser.add_argument("--prometheus_uid", type=str, required=False, help="UID for prometheus (to use with Grafana).")
parser.add_argument("--old_version", type=str, required=False, help="Represents previous RPC version for the desired env (e.g. v0_3).")
parser.add_argument("--new_version", type=str, required=False, help="Represents current RPC version for the desired env (e.g. v0_4).")
parser.add_argument("--dry_run", action="store_true", default=False, help="Enabling this option will dry run the helm upgrade.",)
parser.add_argument("--helm_deployment_dir", type=str, required=False, default="./deployments/helm/", help="Relative path to the helm deployment directory (default is ./deployments/helm/.")

return parser.parse_args()

def generate_grafana_tokens(grafana_namespace: str, prometheus_uid: str, template_path: str, destination_path: str):
grafana_template_lines = open(template_path).readlines()
grafana_dashboard_lines = list()
for line in grafana_template_lines:
grafana_dashboard_lines.append(
line.replace("NAMESPACE", grafana_namespace).replace("${DS_PROMETHEUS}", prometheus_uid))
grafana_dashboard = "".join(line for line in grafana_dashboard_lines)
grafana_deployment_file = open(destination_path, "a")
# Delete previous file contents.
grafana_deployment_file.truncate(0)
grafana_deployment_file.write(grafana_dashboard)
grafana_deployment_file.flush()

def main():
args = parse_command_line_args()
print(args)
# The CMD assumes this script is being run from the root directory.
cmd = f"helm upgrade --install {args.release_name} {args.helm_deployment_dir} --namespace {args.namespace}"
if args.create_namespace:
cmd += " --create-namespace"
if args.values_file:
cmd += f" -f {args.values_file}"
if args.with_alerts:
assert args.prometheus_uid is not None, "Must provide Prometheus UID when deploying with Grafana."
generate_grafana_tokens(
grafana_namespace=args.namespace,
prometheus_uid=args.prometheus_uid,
template_path=GRAFANA_DASHBOARD_TEMPLATE_FILE_PATH,
destination_path=GRAFANA_DASHBOARD_DESTINATION_FILE_PATH
)
generate_grafana_tokens(
grafana_namespace=args.namespace,
prometheus_uid=args.prometheus_uid,
template_path=GRAFANA_ALERTS_TEMPLATE_FILE_PATH,
destination_path=GRAFANA_ALERTS_DESTINATION_FILE_PATH
)

if args.dry_run:
cmd += " --dry-run"

print(f"running {cmd}...")
subprocess.Popen(cmd, shell=True)

if __name__ == "__main__":
sys.exit(main())
Loading

0 comments on commit 68f52e7

Please sign in to comment.