metrics-server-armada-app/metrics-server-helm/files/0001-Add-sample-app-to-metrics-server.patch
Luiz Felipe Kina 6b839fdc28 Fixing metrics-server on Centos and Debian
A previous patch had wrong values to download images. Fixed the patch.
Metrics-server-helm on debian wasn't working, it was fixed and
metrics-server-helm was added as a dependency for
stx-metrics-server-helm.

TEST PLAN CENTOS:
PASS Build-pkgs centos
PASS Build-iso centos
PASS Apply application centos
PASS Remove application centos

TEST PLAN DEBIAN:
PASS Build-pkgs debian
PASS Build-iso debian
PASS Apply application debian
PASS Remove application debian

Closes-bug: 1979586

Signed-off-by: Luiz Felipe Kina <LuizFelipe.EiskeKina@windriver.com>
Signed-off-by: Felipe Sanches Zanoni <Felipe.SanchesZanoni@windriver.com>
Change-Id: I988a5032d7d3fc8769ed6c502d37cfc3493ea282
2022-06-23 16:38:36 +00:00

147 lines
4.3 KiB
Diff

From eb8e6805914d912be374eb86731a88c3936b91b8 Mon Sep 17 00:00:00 2001
From: Luiz Felipe Kina <LuizFelipe.EiskeKina@windriver.com>
Date: Wed, 22 Jun 2022 22:08:25 -0400
Subject: [PATCH] Add sample app to metrics-server
Signed-off-by: Luiz Felipe Kina <LuizFelipe.EiskeKina@windriver.com>
---
templates/sample-app-cluster-role-binding.yml | 16 ++++++++++++
templates/sample-app-cluster-role.yml | 17 +++++++++++++
templates/sample-app-deployment.yml | 25 +++++++++++++++++++
templates/sample-app-namespace.yml | 6 +++++
templates/sample-app-service-account.yml | 9 +++++++
values.yaml | 9 +++++++
6 files changed, 82 insertions(+)
create mode 100644 templates/sample-app-cluster-role-binding.yml
create mode 100644 templates/sample-app-cluster-role.yml
create mode 100644 templates/sample-app-deployment.yml
create mode 100644 templates/sample-app-namespace.yml
create mode 100644 templates/sample-app-service-account.yml
diff --git a/templates/sample-app-cluster-role-binding.yml b/templates/sample-app-cluster-role-binding.yml
new file mode 100644
index 0000000..ad4e316
--- /dev/null
+++ b/templates/sample-app-cluster-role-binding.yml
@@ -0,0 +1,16 @@
+{{- if .Values.sampleApp.create -}}
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+ labels:
+ app: metric-server-test-app
+ name: access-metrics-api
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: ClusterRole
+ name: access-metrics-api
+subjects:
+- kind: ServiceAccount
+ name: metric-server-test-app
+ namespace: metric-server-test-app
+{{- end }}
\ No newline at end of file
diff --git a/templates/sample-app-cluster-role.yml b/templates/sample-app-cluster-role.yml
new file mode 100644
index 0000000..c78fb28
--- /dev/null
+++ b/templates/sample-app-cluster-role.yml
@@ -0,0 +1,17 @@
+{{- if .Values.sampleApp.create -}}
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRole
+metadata:
+ labels:
+ app: metric-server-test-app
+ name: access-metrics-api
+rules:
+- apiGroups:
+ - metrics.k8s.io
+ resources:
+ - pods
+ - nodes
+ verbs:
+ - get
+ - list
+{{- end }}
\ No newline at end of file
diff --git a/templates/sample-app-deployment.yml b/templates/sample-app-deployment.yml
new file mode 100644
index 0000000..d26498b
--- /dev/null
+++ b/templates/sample-app-deployment.yml
@@ -0,0 +1,25 @@
+{{- if .Values.sampleApp.create -}}
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: metric-server-test-app-deployment
+ namespace: metric-server-test-app
+spec:
+ selector:
+ matchLabels:
+ app: metric-server-test-app
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: metric-server-test-app
+ spec:
+ containers:
+ - name: sample-app
+ image: {{ printf "%s:%s" .Values.sampleApp.image.repository (.Values.sampleApp.image.tag | default "latest") }}
+ imagePullPolicy: IfNotPresent
+ env:
+ - name: TOKEN_PATH
+ value: /var/run/secrets/kubernetes.io/serviceaccount/token
+ serviceAccountName: metric-server-test-app
+{{- end -}}
diff --git a/templates/sample-app-namespace.yml b/templates/sample-app-namespace.yml
new file mode 100644
index 0000000..5a83759
--- /dev/null
+++ b/templates/sample-app-namespace.yml
@@ -0,0 +1,6 @@
+{{- if .Values.sampleApp.create -}}
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: metric-server-test-app
+{{- end }}
diff --git a/templates/sample-app-service-account.yml b/templates/sample-app-service-account.yml
new file mode 100644
index 0000000..5e116c0
--- /dev/null
+++ b/templates/sample-app-service-account.yml
@@ -0,0 +1,9 @@
+{{- if .Values.sampleApp.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ labels:
+ app: metric-server-test-app
+ name: metric-server-test-app
+ namespace: metric-server-test-app
+{{- end }}
\ No newline at end of file
diff --git a/values.yaml b/values.yaml
index 6a97505..5167d25 100644
--- a/values.yaml
+++ b/values.yaml
@@ -128,3 +128,12 @@ nodeSelector: {}
tolerations: []
affinity: {}
+
+# If you want to deploy a sample app application to test metrics server
+# Set the create value to true
+sampleApp:
+ create: false
+ image:
+ repository: docker.io/starlingx/stx-metrics-server-sample-app
+ tag: stx.7.0-v1.0.0
+
--
2.29.2