diff --git a/helm_template_common.sh b/helm_template_common.sh new file mode 100755 index 0000000000..e3c4ec7835 --- /dev/null +++ b/helm_template_common.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +common_path=library/common/1.0.0 + +go-yq -i '.type = "application"' "$common_path"/Chart.yaml +helm template ./"$common_path" +go-yq -i '.type = "library"' "$common_path"/Chart.yaml diff --git a/library/common-test/tests/pods/deployment-test.yaml b/library/common-test/tests/pods/deployment-test.yaml index 1a21b4beb4..d776c1a9bc 100644 --- a/library/common-test/tests/pods/deployment-test.yaml +++ b/library/common-test/tests/pods/deployment-test.yaml @@ -17,6 +17,25 @@ tests: documentIndex: *deploymentDoc path: metadata.name value: RELEASE-NAME-common-test + - equal: + documentIndex: *deploymentDoc + path: metadata.labels + value: + app: common-test + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + app.kubernetes.io/version: v1.0.0 + helm-revision: "0" + helm.sh/chart: common-test-1.0.0 + release: RELEASE-NAME + - isNotEmpty: + documentIndex: *deploymentDoc + path: metadata.annotations.rollme + - equal: + documentIndex: *deploymentDoc + path: spec.revisionHistoryLimit + value: 3 - it: should pass with nameOverride set: @@ -37,6 +56,47 @@ tests: path: metadata.name value: RELEASE-NAME-globalOverrodeName + - it: should pass with controller and global labels + set: + controller.labels: + controllerkey: controllervalue + global.labels: + globalkey: globalvalue + asserts: + - equal: + documentIndex: *deploymentDoc + path: metadata.labels + value: + controllerkey: controllervalue + globalkey: globalvalue + app: common-test + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + app.kubernetes.io/version: v1.0.0 + helm-revision: "0" + helm.sh/chart: common-test-1.0.0 + release: RELEASE-NAME + + - it: should pass with controller and global annotations + set: + controller.annotations: + controllerkey: controllervalue + global.annotations: + globalkey: globalvalue + asserts: + - equal: + documentIndex: *deploymentDoc + path: metadata.annotations.controllerkey + value: controllervalue + - equal: + documentIndex: *deploymentDoc + path: metadata.annotations.globalkey + value: globalvalue + - isNotEmpty: + documentIndex: *deploymentDoc + path: metadata.annotations.rollme + - it: should pass with controller disabled set: controller.enabled: false diff --git a/library/common/1.0.0/Chart.yaml b/library/common/1.0.0/Chart.yaml index a094981b15..e72172c2f5 100644 --- a/library/common/1.0.0/Chart.yaml +++ b/library/common/1.0.0/Chart.yaml @@ -1,7 +1,6 @@ apiVersion: v2 name: common description: A library chart for iX Official Catalog - # 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 @@ -11,15 +10,11 @@ description: A library chart for iX Official Catalog # 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. -# Temporary set to application so I can render it locally type: library -# 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. # Versions are expected to follow Semantic Versioning (https://semver.org/) 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. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. diff --git a/library/common/1.0.0/templates/common.yaml b/library/common/1.0.0/templates/common.yaml new file mode 100644 index 0000000000..8b11432b96 --- /dev/null +++ b/library/common/1.0.0/templates/common.yaml @@ -0,0 +1 @@ +{{ include "ix.v1.common.loader.all" . }} diff --git a/library/common/1.0.0/templates/pods/_deployment.tpl b/library/common/1.0.0/templates/pods/_deployment.tpl index 7cfd707fd1..f6958fd878 100644 --- a/library/common/1.0.0/templates/pods/_deployment.tpl +++ b/library/common/1.0.0/templates/pods/_deployment.tpl @@ -8,7 +8,10 @@ apiVersion: {{ include "ix.v1.common.capabilities.deployment.apiVersion" $ }} kind: Deployment metadata: name: {{ include "ix.v1.common.names.fullname" . }} - labels: - annotations: + {{- $labels := merge (default dict .Values.controller.labels) (include "ix.v1.common.labels" $ | fromYaml) }} + labels: {{- (toYaml $labels) | nindent 4 }} + {{- $annotations := merge (default dict .Values.controller.annotations) (include "ix.v1.common.annotations" $ | fromYaml) (include "ix.v1.common.annotations.workload" $ | fromYaml ) }} + annotations: {{- (toYaml $annotations) | nindent 4 }} spec: + revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} {{- end }} diff --git a/library/common/1.0.0/values.yaml b/library/common/1.0.0/values.yaml index ca483609f0..16c0e69710 100644 --- a/library/common/1.0.0/values.yaml +++ b/library/common/1.0.0/values.yaml @@ -19,3 +19,9 @@ controller: # -- Set the controller type. # Valid options are: deployment | daemonset | statefulset type: deployment + # -- Set labels on the deployment/statefulset/daemonset + labels: {} + # -- Set annotations on the deployment/statefulset/daemonset + annotations: {} + # -- Revision history limit + revisionHistoryLimit: 3