From 358191904954c1568f8e7545ea19c0764c338fb0 Mon Sep 17 00:00:00 2001 From: Erickson Silva de Oliveira Date: Tue, 13 Feb 2024 09:13:29 -0300 Subject: [PATCH 1/2] Add sample app to metrics-server This patch allows the creation of a metrics-server sample-app. It adds the necessary elements to templates to create a sample-app pod on a metrics-server namespace. Signed-off-by: Erickson Silva de Oliveira Signed-off-by: Luiz Felipe Kina --- templates/sample-app-cluster-role-binding.yml | 16 ++++++++++++ templates/sample-app-cluster-role.yml | 17 +++++++++++++ templates/sample-app-deployment.yml | 25 +++++++++++++++++++ templates/sample-app-service-account.yml | 11 ++++++++ values.yaml | 8 ++++++ 5 files changed, 77 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-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 00000000..cffc2f1a --- /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: metrics-server-test-app + name: access-metrics-api +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: access-metrics-api +subjects: +- kind: ServiceAccount + name: metrics-server-test-app + namespace: metrics-server +{{- end }} diff --git a/templates/sample-app-cluster-role.yml b/templates/sample-app-cluster-role.yml new file mode 100644 index 00000000..c78fb282 --- /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: metrics-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 00000000..26de1cc9 --- /dev/null +++ b/templates/sample-app-deployment.yml @@ -0,0 +1,25 @@ +{{- if .Values.sampleApp.create -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: metrics-server-test-app-deployment + namespace: metrics-server +spec: + selector: + matchLabels: + app: metrics-server-test-app + replicas: 1 + template: + metadata: + labels: + app: metrics-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: metrics-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 00000000..81b0ef6a --- /dev/null +++ b/templates/sample-app-service-account.yml @@ -0,0 +1,11 @@ +{{- if .Values.sampleApp.create -}} +apiVersion: v1 +imagePullSecrets: +- name: default-registry-key +kind: ServiceAccount +metadata: + labels: + app: metrics-server-test-app + name: metrics-server-test-app + namespace: metrics-server +{{- end }} diff --git a/values.yaml b/values.yaml index 4f6b9219..54567451 100644 --- a/values.yaml +++ b/values.yaml @@ -195,5 +195,13 @@ deploymentAnnotations: {} schedulerName: "" +# 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 + tmpVolume: emptyDir: {} -- 2.34.1