diff --git a/pkg/config/templates/patch/rancher-monitoring/102.0.0+up40.1.2/nginx-config.yaml b/pkg/config/templates/patch/rancher-monitoring/102.0.0+up40.1.2/nginx-config.yaml new file mode 100644 index 000000000..924439431 --- /dev/null +++ b/pkg/config/templates/patch/rancher-monitoring/102.0.0+up40.1.2/nginx-config.yaml @@ -0,0 +1,90 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: grafana-nginx-proxy-config + namespace: {{ template "grafana.namespace" . }} + labels: + {{- include "grafana.labels" . | nindent 4 }} +data: + nginx.conf: |- + worker_processes auto; + error_log /dev/stdout warn; + pid /var/cache/nginx/nginx.pid; + + events { + worker_connections 1024; + } + + http { + include /etc/nginx/mime.types; + log_format main '[$time_local - $status] $remote_addr - $remote_user $request ($http_referer)'; + + proxy_connect_timeout 10; + proxy_read_timeout 180; + proxy_send_timeout 5; + proxy_buffering off; + proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=my_zone:100m inactive=1d max_size=10g; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + server { + listen 8080; + access_log off; + + gzip on; + gzip_min_length 1k; + gzip_comp_level 2; + gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript image/jpeg image/gif image/png; + gzip_vary on; + gzip_disable "MSIE [1-6]\."; + + proxy_set_header Host $host; + + location /api/dashboards { + proxy_pass http://localhost:3000; + } + + location /api/search { + proxy_pass http://localhost:3000; + + sub_filter_types application/json; + sub_filter_once off; + } + + location /api/live/ { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $http_host; + proxy_pass http://localhost:3000; + } + + location / { + proxy_cache my_zone; + proxy_cache_valid 200 302 1d; + proxy_cache_valid 301 30d; + proxy_cache_valid any 5m; + proxy_cache_bypass $http_cache_control; + add_header X-Proxy-Cache $upstream_cache_status; + add_header Cache-Control "public"; + + proxy_pass http://localhost:3000/; + + sub_filter_once off; + + sub_filter '"appSubUrl":""' '"appSubUrl":"/api/v1/namespaces/{{ template "grafana.namespace" . }}/services/http:{{ template "grafana.fullname" . }}:{{ .Values.service.port }}/proxy"'; + + sub_filter ':"/avatar/' ':"avatar/'; + + if ($request_filename ~ .*\.(?:js|css|jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$) { + expires 90d; + } + + rewrite ^/k8s/clusters/.*/proxy(.*) /$1 break; + + } + } + } diff --git a/pkg/config/templates/rancherd-22-addons.yaml b/pkg/config/templates/rancherd-22-addons.yaml index a22793192..57be3e7e5 100644 --- a/pkg/config/templates/rancherd-22-addons.yaml +++ b/pkg/config/templates/rancherd-22-addons.yaml @@ -114,7 +114,7 @@ resources: namespace: cattle-monitoring-system spec: repo: http://harvester-cluster-repo.cattle-system.svc/charts - version: "100.1.0+up19.0.3" + version: "102.0.0+up40.1.2" chart: rancher-monitoring {{- if and .Addons .Addons.rancher_monitoring }} enabled: {{ .Addons.rancher_monitoring.Enabled }} diff --git a/scripts/build-bundle b/scripts/build-bundle index c6e535d1f..e179eddb9 100755 --- a/scripts/build-bundle +++ b/scripts/build-bundle @@ -14,6 +14,7 @@ source ${SCRIPTS_DIR}/version-rke2 source ${SCRIPTS_DIR}/version-rancher source ${SCRIPTS_DIR}/lib/http source ${SCRIPTS_DIR}/lib/image +source ${SCRIPTS_DIR}/hack/patch-rancher-monitoring source ${SCRIPTS_DIR}/hack/patch-rancher-logging BUNDLE_DIR="${PACKAGE_HARVESTER_OS_DIR}/iso/bundle" @@ -61,9 +62,13 @@ source ${SCRIPTS_DIR}/version-monitoring helm pull https://charts.rancher.io/assets/rancher-monitoring-crd/rancher-monitoring-crd-${MONITORING_VERSION}.tgz -d ${CHARTS_DIR} helm pull https://charts.rancher.io/assets/rancher-monitoring/rancher-monitoring-${MONITORING_VERSION}.tgz -d ${CHARTS_DIR} +# patch rancher-monitoring chart to fix issues +PKG_PATCH_MONITORING_PATH="${TOP_DIR}/pkg/config/templates/patch/rancher-monitoring" +patch_rancher_monitoring_chart ${CHARTS_DIR} ${MONITORING_VERSION} ${PKG_PATCH_MONITORING_PATH} + # make chart sanity check -tar zxvf ${CHARTS_DIR}/rancher-monitoring-crd-${MONITORING_VERSION}.tgz >/dev/null -tar zxvf ${CHARTS_DIR}/rancher-monitoring-${MONITORING_VERSION}.tgz >/dev/null +tar zxvf ${CHARTS_DIR}/rancher-monitoring-crd-${MONITORING_VERSION}.tgz >/dev/null --warning=no-timestamp +tar zxvf ${CHARTS_DIR}/rancher-monitoring-${MONITORING_VERSION}.tgz >/dev/null --warning=no-timestamp # Prepare logging chart source ${SCRIPTS_DIR}/version-logging @@ -71,25 +76,25 @@ helm pull https://charts.rancher.io/assets/rancher-logging-crd/rancher-logging-c helm pull https://charts.rancher.io/assets/rancher-logging/rancher-logging-${LOGGING_VERSION}.tgz -d ${CHARTS_DIR} # make chart sanity check -tar zxvf ${CHARTS_DIR}/rancher-logging-crd-${LOGGING_VERSION}.tgz >/dev/null -tar zxvf ${CHARTS_DIR}/rancher-logging-${LOGGING_VERSION}.tgz >/dev/null +tar zxvf ${CHARTS_DIR}/rancher-logging-crd-${LOGGING_VERSION}.tgz >/dev/null --warning=no-timestamp +tar zxvf ${CHARTS_DIR}/rancher-logging-${LOGGING_VERSION}.tgz >/dev/null --warning=no-timestamp # patch rancher-logging chart to collect more logs" PKG_PATCH_LOGGING_PATH="${TOP_DIR}/pkg/config/templates/patch/rancher-logging" patch_rancher_logging_chart ${CHARTS_DIR} ${LOGGING_VERSION} ${PKG_PATCH_LOGGING_PATH} # make chart sanity check again after patch -tar zxvf ${CHARTS_DIR}/rancher-logging-${LOGGING_VERSION}.tgz >/dev/null +tar zxvf ${CHARTS_DIR}/rancher-logging-${LOGGING_VERSION}.tgz >/dev/null --warning=no-timestamp # Prepare vm-import-controller-chart helm pull https://github.com/harvester/charts/releases/download/harvester-vm-import-controller-${VM_IMPORT_CONTROLLER_CHART_VERSION}/harvester-vm-import-controller-${VM_IMPORT_CONTROLLER_CHART_VERSION}.tgz -d ${CHARTS_DIR} # make chart sanity check -tar zxvf ${CHARTS_DIR}/harvester-vm-import-controller-${VM_IMPORT_CONTROLLER_CHART_VERSION}.tgz >/dev/null +tar zxvf ${CHARTS_DIR}/harvester-vm-import-controller-${VM_IMPORT_CONTROLLER_CHART_VERSION}.tgz >/dev/null --warning=no-timestamp # Prepare pcidevices-chart helm pull https://github.com/harvester/charts/releases/download/harvester-pcidevices-controller-${PCIDEVICES_CONTROLLER_CHART_VERSION}/harvester-pcidevices-controller-${PCIDEVICES_CONTROLLER_CHART_VERSION}.tgz -d ${CHARTS_DIR} # make chart sanity check -tar zxvf ${CHARTS_DIR}/harvester-pcidevices-controller-${PCIDEVICES_CONTROLLER_CHART_VERSION}.tgz >/dev/null +tar zxvf ${CHARTS_DIR}/harvester-pcidevices-controller-${PCIDEVICES_CONTROLLER_CHART_VERSION}.tgz >/dev/null --warning=no-timestamp # Create Helm repo index after charts are ready diff --git a/scripts/hack/patch-rancher-monitoring b/scripts/hack/patch-rancher-monitoring new file mode 100755 index 000000000..4ee2704cc --- /dev/null +++ b/scripts/hack/patch-rancher-monitoring @@ -0,0 +1,34 @@ +#!/bin/bash + +patch_rancher_monitoring_chart() +{ + local chart_dir=$1 #${CHARTS_DIR} + local monitoring_version=$2 #MONITORING_VERSION + local pkg_monitoring_path=$3 #${PKG_PATCH_MONITORING_PATH} + local cwd=$(pwd) + + if [ ! -d "${pkg_monitoring_path}/${monitoring_version}" ]; then + echo "NOTE: there is no related path: ${pkg_monitoring_path}/${monitoring_version} to patch, SKIP" + return 0 + fi + + cd ${chart_dir} + tar zxf rancher-monitoring-${monitoring_version}.tgz --warning=no-timestamp + + local nm="./rancher-monitoring/charts/grafana/templates/nginx-config.yaml" + echo "patch $nm, original file" + ls -alth "$nm" || echo "file $nm is not found" + rm -f "$nm" + cp -f ${pkg_monitoring_path}/${monitoring_version}/nginx-config.yaml "$nm" + echo "patched file" + ls -alth "$nm" + + # remove existing chart + rm -f ${chart_dir}/rancher-monitoring-${monitoring_version}.tgz + + # helm pack new + helm package rancher-monitoring + echo "finish patch ranch-monitoring chart" + cd $cwd +} + diff --git a/scripts/version-monitoring b/scripts/version-monitoring index 598876e72..eee778a58 100644 --- a/scripts/version-monitoring +++ b/scripts/version-monitoring @@ -1 +1 @@ -MONITORING_VERSION=100.1.0+up19.0.3 +MONITORING_VERSION=102.0.0+up40.1.2