From 0768d9fb7f466a9064de40c4ea3d39282fbaf54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Mart=C3=ADn=20Garc=C3=ADa?= <49920382+amartingarcia@users.noreply.github.com> Date: Fri, 4 Nov 2022 12:02:28 +0100 Subject: [PATCH] Feat/default resources (#4) * feat(default-resources): upload default-resources chart * fix(default-resources): delete wrong files --- charts/default-resources/Chart.yaml | 22 +++++++ charts/default-resources/README.md | 23 +++++++ charts/default-resources/templates/NOTES.txt | 0 .../default-resources/templates/_helpers.tpl | 27 ++++++++ .../templates/namespace.yaml | 10 +++ charts/default-resources/templates/quota.yaml | 14 +++++ .../default-resources/templates/secrets.yaml | 16 +++++ .../templates/serviceaccount.yaml | 15 +++++ .../templates/volumesnapshotclass.yaml | 20 ++++++ charts/default-resources/values.yaml | 63 +++++++++++++++++++ 10 files changed, 210 insertions(+) create mode 100644 charts/default-resources/Chart.yaml create mode 100644 charts/default-resources/README.md create mode 100644 charts/default-resources/templates/NOTES.txt create mode 100644 charts/default-resources/templates/_helpers.tpl create mode 100644 charts/default-resources/templates/namespace.yaml create mode 100644 charts/default-resources/templates/quota.yaml create mode 100644 charts/default-resources/templates/secrets.yaml create mode 100644 charts/default-resources/templates/serviceaccount.yaml create mode 100644 charts/default-resources/templates/volumesnapshotclass.yaml create mode 100644 charts/default-resources/values.yaml diff --git a/charts/default-resources/Chart.yaml b/charts/default-resources/Chart.yaml new file mode 100644 index 0000000..62bf81e --- /dev/null +++ b/charts/default-resources/Chart.yaml @@ -0,0 +1,22 @@ +# Chart info +apiVersion: v2 +name: default-resources +description: A Helm chart for Default Resources + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 1.0.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: 1.0.0 diff --git a/charts/default-resources/README.md b/charts/default-resources/README.md new file mode 100644 index 0000000..ede8543 --- /dev/null +++ b/charts/default-resources/README.md @@ -0,0 +1,23 @@ +# default-resources + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) + +A Helm chart for Default Resources + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| VolumeSnapshotClass.config | list | `[]` | | +| VolumeSnapshotClass.create | bool | `false` | | +| namespaces.create | bool | `false` | | +| namespaces.name | list | `[]` | | +| quotas.config | list | `[]` | | +| quotas.create | bool | `false` | | +| secrets.config | list | `[]` | | +| secrets.create | bool | `false` | | +| serviceAccounts.config | list | `[]` | | +| serviceAccounts.create | bool | `false` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/charts/default-resources/templates/NOTES.txt b/charts/default-resources/templates/NOTES.txt new file mode 100644 index 0000000..e69de29 diff --git a/charts/default-resources/templates/_helpers.tpl b/charts/default-resources/templates/_helpers.tpl new file mode 100644 index 0000000..c4a4c39 --- /dev/null +++ b/charts/default-resources/templates/_helpers.tpl @@ -0,0 +1,27 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "default-resources.name" -}} +{{- default .Chart.Name -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "default-resources.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "default-resources.labels" -}} +app.kubernetes.io/name: {{ include "default-resources.name" . }} +helm.sh/chart: {{ include "default-resources.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} diff --git a/charts/default-resources/templates/namespace.yaml b/charts/default-resources/templates/namespace.yaml new file mode 100644 index 0000000..62827e6 --- /dev/null +++ b/charts/default-resources/templates/namespace.yaml @@ -0,0 +1,10 @@ +{{ if .Values.namespaces.create }} +{{ range .Values.namespaces.name }} +--- +apiVersion: v1 +kind: Namespace +metadata: + name: {{ . }} + +{{ end }} +{{ end }} \ No newline at end of file diff --git a/charts/default-resources/templates/quota.yaml b/charts/default-resources/templates/quota.yaml new file mode 100644 index 0000000..6043ca3 --- /dev/null +++ b/charts/default-resources/templates/quota.yaml @@ -0,0 +1,14 @@ +{{ if (.Values.quotas.create)}} +{{ range .Values.quotas.config }} +--- +apiVersion: v1 +kind: ResourceQuota +metadata: + name: {{ .namespace }} + namespace: {{ .namespace }} +spec: + hard: +{{ toYaml .spec | indent 4 }} + +{{ end }} +{{ end }} \ No newline at end of file diff --git a/charts/default-resources/templates/secrets.yaml b/charts/default-resources/templates/secrets.yaml new file mode 100644 index 0000000..443ecda --- /dev/null +++ b/charts/default-resources/templates/secrets.yaml @@ -0,0 +1,16 @@ +{{ if .Values.secrets.create }} +{{ range $secrets := .Values.secrets.config }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .name }} + namespace: {{ .namespace }} +type: {{ .type }} +data: +{{- range $key, $value := $secrets.data }} + {{ $value.name }}: {{ $value.value | b64enc | quote }} +{{- end }} + +{{ end }} +{{ end }} \ No newline at end of file diff --git a/charts/default-resources/templates/serviceaccount.yaml b/charts/default-resources/templates/serviceaccount.yaml new file mode 100644 index 0000000..b0d1623 --- /dev/null +++ b/charts/default-resources/templates/serviceaccount.yaml @@ -0,0 +1,15 @@ +{{ if .Values.serviceAccounts.create }} +{{ range .Values.serviceAccounts.config }} +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .name }} + annotations: + {{- with .annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + namespace: {{ .namespace }} + +{{ end }} +{{ end }} \ No newline at end of file diff --git a/charts/default-resources/templates/volumesnapshotclass.yaml b/charts/default-resources/templates/volumesnapshotclass.yaml new file mode 100644 index 0000000..e1d00bb --- /dev/null +++ b/charts/default-resources/templates/volumesnapshotclass.yaml @@ -0,0 +1,20 @@ +{{ if .Values.VolumeSnapshotClass.create }} +{{ range .Values.VolumeSnapshotClass.config }} +--- +apiVersion: snapshot.storage.k8s.io/v1 +kind: VolumeSnapshotClass +metadata: + name: {{ .name }} + labels: + {{- with .labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +driver: {{ .driver }} +deletionPolicy: {{ .deletionPolicy }} +parameters: +{{- with .parameters }} + {{- toYaml . | nindent 2 }} +{{- end }} + +{{ end }} +{{ end }} \ No newline at end of file diff --git a/charts/default-resources/values.yaml b/charts/default-resources/values.yaml new file mode 100644 index 0000000..34c8511 --- /dev/null +++ b/charts/default-resources/values.yaml @@ -0,0 +1,63 @@ +# Custom values for default-resources. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +--- +namespaces: + create: false + name: [] +# - integration +# - monitoring + +quotas: + create: false + config: [] +# - namespace: integration +# quota_requests_cpu: "4" +# quota_requests_memory: "6Gi" +# quota_limits_cpu: "4" +# quota_limits_memory: "6Gi" +# - namespace: monitoring +# quota_requests_cpu: "2" +# quota_requests_memory: "2Gi" +# quota_limits_cpu: "2" +# quota_limits_memory: "2Gi" + +secrets: + create: false + config: [] +# - name: my-secret +# namespace: my-namespace +# type: Opaque +# data: +# - name: data-name +# value: data-value + +serviceAccounts: + create: false + config: [] +# - name: integration +# namespace: integration +# clusterRoleRules: [] +# - apiGroups: ["extensions", "app"] +# resources: ["deployments"] +# verbs: ["get", "list", "watch", "create", "update", "patch"] +# - apiGroups: ["extensions", "app"] +# resources: ["deployments"] +# verbs: ["get", "list", "watch", "create", "update", "patch"] +# - name: monitoring +# namespace: monitoring +# clusterRoleRules: [] +# - apiGroups: ["*"] +# resources: ["*"] +# verbs: ["get", "list"] + +VolumeSnapshotClass: + create: false + config: [] +# - name: my-volume-snapshot-class +# labels: +# key: value +# driver: my-driver +# deletionPolicy: Retain +# parameters: +# tags: 'foo=aaa,bar=bbb' \ No newline at end of file