From 5175656b18202bfdefadbcc1ed68df02fcf42907 Mon Sep 17 00:00:00 2001 From: Francisco de Paz Galan Date: Thu, 29 Sep 2022 19:37:30 +0200 Subject: [PATCH] [bitnami/node-exporter] Add tests and publishing using VIB (#12727) * [bitnami/node-exporter] Add tests and publishing using VIB Signed-off-by: FraPazGal * update CD pipeline Signed-off-by: FraPazGal * Modify missing resourceName for cluster-wide resource Signed-off-by: FraPazGal Signed-off-by: FraPazGal --- .github/workflows/cd-pipeline.yml | 1 + .vib/node-exporter/cypress/cypress.json | 3 +++ .../cypress/integration/node_exporter_spec.js | 12 +++++++++ .vib/node-exporter/goss/goss.yaml | 22 ++++++++++++++++ .vib/node-exporter/goss/vars.yaml | 9 +++++++ .vib/node-exporter/vib-publish.json | 26 +++++++++++++++++-- .vib/node-exporter/vib-verify.json | 26 +++++++++++++++++-- bitnami/node-exporter/Chart.yaml | 2 +- .../templates/psp-clusterrole.yaml | 4 +-- .../templates/psp-clusterrolebinding.yaml | 4 +-- bitnami/node-exporter/templates/psp.yaml | 2 +- 11 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 .vib/node-exporter/cypress/cypress.json create mode 100644 .vib/node-exporter/cypress/cypress/integration/node_exporter_spec.js create mode 100644 .vib/node-exporter/goss/goss.yaml create mode 100644 .vib/node-exporter/goss/vars.yaml diff --git a/.github/workflows/cd-pipeline.yml b/.github/workflows/cd-pipeline.yml index 8068c164f7..dfad72b9b5 100644 --- a/.github/workflows/cd-pipeline.yml +++ b/.github/workflows/cd-pipeline.yml @@ -49,6 +49,7 @@ on: # rebuild any PRs and main branch changes - 'bitnami/nginx-intel/**' - 'bitnami/nginx/**' - 'bitnami/node/**' + - 'bitnami/node-exporter/**' - 'bitnami/odoo/**' - 'bitnami/opencart/**' - 'bitnami/osclass/**' diff --git a/.vib/node-exporter/cypress/cypress.json b/.vib/node-exporter/cypress/cypress.json new file mode 100644 index 0000000000..d6586ea939 --- /dev/null +++ b/.vib/node-exporter/cypress/cypress.json @@ -0,0 +1,3 @@ +{ + "baseUrl": "http://localhost/" +} diff --git a/.vib/node-exporter/cypress/cypress/integration/node_exporter_spec.js b/.vib/node-exporter/cypress/cypress/integration/node_exporter_spec.js new file mode 100644 index 0000000000..b4a0a1f46b --- /dev/null +++ b/.vib/node-exporter/cypress/cypress/integration/node_exporter_spec.js @@ -0,0 +1,12 @@ +/// + +it('can check cluster health', () => { + cy.request({ + method: 'GET', + url: '/metrics', + form: true, + }).then((response) => { + expect(response.status).to.eq(200); + expect(response.body).to.contain('node_network_info gauge'); + }); +}); diff --git a/.vib/node-exporter/goss/goss.yaml b/.vib/node-exporter/goss/goss.yaml new file mode 100644 index 0000000000..0d45dcfdcc --- /dev/null +++ b/.vib/node-exporter/goss/goss.yaml @@ -0,0 +1,22 @@ +file: + /host/proc: + exists: true + filetype: directory + mode: "0555" + owner: root + /host/sys: + exists: true + filetype: directory + mode: "0555" + owner: root + /var/run/secrets/kubernetes.io/serviceaccount: + exists: {{ .Vars.serviceAccount.automountServiceAccountToken }} + filetype: directory + mode: "3777" +command: + check-user-info: + exec: id + exit-status: 0 + stdout: + - uid={{ .Vars.containerSecurityContext.runAsUser }} + - /groups=.*{{ .Vars.podSecurityContext.fsGroup }}/ diff --git a/.vib/node-exporter/goss/vars.yaml b/.vib/node-exporter/goss/vars.yaml new file mode 100644 index 0000000000..801c56d7fa --- /dev/null +++ b/.vib/node-exporter/goss/vars.yaml @@ -0,0 +1,9 @@ +serviceAccount: + automountServiceAccountToken: true +podSecurityContext: + fsGroup: 1002 +containerSecurityContext: + runAsUser: 1002 +service: + ports: + metrics: 80 diff --git a/.vib/node-exporter/vib-publish.json b/.vib/node-exporter/vib-publish.json index d74c121114..32017f7d7c 100644 --- a/.vib/node-exporter/vib-publish.json +++ b/.vib/node-exporter/vib-publish.json @@ -22,11 +22,11 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/node-exporter" }, - "runtime_parameters": "InNlcnZpY2UiOgogICJwb3J0cyI6IAogICAgIm1ldHJpY3MiOiA4MAogICJ0eXBlIjogIkxvYWRCYWxhbmNlciIK", + "runtime_parameters": "cmJhYzoKICBjcmVhdGU6IHRydWUKICBwc3BFbmFibGVkOiB0cnVlCnNlcnZpY2VBY2NvdW50OgogIGNyZWF0ZTogdHJ1ZQogIGF1dG9tb3VudFNlcnZpY2VBY2NvdW50VG9rZW46IHRydWUKY29udGFpbmVyUG9ydHM6CiAgbWV0cmljczogOTEwMQpwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKc2VydmljZToKICBwb3J0czogCiAgICBtZXRyaWNzOiA4MAogIHR5cGU6IExvYWRCYWxhbmNlcg==", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { - "name": "S4" + "name": "L4" } } }, @@ -37,6 +37,28 @@ "endpoint": "lb-node-exporter-metrics", "app_protocol": "HTTP" } + }, + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib/node-exporter/goss" + }, + "remote": { + "workload": "ds-node-exporter" + }, + "vars_file": "vars.yaml" + } + }, + { + "action_id": "cypress", + "params": { + "resources": { + "path": "/.vib/node-exporter/cypress" + }, + "endpoint": "lb-node-exporter-metrics", + "app_protocol": "HTTP" + } } ] }, diff --git a/.vib/node-exporter/vib-verify.json b/.vib/node-exporter/vib-verify.json index 8d6dbd0fc8..d01ae2f83a 100644 --- a/.vib/node-exporter/vib-verify.json +++ b/.vib/node-exporter/vib-verify.json @@ -22,11 +22,11 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/node-exporter" }, - "runtime_parameters": "InNlcnZpY2UiOgogICJwb3J0cyI6IAogICAgIm1ldHJpY3MiOiA4MAogICJ0eXBlIjogIkxvYWRCYWxhbmNlciIK", + "runtime_parameters": "cmJhYzoKICBjcmVhdGU6IHRydWUKICBwc3BFbmFibGVkOiB0cnVlCnNlcnZpY2VBY2NvdW50OgogIGNyZWF0ZTogdHJ1ZQogIGF1dG9tb3VudFNlcnZpY2VBY2NvdW50VG9rZW46IHRydWUKY29udGFpbmVyUG9ydHM6CiAgbWV0cmljczogOTEwMQpwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKc2VydmljZToKICBwb3J0czogCiAgICBtZXRyaWNzOiA4MAogIHR5cGU6IExvYWRCYWxhbmNlcg==", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { - "name": "S4" + "name": "L4" } } }, @@ -37,6 +37,28 @@ "endpoint": "lb-node-exporter-metrics", "app_protocol": "HTTP" } + }, + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib/node-exporter/goss" + }, + "remote": { + "workload": "ds-node-exporter" + }, + "vars_file": "vars.yaml" + } + }, + { + "action_id": "cypress", + "params": { + "resources": { + "path": "/.vib/node-exporter/cypress" + }, + "endpoint": "lb-node-exporter-metrics", + "app_protocol": "HTTP" + } } ] } diff --git a/bitnami/node-exporter/Chart.yaml b/bitnami/node-exporter/Chart.yaml index 86001f7d97..33c4ff987e 100644 --- a/bitnami/node-exporter/Chart.yaml +++ b/bitnami/node-exporter/Chart.yaml @@ -24,4 +24,4 @@ sources: - https://github.com/bitnami/containers/tree/main/bitnami/node-exporter - https://github.com/prometheus/node_exporter - https://prometheus.io/ -version: 3.1.4 +version: 3.2.0 diff --git a/bitnami/node-exporter/templates/psp-clusterrole.yaml b/bitnami/node-exporter/templates/psp-clusterrole.yaml index 60934830eb..07772eaa26 100644 --- a/bitnami/node-exporter/templates/psp-clusterrole.yaml +++ b/bitnami/node-exporter/templates/psp-clusterrole.yaml @@ -3,7 +3,7 @@ kind: ClusterRole apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }} metadata: - name: {{ template "common.names.fullname" . }}-psp + name: {{ printf "%s-%s" (include "common.names.fullname.namespace" .) "psp" }} namespace: {{ include "common.names.namespace" . | quote }} labels: {{- include "common.labels.standard" . | nindent 4 }} {{- if .Values.commonLabels }} @@ -17,7 +17,7 @@ rules: resources: ['podsecuritypolicies'] verbs: ['use'] resourceNames: - - {{ template "common.names.fullname" . }} + - {{ template "common.names.fullname.namespace" . }} {{- if .Values.rbac.rules }} {{- include "common.tplvalues.render" ( dict "value" .Values.rbac.rules "context" $ ) | nindent 2 }} {{- end }} diff --git a/bitnami/node-exporter/templates/psp-clusterrolebinding.yaml b/bitnami/node-exporter/templates/psp-clusterrolebinding.yaml index 6a1bcfb00c..d6fbe445fd 100644 --- a/bitnami/node-exporter/templates/psp-clusterrolebinding.yaml +++ b/bitnami/node-exporter/templates/psp-clusterrolebinding.yaml @@ -3,7 +3,7 @@ apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }} kind: ClusterRoleBinding metadata: - name: {{ template "common.names.fullname" . }}-psp + name: {{ printf "%s-%s" (include "common.names.fullname.namespace" .) "psp" }} namespace: {{ include "common.names.namespace" . | quote }} labels: {{- include "common.labels.standard" . | nindent 4 }} {{- if .Values.commonLabels }} @@ -15,7 +15,7 @@ metadata: roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: {{ template "common.names.fullname" . }}-psp + name: {{ printf "%s-%s" (include "common.names.fullname.namespace" .) "psp" }} subjects: - kind: ServiceAccount name: {{ template "node-exporter.serviceAccountName" . }} diff --git a/bitnami/node-exporter/templates/psp.yaml b/bitnami/node-exporter/templates/psp.yaml index d6ed72ae1b..962fe19eb3 100644 --- a/bitnami/node-exporter/templates/psp.yaml +++ b/bitnami/node-exporter/templates/psp.yaml @@ -3,7 +3,7 @@ apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata: - name: {{ template "common.names.fullname" . }} + name: {{ template "common.names.fullname.namespace" . }} namespace: {{ include "common.names.namespace" . | quote }} labels: {{- include "common.labels.standard" . | nindent 4 }} {{- if .Values.commonLabels }}