From 6ac7c55114e4b551466d03e856e0aa709b570258 Mon Sep 17 00:00:00 2001 From: Karim Radhouani Date: Mon, 13 Nov 2023 16:04:58 -0800 Subject: [PATCH] update lab --- .goreleaser.yml | 4 +-- labs/clab/config/app/config.yaml | 2 ++ labs/clab/prometheus-exporter.clab.yaml | 2 +- labs/clab/run.sh | 39 ++++++++++++++++--------- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index e0bbb6c..107a674 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -11,7 +11,7 @@ builds: archives: - name_template: >- {{ .ProjectName }}_ - {{- .Version }}_ + {{- slice .Version 1 }}_ {{- title .Os }}_ {{- if eq .Arch "amd64" }}x86_64 {{- else }}{{ .Arch }}{{ end }} @@ -36,7 +36,7 @@ nfpms: - id: srl-prometheus-exporter-nfpms file_name_template: >- {{ .ProjectName }}_ - {{- .Version }}_ + {{- slice .Version 1 }}_ {{- title .Os }}_ {{- if eq .Arch "amd64" }}x86_64 {{- else }}{{ .Arch }}{{ end }} diff --git a/labs/clab/config/app/config.yaml b/labs/clab/config/app/config.yaml index 17c9a8e..64e7684 100644 --- a/labs/clab/config/app/config.yaml +++ b/labs/clab/config/app/config.yaml @@ -5,6 +5,8 @@ updates: value: admin-state: enable use-authentication: false + services: + - gnmi - path: /acl/cpm-filter/ipv4-filter/entry[sequence-id=281] encoding: json_ietf diff --git a/labs/clab/prometheus-exporter.clab.yaml b/labs/clab/prometheus-exporter.clab.yaml index b4c76a5..6208b10 100644 --- a/labs/clab/prometheus-exporter.clab.yaml +++ b/labs/clab/prometheus-exporter.clab.yaml @@ -9,7 +9,7 @@ topology: srl: image: ghcr.io/nokia/srlinux:latest binds: - - ./app:/tmp/rpm:ro + - ./app:/tmp/pkg:ro nodes: srl1: diff --git a/labs/clab/run.sh b/labs/clab/run.sh index f92491d..f4d4c43 100755 --- a/labs/clab/run.sh +++ b/labs/clab/run.sh @@ -2,28 +2,34 @@ ./stop.sh -version=0.2.8 +version=0.2.13 username=admin password=NokiaSrl1! +pkg="deb" -filename="srl-prometheus-exporter_${version}_Linux_x86_64.rpm" +# script path +SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" -rm -rf app -mkdir -p app +rm -rf $SCRIPTPATH/app +mkdir -p $SCRIPTPATH/app + +filename="srl-prometheus-exporter_${version}_Linux_x86_64.$pkg" + +cd $SCRIPTPATH/../.. if [[ $1 == "build" ]]; then - # build RPM + # build pkgs echo "building using goreleaser" - cd ../.. goreleaser --snapshot --clean release - cp dist/*.rpm labs/clab/app/ - cd labs/clab + cp dist/*.${pkg} labs/clab/app/ else - # download the app installation RPM - echo "downloading the app RPM" + # download the app installation package + echo "downloading the app package" curl -sSL https://github.com/karimra/srl-prometheus-exporter/releases/download/v${version}/${filename} -o app/${filename} fi +cd $SCRIPTPATH + #deploy the lab sudo clab dep -c @@ -43,7 +49,14 @@ clab_exec_args="--topo prometheus-exporter.clab.yaml --label clab-node-kind=srl sudo clab exec $clab_exec_args "sr_cli show system application" # install the RPM located in /tmp/rpm -sudo clab exec $clab_exec_args "sudo rpm -U /tmp/rpm/*rpm" + +if [[ $pkg == "rpm" ]]; then + sudo clab exec $clab_exec_args "sudo rpm -U /tmp/pkg/$filename" +else + sudo clab exec $clab_exec_args "sudo dpkg -i /tmp/pkg/$filename" +fi + +sleep 10 # reload the app manager so it picks up the newly installed app sudo clab exec $clab_exec_args "sr_cli tools system app-management application app_mgr reload" @@ -84,8 +97,8 @@ gnmic $gnmic_args -e json_ietf \ --update-value enable # check that the SRLs prometheus endpoint is UP -# curl clab-prom-exporter-srl1:8888/metrics -# curl clab-prom-exporter-srl2:8888/metrics +curl -sSL clab-prom-exporter-srl1:8888/metrics +curl -sSL clab-prom-exporter-srl2:8888/metrics # navigate to the prometheus server GUI on :9090/targets # you should see that both SRL prometheus exporters are UP and being scraped by Prometheus \ No newline at end of file