From 83b3d73460711b092377c738153d8a10867d88a5 Mon Sep 17 00:00:00 2001 From: Rajesh Rajendran Date: Sat, 12 Jun 2021 00:08:35 +0530 Subject: [PATCH 1/2] fix(install): update cache before installation Signed-off-by: Rajesh Rajendran --- scripts/helm/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helm/install.sh b/scripts/helm/install.sh index 67e94e269..881d98808 100755 --- a/scripts/helm/install.sh +++ b/scripts/helm/install.sh @@ -17,6 +17,7 @@ domain_name=`grep domain_name vars.yaml | grep -v "example" | cut -d " " -f2 | c } } +sudo apt update which docker &> /dev/null || { echo "docker is not installed. Installing it..." user=`whoami` @@ -38,7 +39,6 @@ export KUBECONFIG=~/.kube/config sed -i "s#kubeconfig.*#kubeconfig_path: ${HOME}/.kube/config#g" vars.yaml # Installing nfs common for NFS -sudo apt update sudo apt install -y nfs-common bash -x kube-install.sh $@ From b958da38dd83eee33b10bd59792bfdffe6d93fbd Mon Sep 17 00:00:00 2001 From: Rajesh Rajendran Date: Fri, 11 Jun 2021 21:10:31 +0000 Subject: [PATCH 2/2] Enable monitoring for enterprise edition (#32) * chore(install): flag to install monitoring Signed-off-by: Rajesh Rajendran * chore(install): change request to min memory and cpu. * chore(install): grafana proxy path Signed-off-by: Rajesh Rajendran * chore(install): ansible tag for grafana password Signed-off-by: Rajesh Rajendran * fix(install): grafana password override Signed-off-by: Rajesh Rajendran * chore(install): Adding grafana nginx path Signed-off-by: Rajesh Rajendran * feat(nginx): getting resolver ip for nginx ip resolution. Signed-off-by: Rajesh Rajendran --- scripts/helm/app/alerts.yaml | 4 +-- scripts/helm/app/assets.yaml | 4 +-- scripts/helm/app/chalice.yaml | 4 +-- scripts/helm/app/db.yaml | 4 +-- scripts/helm/app/ender.yaml | 4 +-- scripts/helm/app/http.yaml | 4 +-- scripts/helm/app/integrations.yaml | 4 +-- scripts/helm/app/sink.yaml | 4 +-- scripts/helm/app/storage.yaml | 4 +-- scripts/helm/kube-install.sh | 29 ++++++++++++++----- .../nginx-ingress/templates/configmap.yaml | 10 +++++++ .../nginx-ingress/nginx-ingress/values.yaml | 3 ++ .../roles/openreplay/tasks/install-apps.yaml | 12 +++++++- .../roles/openreplay/tasks/pre-check.yaml | 16 ++++++++++ .../openreplay/templates/monitoring.yaml | 6 ++++ scripts/helm/vars.yaml | 22 +++++++++----- 16 files changed, 100 insertions(+), 34 deletions(-) create mode 100644 scripts/helm/roles/openreplay/templates/monitoring.yaml diff --git a/scripts/helm/app/alerts.yaml b/scripts/helm/app/alerts.yaml index 0485f7eee..f992a7cee 100644 --- a/scripts/helm/app/alerts.yaml +++ b/scripts/helm/app/alerts.yaml @@ -18,8 +18,8 @@ resources: cpu: 256m memory: 512Mi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi env: ALERT_NOTIFICATION_STRING: http://chalice-openreplay.app.svc.cluster.local:8000/alerts/notifications diff --git a/scripts/helm/app/assets.yaml b/scripts/helm/app/assets.yaml index ed38781bf..cedc5f6aa 100644 --- a/scripts/helm/app/assets.yaml +++ b/scripts/helm/app/assets.yaml @@ -18,8 +18,8 @@ resources: cpu: 256m memory: 512Mi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi env: ASSETS_ORIGIN: /sessions-assets # TODO: full path (with the minio prefix) diff --git a/scripts/helm/app/chalice.yaml b/scripts/helm/app/chalice.yaml index 78955c2da..a53846acd 100644 --- a/scripts/helm/app/chalice.yaml +++ b/scripts/helm/app/chalice.yaml @@ -17,8 +17,8 @@ resources: cpu: 1000m memory: 1Gi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi env: AWS_DEFAULT_REGION: us-east-1 pg_host: postgresql.db.svc.cluster.local diff --git a/scripts/helm/app/db.yaml b/scripts/helm/app/db.yaml index d74ab3a92..98b96b855 100644 --- a/scripts/helm/app/db.yaml +++ b/scripts/helm/app/db.yaml @@ -18,8 +18,8 @@ resources: cpu: 256m memory: 512Mi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi env: POSTGRES_STRING: postgres://postgres:asayerPostgres@postgresql.db.svc.cluster.local:5432 diff --git a/scripts/helm/app/ender.yaml b/scripts/helm/app/ender.yaml index d1545de05..9c88afa0f 100644 --- a/scripts/helm/app/ender.yaml +++ b/scripts/helm/app/ender.yaml @@ -18,8 +18,8 @@ resources: cpu: 256m memory: 512Mi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi env: REDIS_STRING: redis-master.db.svc.cluster.local:6379 diff --git a/scripts/helm/app/http.yaml b/scripts/helm/app/http.yaml index 251461145..f594df201 100644 --- a/scripts/helm/app/http.yaml +++ b/scripts/helm/app/http.yaml @@ -18,8 +18,8 @@ resources: cpu: 256m memory: 512Mi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi env: ASSETS_ORIGIN: /sessions-assets # TODO: full path (with the minio prefix) diff --git a/scripts/helm/app/integrations.yaml b/scripts/helm/app/integrations.yaml index 69d6d5e58..0a8a2ee91 100644 --- a/scripts/helm/app/integrations.yaml +++ b/scripts/helm/app/integrations.yaml @@ -18,8 +18,8 @@ resources: cpu: 512m memory: 1Gi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi env: POSTGRES_STRING: postgres://postgres:asayerPostgres@postgresql.db.svc.cluster.local:5432 diff --git a/scripts/helm/app/sink.yaml b/scripts/helm/app/sink.yaml index e80e06102..51113fdd0 100644 --- a/scripts/helm/app/sink.yaml +++ b/scripts/helm/app/sink.yaml @@ -18,8 +18,8 @@ resources: cpu: 512m memory: 512Mi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi pvc: create: true diff --git a/scripts/helm/app/storage.yaml b/scripts/helm/app/storage.yaml index 9f3889566..836deab4a 100644 --- a/scripts/helm/app/storage.yaml +++ b/scripts/helm/app/storage.yaml @@ -18,8 +18,8 @@ resources: cpu: 512m memory: 512Mi requests: - cpu: 100m - memory: 128Mi + cpu: 1m + memory: 1Mi pvc: # PVC Created from filesink.yaml diff --git a/scripts/helm/kube-install.sh b/scripts/helm/kube-install.sh index 0dc9d9777..6e8102e5e 100755 --- a/scripts/helm/kube-install.sh +++ b/scripts/helm/kube-install.sh @@ -17,6 +17,7 @@ uline="\e[4m" reset="\e[0m" working_dir=$(pwd) +script_name=`basename "$0"` echo -e ${reset} @@ -86,6 +87,7 @@ cat <<"EOF" EOF echo -e "${green}Usage: openreplay-cli [ -h | --help ] [ -v | --verbose ] + [ -m | --monitoring ] [ -e | --enterprise ] [ -a | --app APP_NAME ] to install/reinstall specific application [ -t | --type small|medium|ideal ]" @@ -105,9 +107,9 @@ apps can specifically be installed/reinstalled: installation_type=1 type() { case "$1" in - small) installation_type=1 ;; + small) installation_type=1 ;; medium) installation_type=1.5 ;; - ideal) installation_type=2 ;; + ideal) installation_type=2 ;; *) echo -e ${red}${bold}'ERROR!!!\nwrong value for `type`'${reset} usage ;; @@ -136,15 +138,25 @@ function app(){ esac } +enterprise=0 function enterprise(){ + enterprise=1 sed -i "s#enterprise_edition_license.*#enterprise_edition_license: \"${1}\"#g" vars.yaml # Updating image version to be ee sed -i "s/\(image_tag.*[0-9]\)\"$/\1-ee\"/" vars.yaml echo "Importing enterprise code..." cp -rf ../../ee/scripts/* ../ } +monitoring(){ + if [[ enterprise -eq 0 ]]; then + echo -e "${red}Monitoring is supported only for enterprise edition.\n bash ./${script_name} -e --monitoring ${reset}" + exit 1 + fi + sed -i "s#enable_monitoring.*#enable_monitoring: \"true\"#g" vars.yaml +} + # Parsing command line args. -PARSED_ARGUMENTS=$(color getopt -a -n openreplay-cli -o vht:a:e: --long verbose,help,type:,app:,enterprise: -- "$@") +PARSED_ARGUMENTS=$(color getopt -a -n openreplay-cli -o vht:a:e:m --long verbose,help,type:,app:,enterprise:,monitoring -- "$@") VALID_ARGUMENTS=$? if [[ "$VALID_ARGUMENTS" != "0" ]]; then usage @@ -154,11 +166,12 @@ eval set -- "$PARSED_ARGUMENTS" while : do case "$1" in - -v | --verbose) VERBOSE=1 ; shift ;; - -h | --help) usage ; shift ;; - -t | --type) type $2 ; shift 2 ;; - -a | --app) app $2 ; shift 2 ;; - -e | --enterprise) enterprise $2 ; shift 2 ;; + -v | --verbose) VERBOSE=1 ; shift ;; + -h | --help) usage ; shift ;; + -t | --type) type $2 ; shift 2 ;; + -a | --app) app $2 ; shift 2 ;; + -e | --enterprise) enterprise $2 ; shift 2 ;; + -m | --monitoring) monitoring ; shift ;; # -- means the end of the arguments; drop this, and break out of the while loop --) shift; break ;; # If invalid options were passed, then getopt should have reported an error, diff --git a/scripts/helm/nginx-ingress/nginx-ingress/templates/configmap.yaml b/scripts/helm/nginx-ingress/nginx-ingress/templates/configmap.yaml index d02cc26b1..fad59aa89 100644 --- a/scripts/helm/nginx-ingress/nginx-ingress/templates/configmap.yaml +++ b/scripts/helm/nginx-ingress/nginx-ingress/templates/configmap.yaml @@ -43,6 +43,15 @@ data: proxy_set_header Host $host; proxy_pass http://http-openreplay.app.svc.cluster.local; } + location /grafana { + set $target http://monitoring-grafana.monitoring.svc.cluster.local; + rewrite ^/grafana/(.*) /$1 break; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + proxy_pass $target; + } location /streaming/ { set $target http://ios-proxy-openreplay.app.svc.cluster.local; rewrite ^/streaming/(.*) /$1 break; proxy_http_version 1.1; @@ -107,6 +116,7 @@ data: ; sites.conf: |- + resolver {{ .Values.kubeDnsIP }}; # Need real ip address for flags in replay. # Some LBs will forward real ips as x-forwarded-for # So making that as priority diff --git a/scripts/helm/nginx-ingress/nginx-ingress/values.yaml b/scripts/helm/nginx-ingress/nginx-ingress/values.yaml index a89f4ca9e..9a703e387 100644 --- a/scripts/helm/nginx-ingress/nginx-ingress/values.yaml +++ b/scripts/helm/nginx-ingress/nginx-ingress/values.yaml @@ -10,6 +10,9 @@ image: # Overrides the image tag whose default is the chart appVersion. tag: "" +# DNS address of the kubernetes resolver +kubeDnsIP: "" + imagePullSecrets: [] nameOverride: "" fullnameOverride: "" diff --git a/scripts/helm/roles/openreplay/tasks/install-apps.yaml b/scripts/helm/roles/openreplay/tasks/install-apps.yaml index 3e511ac19..4f45a9608 100644 --- a/scripts/helm/roles/openreplay/tasks/install-apps.yaml +++ b/scripts/helm/roles/openreplay/tasks/install-apps.yaml @@ -20,7 +20,17 @@ - "app/*.yaml" when: app_name|length == 0 tags: apps + +- name: getting kube dns ip + shell: kubectl get service --namespace kube-system kube-dns -o jsonpath="{.spec.clusterIP}" + register: kube_dns_ip + tags: nginx - name: Installing Proxy shell: | - helm upgrade --install -n nginx-ingress nginx-ingress "./nginx-ingress/nginx-ingress" --create-namespace + helm upgrade --install -n nginx-ingress nginx-ingress "./nginx-ingress/nginx-ingress" --create-namespace --set kubeDnsIP="{{ kube_dns_ip.stdout }}" tags: nginx +- name: Installing Monitoring + shell: | + helm upgrade --install -n monitoring monitoring "./monitoring/kube-prometheus-stack" -f "/tmp/monitoring.yaml" --create-namespace + tags: monitoring + when: enable_monitoring == "true" diff --git a/scripts/helm/roles/openreplay/tasks/pre-check.yaml b/scripts/helm/roles/openreplay/tasks/pre-check.yaml index 9f503a220..7f85d0ea1 100644 --- a/scripts/helm/roles/openreplay/tasks/pre-check.yaml +++ b/scripts/helm/roles/openreplay/tasks/pre-check.yaml @@ -126,3 +126,19 @@ when: enterprise_edition_license|length > 0 register: enterprise_edition_license_check failed_when: enterprise_edition_license_check.json.data.valid != true +- name: Generaing grafana password + block: + - name: Generating grafana password + set_fact: + grafana_password_generated: "{{ lookup('password', '/dev/null length=30 chars=ascii_letters') }}" + - name: Updating vars.yaml + lineinfile: + regexp: '^grafana_password' + line: 'grafana_password: "{{ grafana_password_generated }}"' + path: vars.yaml + - name: Generating grafana access key + set_fact: + grafana_password: "{{ grafana_password_generated }}" + when: grafana_password|length == 0 + tags: + - pre-check diff --git a/scripts/helm/roles/openreplay/templates/monitoring.yaml b/scripts/helm/roles/openreplay/templates/monitoring.yaml new file mode 100644 index 000000000..48c9146f0 --- /dev/null +++ b/scripts/helm/roles/openreplay/templates/monitoring.yaml @@ -0,0 +1,6 @@ +fullnameOverride: "openreplay" +grafana: + adminPassword: "{{ grafana_password }}" + env: + GF_SERVER_ROOT_URL: http://grafana.local.com/grafana + diff --git a/scripts/helm/vars.yaml b/scripts/helm/vars.yaml index a6525e526..69e77defa 100644 --- a/scripts/helm/vars.yaml +++ b/scripts/helm/vars.yaml @@ -46,13 +46,6 @@ nginx_ssl_key_file_path: "" # By default, a default key will be generated and will update the value here. jwt_secret_key: "" -# Enable monitoring -# If set, monitoring stack will be installed -# including, prometheus, grafana and other core components, -# to scrape the metrics. But this will cost, additional resources (cpu and memory). -# Monitoring won't be installed on base installation. -enable_monitoring: "false" - # Random password for minio, # If not defined, will generate at runtime. # Use following command to generate password @@ -63,3 +56,18 @@ minio_secret_key: "" # If you're using enterprise edition. # Insert the enterprise_edition_License key which you got. enterprise_edition_license: "" + +# Enable monitoring +# If set, monitoring stack will be installed +# including, prometheus, grafana and other core components, +# to scrape the metrics. But this will cost, additional resources (cpu and memory). +# Monitoring won't be installed on base installation. +enable_monitoring: "false" +# Password for grafana. +# If password is not given, it'll be generated, and updated here. +# +# Use following command to generate password +# `openssl rand -base64 30` +# +# Username: admin +grafana_password: ""