From 10ab45d51cade9fd6b51f1ddffc4bb514c3421f2 Mon Sep 17 00:00:00 2001 From: ccremer Date: Thu, 14 Jul 2022 11:09:19 +0200 Subject: [PATCH 1/4] Add notice that K8up chart has moved Signed-off-by: ccremer --- appuio/k8up/README.gotmpl.md | 41 ------------------------------------ appuio/k8up/README.md | 20 ++++++++---------- 2 files changed, 9 insertions(+), 52 deletions(-) delete mode 100644 appuio/k8up/README.gotmpl.md diff --git a/appuio/k8up/README.gotmpl.md b/appuio/k8up/README.gotmpl.md deleted file mode 100644 index 059c2733..00000000 --- a/appuio/k8up/README.gotmpl.md +++ /dev/null @@ -1,41 +0,0 @@ -```bash -kubectl apply -f https://github.com/k8up-io/k8up/releases/download/{{ template "chart.appVersion" . }}/k8up-crd.yaml -``` - - - -## Handling CRDs - -* Always upgrade the CRDs before upgrading the Helm release. -* Watch out for breaking changes in the {{ title .Name }} release notes. - -{{ template "chart.sourcesSection" . }} - -{{ template "chart.requirementsSection" . }} - -{{ template "chart.valuesSection" . }} - -## Upgrading from Charts 0.x to 1.x - -* In `image.repository` the registry domain was moved into its own parameter `image.registry`. -* K8up 1.x features leader election, this enables rolling updates and multiple replicas. - `k8up.enableLeaderElection` defaults to `true`. Disable this for older Kubernetes versions (<= 1.15) -* `replicaCount` is now configurable, defaults to `1`. -* Note: Deployment strategy type has changed from `Recreate` to `RollingUpdate`. -* CRDs need to be installed separately, they are no longer included in this chart. - -## Upgrading from Charts 1.x to 2.x - -* Note: `image.repository` changed from `vshn/k8up` to `k8up-io/k8up`. -* Note: `image.registry` changed from `quay.io` to `ghcr.io`. -* Note: `image.tag` changed from `v1.x` to `v2.x`. Please see the [full changelog](https://github.com/k8up-io/k8up/releases/tag/v2.0.0). -* `metrics.prometheusRule.legacyRules` has been removed (no support for OpenShift 3.11 anymore). -* Note: `k8up.backupImage.repository` changed from `quay.io/vshn/wrestic` to `ghcr.io/k8up-io/k8up` (`wrestic` is not needed anymore in K8up v2). diff --git a/appuio/k8up/README.md b/appuio/k8up/README.md index a222fa93..b9a35c40 100644 --- a/appuio/k8up/README.md +++ b/appuio/k8up/README.md @@ -1,3 +1,12 @@ +# ⚠️ WE HAVE MOVED + +This chart is no longer maintained here. +Instead, it is now available in the [K8up repository itself](https://github.com/k8up-io/k8up/tree/master/charts/k8up). + +To communicate a clear cut, we've released the chart in version `v3.0.0` with a few changes. +The releases from `v3.0.0` and onwards are only available in the new location. +All previously released chart versions remain in the APPUiO repository (`https://charts.appuio.ch`). + # k8up ![Version: 2.0.5](https://img.shields.io/badge/Version-2.0.5-informational?style=flat-square) ![AppVersion: v2.3.2](https://img.shields.io/badge/AppVersion-v2.3.2-informational?style=flat-square) @@ -16,12 +25,6 @@ helm install k8up appuio/k8up kubectl apply -f https://github.com/k8up-io/k8up/releases/download/v2.3.2/k8up-crd.yaml ``` - - ## Handling CRDs * Always upgrade the CRDs before upgrading the Helm release. @@ -31,11 +34,6 @@ Edit the README.gotmpl.md template instead. * - ## Values | Key | Type | Default | Description | From 9764ae97b27d5d11fa9e370e7514c798bc407777 Mon Sep 17 00:00:00 2001 From: ccremer Date: Thu, 14 Jul 2022 11:00:03 +0200 Subject: [PATCH 2/4] Rename Chart.yaml to avoid CI/CD pipelines from interacting with it --- README.md | 1 - appuio/k8up/{Chart.yaml => old.Chart.yaml} | 0 2 files changed, 1 deletion(-) rename appuio/k8up/{Chart.yaml => old.Chart.yaml} (100%) diff --git a/README.md b/README.md index 566ab6fa..5539fbc0 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ helm repo add appuio https://charts.appuio.ch | [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/exoip-1.0.4/total)](https://github.com/appuio/charts/releases/tag/exoip-1.0.4) | [exoip](appuio/exoip/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/generic-0.1.2/total)](https://github.com/appuio/charts/releases/tag/generic-0.1.2) | [generic](appuio/generic/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/haproxy-2.1.0/total)](https://github.com/appuio/charts/releases/tag/haproxy-2.1.0) | [haproxy](appuio/haproxy/README.md) | -| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/k8up-2.0.5/total)](https://github.com/appuio/charts/releases/tag/k8up-2.0.5) | [k8up](appuio/k8up/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/mariadb-galera-1.2.4/total)](https://github.com/appuio/charts/releases/tag/mariadb-galera-1.2.4) | [mariadb-galera](appuio/mariadb-galera/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/maxscale-1.1.2/total)](https://github.com/appuio/charts/releases/tag/maxscale-1.1.2) | [maxscale](appuio/maxscale/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/metrics-server-2.12.1/total)](https://github.com/appuio/charts/releases/tag/metrics-server-2.12.1) | [metrics-server](appuio/metrics-server/README.md) | diff --git a/appuio/k8up/Chart.yaml b/appuio/k8up/old.Chart.yaml similarity index 100% rename from appuio/k8up/Chart.yaml rename to appuio/k8up/old.Chart.yaml From 5ae5202d18b590678a73d1cfc48bc38c3ba5a704 Mon Sep 17 00:00:00 2001 From: ccremer Date: Thu, 14 Jul 2022 11:01:48 +0200 Subject: [PATCH 3/4] Remove K8up unit tests --- appuio/k8up/Makefile | 45 ------ appuio/k8up/test/deployment_test.go | 116 -------------- appuio/k8up/test/main_test.go | 7 - .../k8up/test/prometheus/prometheus_test.go | 6 - .../test/prometheus/prometheusrule_test.go | 144 ------------------ .../test/prometheus/servicemonitor_test.go | 60 -------- .../prometheus/testdata/custom_rules.yaml | 12 -- .../k8up/test/prometheus/testdata/labels.yaml | 9 -- appuio/k8up/test/rbac_test.go | 63 -------- appuio/k8up/test/service_test.go | 67 -------- appuio/k8up/test/serviceaccount_test.go | 59 ------- appuio/k8up/test/testdata/deployment_1.yaml | 14 -- 12 files changed, 602 deletions(-) delete mode 100644 appuio/k8up/Makefile delete mode 100644 appuio/k8up/test/deployment_test.go delete mode 100644 appuio/k8up/test/main_test.go delete mode 100644 appuio/k8up/test/prometheus/prometheus_test.go delete mode 100644 appuio/k8up/test/prometheus/prometheusrule_test.go delete mode 100644 appuio/k8up/test/prometheus/servicemonitor_test.go delete mode 100644 appuio/k8up/test/prometheus/testdata/custom_rules.yaml delete mode 100644 appuio/k8up/test/prometheus/testdata/labels.yaml delete mode 100644 appuio/k8up/test/rbac_test.go delete mode 100644 appuio/k8up/test/service_test.go delete mode 100644 appuio/k8up/test/serviceaccount_test.go delete mode 100644 appuio/k8up/test/testdata/deployment_1.yaml diff --git a/appuio/k8up/Makefile b/appuio/k8up/Makefile deleted file mode 100644 index 7181119a..00000000 --- a/appuio/k8up/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -MAKEFLAGS += --warn-undefined-variables -SHELL := bash -.SHELLFLAGS := -eu -o pipefail -c -.DEFAULT_GOAL := help -.DELETE_ON_ERROR: -.SUFFIXES: - -# git tag of the K8up version to fetch -# defaults to tag specified in values.yaml, as this gets maintained by renovate -APP_VERSION ?= $(shell grep -E "^ tag: " values.yaml | cut -d " " -f 4 | sed s/\"//g) - -SED_BIN := sed - -REPLACE_RBAC_LABEL := {{- include "k8up.staticLabels" . | nindent 4 }} -REPLACE_NAME_PREFIX := {{ include "k8up.fullname" . }}- -REPLACE_SA_NAME := {{ include "k8up.serviceAccountName" . }} - -.PHONY: help -help: ## Show this help - @grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "(: ).*?## "}; {gsub(/\\:/,":",$$1)}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' - -.PHONY: rbac -rbac: templates/rbac.yaml ## Update the RBAC templates by building them from Kustomize - -.PHONY: templates/rbac.yaml -templates/rbac.yaml: - $(SED_BIN) -i -e 's/?ref=.*/?ref=$(APP_VERSION)/g' rbac-kustomize/kustomization.yaml - kustomize build rbac-kustomize -o $@ - $(SED_BIN) -i -e '1i{{- if .Values.rbac.create -}}' $@ - $(SED_BIN) -i -e 's/replace: LABELS/$(REPLACE_RBAC_LABEL)/g' $@ - $(SED_BIN) -i -e 's/PREFIX-/$(REPLACE_NAME_PREFIX)/g' $@ - $(SED_BIN) -i -e 's/name: default/name: $(REPLACE_SA_NAME)/g' $@ - $(SED_BIN) -i -e '$$a{{- end }}' $@ - -.PHONY: appVersion -appVersion: ## Replaces "appVersion" in Chart.yaml with 'image.tag' from values.yaml - $(SED_BIN) -i -e 's/^appVersion.*/appVersion: $(APP_VERSION)/' Chart.yaml - -.PHONY: update -update: rbac appVersion ## Updates all templates - -# -# "Interface" for parent Makefile -# -prepare: update ## Prepare helm chart diff --git a/appuio/k8up/test/deployment_test.go b/appuio/k8up/test/deployment_test.go deleted file mode 100644 index 6be47f2f..00000000 --- a/appuio/k8up/test/deployment_test.go +++ /dev/null @@ -1,116 +0,0 @@ -package test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/gruntwork-io/terratest/modules/helm" - "github.com/stretchr/testify/assert" - appv1 "k8s.io/api/apps/v1" -) - -var ( - tplDeployment = []string{"templates/deployment.yaml"} -) - -func Test_Deployment_ShouldRender_EnvironmentVariables(t *testing.T) { - wantRepo := "repository" - wantTag := "tag" - wantVar := "BACKUP_IMAGE" - wantTimezone := "Europe/Zurich" - wantCpuRequest := "10m" - options := &helm.Options{ - ValuesFiles: []string{"testdata/deployment_1.yaml"}, - SetValues: map[string]string{ - "k8up.backupImage.repository": wantRepo, - "k8up.backupImage.tag": wantTag, - "k8up.timezone": wantTimezone, - "k8up.globalResources.requests.cpu": wantCpuRequest, - }, - } - - got := renderDeployment(t, options, false) - - envs := got.Spec.Template.Spec.Containers[0].Env - assert.Equalf(t, wantVar, envs[0].Name, "Deployment does not use required Env %s", wantVar) - assert.Equalf(t, wantRepo+":"+wantTag, envs[0].Value, "Deployment does not use required Env Value from %s", wantVar) - assert.Equal(t, "TZ", envs[1].Name) - assert.Equal(t, wantTimezone, envs[1].Value) - assert.Equal(t, "BACKUP_OPERATOR_NAMESPACE", envs[3].Name) - assert.Equal(t, "metadata.namespace", envs[3].ValueFrom.FieldRef.FieldPath) - assert.Equal(t, "BACKUP_GLOBALCPU_REQUEST", envs[4].Name, "Deployment does not use configured Env Name") - assert.Equal(t, wantCpuRequest, envs[4].Value, "Deployment does not use configured Env Value") - assert.Equal(t, "VARIABLE", envs[5].Name, "Deployment does not use configured Env Name") - assert.Equal(t, "VALUE", envs[5].Value, "Deployment does not use configured Env Value") -} - -func Test_Deployment_ShouldRender_Affinity(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"testdata/deployment_1.yaml"}, - } - - got := renderDeployment(t, options, false) - - host := got.Spec.Template.Spec. - Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms[0].MatchExpressions[0].Values[0] - assert.Equal(t, "host", host, "Deployment does not render configured host affinity") -} - -func Test_Deployment_ShouldRender_DefaultServiceAccount(t *testing.T) { - want := releaseName + "-k8up" - options := &helm.Options{} - - got := renderDeployment(t, options, false) - serviceName := got.Spec.Template.Spec.ServiceAccountName - assert.Equal(t, want, serviceName, "Deployment does not render configured serviceName") -} - -func Test_Deployment_ShouldRender_CustomServiceAccount(t *testing.T) { - want := "test" - options := &helm.Options{ - SetValues: map[string]string{ - "serviceAccount.name": want, - }, - } - - got := renderDeployment(t, options, false) - - serviceName := got.Spec.Template.Spec.ServiceAccountName - assert.Equal(t, want, serviceName, "Deployment does not render configured serviceName") -} - -func Test_Deployment_ShouldRender_Resources(t *testing.T) { - want := "1Gi" - options := &helm.Options{ - SetValues: map[string]string{ - "resources.limits.memory": want, - }, - } - - got := renderDeployment(t, options, false) - resources := got.Spec.Template.Spec.Containers[0].Resources - assert.Equal(t, want, resources.Limits.Memory().String(), "Deployment does not render configured memory limit") -} - -func Test_Deployment_ShouldRender_Labels(t *testing.T) { - options := &helm.Options{} - - got := renderDeployment(t, options, false) - - selector := got.Spec.Selector.MatchLabels - matchLabels := got.Spec.Template.Labels - assert.Equal(t, selector, matchLabels, "Deployment does not render matching labels") -} - -func renderDeployment(t *testing.T, options *helm.Options, wantErr bool) *appv1.Deployment { - output, err := helm.RenderTemplateE(t, options, helmChartPath, releaseName, tplDeployment) - if wantErr { - require.Error(t, err) - return nil - } - require.NoError(t, err) - deployment := appv1.Deployment{} - helm.UnmarshalK8SYaml(t, output, &deployment) - return &deployment -} diff --git a/appuio/k8up/test/main_test.go b/appuio/k8up/test/main_test.go deleted file mode 100644 index acf21d16..00000000 --- a/appuio/k8up/test/main_test.go +++ /dev/null @@ -1,7 +0,0 @@ -package test - -var ( - helmChartPath = ".." - releaseName = "test-release" - chartName = "k8up" -) diff --git a/appuio/k8up/test/prometheus/prometheus_test.go b/appuio/k8up/test/prometheus/prometheus_test.go deleted file mode 100644 index cc3efa4a..00000000 --- a/appuio/k8up/test/prometheus/prometheus_test.go +++ /dev/null @@ -1,6 +0,0 @@ -package test - -var ( - helmChartPath = "../.." - releaseName = "test-release" -) diff --git a/appuio/k8up/test/prometheus/prometheusrule_test.go b/appuio/k8up/test/prometheus/prometheusrule_test.go deleted file mode 100644 index ea16b283..00000000 --- a/appuio/k8up/test/prometheus/prometheusrule_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package test - -import ( - "strings" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/gruntwork-io/terratest/modules/helm" - monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" -) - -var ( - tplPrometheusRule = []string{"templates/prometheus/prometheusrule.yaml"} -) - -func Test_PrometheusRule_GivenDisabled_WhenAdditionalRulesDefined_ThenRenderNoTemplate(t *testing.T) { - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.prometheusRule.enabled": "false", - }, - ValuesFiles: []string{"testdata/custom_rules"}, - } - - _, err := helm.RenderTemplateE(t, options, helmChartPath, releaseName, tplPrometheusRule) - assert.Error(t, err) -} - -func Test_PrometheusRule_GivenEnabled_WhenNamespaceDefined_ThenRenderNewNamespace(t *testing.T) { - expectedNamespace := "alternative" - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.prometheusRule.enabled": "true", - "metrics.prometheusRule.namespace": expectedNamespace, - }, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplPrometheusRule) - rule := monitoringv1.PrometheusRule{} - helm.UnmarshalK8SYaml(t, output, &rule) - - assert.Equal(t, expectedNamespace, rule.Namespace) -} - -func Test_PrometheusRule_GivenEnabled_WhenAdditionalLabelsDefined_ThenRenderMoreLabels(t *testing.T) { - expectedLabelKey := "my-custom-label" - expectedLabelValue := "my-value" - options := &helm.Options{ - ValuesFiles: []string{"testdata/labels.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplPrometheusRule) - rule := monitoringv1.PrometheusRule{} - helm.UnmarshalK8SYaml(t, output, &rule) - - assert.Equal(t, expectedLabelValue, rule.Labels[expectedLabelKey]) -} - -func Test_PrometheusRule_GivenEnabled_WhenCreateDefaultRulesEnabled_ThenRenderDefaultAlerts(t *testing.T) { - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.prometheusRule.enabled": "true", - }, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplPrometheusRule) - rule := monitoringv1.PrometheusRule{} - helm.UnmarshalK8SYaml(t, output, &rule) - - assert.NotEmpty(t, rule.Spec.Groups[0].Rules) - assert.GreaterOrEqual(t, len(rule.Spec.Groups[0].Rules), 4) -} - -func Test_PrometheusRule_GivenEnabled_ConfigureEnabledRules(t *testing.T) { - renderWithRulesFor := func(rules []string) []monitoringv1.Rule { - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.prometheusRule.enabled": "true", - "metrics.prometheusRule.jobFailedRulesFor": "{" + strings.Join(rules, ",") + "}", - }, - } - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplPrometheusRule) - rule := monitoringv1.PrometheusRule{} - helm.UnmarshalK8SYaml(t, output, &rule) - return rule.Spec.Groups[0].Rules - } - - rules := []string{"backup"} - assert.Len(t, findFailedRules(renderWithRulesFor(rules)), 1) - rules = append(rules, "restore", "prune") - assert.Len(t, findFailedRules(renderWithRulesFor(rules)), 3) -} - -func Test_PrometheusRule_GivenEnabled_WhenCreateDefaultRulesDisabled_ThenRenderNoTemplate(t *testing.T) { - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.prometheusRule.enabled": "true", - "metrics.prometheusRule.createDefaultRules": "false", - }, - } - - _, err := helm.RenderTemplateE(t, options, helmChartPath, releaseName, tplPrometheusRule) - assert.Error(t, err) -} - -func Test_PrometheusRule_GivenEnabled_WhenCreateDefaultRulesDisabledAndAdditionalRulesGiven_ThenRenderCustomRules(t *testing.T) { - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.prometheusRule.createDefaultRules": "false", - }, - ValuesFiles: []string{"testdata/custom_rules.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplPrometheusRule) - rule := monitoringv1.PrometheusRule{} - helm.UnmarshalK8SYaml(t, output, &rule) - - assert.Equal(t, 1, len(rule.Spec.Groups[0].Rules)) - assert.Equal(t, "MyCustomRule", rule.Spec.Groups[0].Rules[0].Alert) -} - -func Test_PrometheusRule_GivenEnabled_WhenCreateDefaultRulesEnabledAndAdditionalRulesGiven_ThenRenderDefaultAndCustomRules(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"testdata/custom_rules.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplPrometheusRule) - rule := monitoringv1.PrometheusRule{} - helm.UnmarshalK8SYaml(t, output, &rule) - - amount := len(rule.Spec.Groups[0].Rules) - assert.GreaterOrEqual(t, amount, 2) - assert.Equal(t, "MyCustomRule", rule.Spec.Groups[0].Rules[amount-1].Alert) -} - -func findFailedRules(rules []monitoringv1.Rule) []monitoringv1.Rule { - failedRules := make([]monitoringv1.Rule, 0, len(rules)) - for _, rule := range rules { - if strings.HasSuffix(rule.Alert, "Failed") { - failedRules = append(failedRules, rule) - } - } - return failedRules -} diff --git a/appuio/k8up/test/prometheus/servicemonitor_test.go b/appuio/k8up/test/prometheus/servicemonitor_test.go deleted file mode 100644 index a9242485..00000000 --- a/appuio/k8up/test/prometheus/servicemonitor_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/gruntwork-io/terratest/modules/helm" - monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" -) - -var ( - tplServiceMonitor = []string{"templates/prometheus/servicemonitor.yaml"} -) - -func Test_ServiceMonitor_GivenEnabled_WhenIntervalDefined_ThenRenderNewInterval(t *testing.T) { - expectedInterval := "1m10s" - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.serviceMonitor.enabled": "true", - "metrics.serviceMonitor.scrapeInterval": expectedInterval, - }, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplServiceMonitor) - monitor := monitoringv1.ServiceMonitor{} - helm.UnmarshalK8SYaml(t, output, &monitor) - - assert.Equal(t, expectedInterval, monitor.Spec.Endpoints[0].Interval) -} - -func Test_ServiceMonitor_GivenEnabled_WhenNamespaceDefined_ThenRenderNewNamespace(t *testing.T) { - expectedNamespace := "alternative" - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.serviceMonitor.enabled": "true", - "metrics.serviceMonitor.namespace": expectedNamespace, - }, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplServiceMonitor) - monitor := monitoringv1.ServiceMonitor{} - helm.UnmarshalK8SYaml(t, output, &monitor) - - assert.Equal(t, expectedNamespace, monitor.Namespace) -} - -func Test_ServiceMonitor_GivenEnabled_WhenAdditionalLabelsDefined_ThenRenderMoreLabels(t *testing.T) { - expectedLabelKey := "my-custom-label" - expectedLabelValue := "my-value" - options := &helm.Options{ - ValuesFiles: []string{"testdata/labels.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplServiceMonitor) - monitor := monitoringv1.ServiceMonitor{} - helm.UnmarshalK8SYaml(t, output, &monitor) - - assert.Equal(t, expectedLabelValue, monitor.Labels[expectedLabelKey]) -} diff --git a/appuio/k8up/test/prometheus/testdata/custom_rules.yaml b/appuio/k8up/test/prometheus/testdata/custom_rules.yaml deleted file mode 100644 index bb90e405..00000000 --- a/appuio/k8up/test/prometheus/testdata/custom_rules.yaml +++ /dev/null @@ -1,12 +0,0 @@ -metrics: - prometheusRule: - enabled: true - additionalRules: - - alert: MyCustomRule - expr: metric > 0 - for: 1m - labels: - severity: critical - annotations: - summary: Summary - description: Description diff --git a/appuio/k8up/test/prometheus/testdata/labels.yaml b/appuio/k8up/test/prometheus/testdata/labels.yaml deleted file mode 100644 index 4cce1934..00000000 --- a/appuio/k8up/test/prometheus/testdata/labels.yaml +++ /dev/null @@ -1,9 +0,0 @@ -metrics: - serviceMonitor: - enabled: true - additionalLabels: - my-custom-label: my-value - prometheusRule: - enabled: true - additionalLabels: - my-custom-label: my-value diff --git a/appuio/k8up/test/rbac_test.go b/appuio/k8up/test/rbac_test.go deleted file mode 100644 index 0a69a869..00000000 --- a/appuio/k8up/test/rbac_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package test - -import ( - "strings" - "testing" - - "github.com/gruntwork-io/terratest/modules/helm" - "github.com/gruntwork-io/terratest/modules/logger" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" -) - -var ( - tplRbac = []string{"templates/rbac.yaml"} -) - -func Test_RBAC_GivenDefaultSetting_WhenRenderTemplate_ThenRenderRbacRules(t *testing.T) { - options := &helm.Options{ - Logger: logger.Discard, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplRbac) - - docs := strings.Split(output, "\n---\n") - assert.Greater(t, len(docs), 1) -} - -func Test_RBAC_GivenDefaultSetting_WhenRenderTemplate_ThenRenderRbacWithReplacedValues(t *testing.T) { - options := &helm.Options{ - //Logger: logger.Discard, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplRbac) - - docs := strings.Split(output, "\n---\n") - assert.Greater(t, len(docs), 1) - - for _, doc := range docs { - obj := unstructured.Unstructured{} - helm.UnmarshalK8SYaml(t, doc, &obj.Object) - labels := obj.GetLabels() - assert.Contains(t, labels, "app.kubernetes.io/name") - assert.Contains(t, labels, "app.kubernetes.io/instance") - assert.Contains(t, labels, "app.kubernetes.io/managed-by") - assert.NotContains(t, labels, "app.kubernetes.io/version") - - name := obj.GetName() - assert.Contains(t, name, strings.Join([]string{releaseName, chartName}, "-")) - - } -} - -func Test_RBAC_GivenRbacDisabled_WhenRenderTemplate_ThenDontRenderRbacRules(t *testing.T) { - options := &helm.Options{ - SetValues: map[string]string{ - "rbac.create": "false", - }, - } - - _, err := helm.RenderTemplateE(t, options, helmChartPath, releaseName, tplRbac) - require.Error(t, err) -} diff --git a/appuio/k8up/test/service_test.go b/appuio/k8up/test/service_test.go deleted file mode 100644 index 504ee723..00000000 --- a/appuio/k8up/test/service_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package test - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/gruntwork-io/terratest/modules/helm" - corev1 "k8s.io/api/core/v1" -) - -var ( - tplService = []string{"templates/service.yaml"} -) - -func Test_Service_WhenServicePortOverridden_ThenRenderNewPort(t *testing.T) { - expectedPort := int32(9090) - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.service.port": fmt.Sprintf("%d", expectedPort), - }, - } - - service := renderService(t, options, false) - - assert.Equal(t, expectedPort, service.Spec.Ports[0].Port, "Service does not use configured port") -} - -func Test_Service_GivenTypeNodePort_WhenNodePortDefine_ThenRenderNodePort(t *testing.T) { - expectedPort := int32(30090) - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.service.nodePort": fmt.Sprintf("%d", expectedPort), - "metrics.service.type": "NodePort", - }, - } - - service := renderService(t, options, false) - - assert.Equal(t, expectedPort, service.Spec.Ports[0].NodePort, "Service does not use configured node port") - assert.Equal(t, corev1.ServiceTypeNodePort, service.Spec.Type, "Service does not use configured type") -} - -func Test_Service_GivenDefaultValues_ThenRenderMatchingLabelsWithDeployment(t *testing.T) { - expectedName := releaseName + "-k8up-metrics" - options := &helm.Options{} - - service := renderService(t, options, false) - deployment := renderDeployment(t, options, false) - - assert.Equal(t, expectedName, service.Name, "Service does not use configured name") - assert.Equal(t, service.Spec.Selector, deployment.Spec.Template.Labels, "Service labels do not match with deployment labels") -} - -func renderService(t *testing.T, options *helm.Options, wantErr bool) *corev1.Service { - output, err := helm.RenderTemplateE(t, options, helmChartPath, releaseName, tplService) - if wantErr { - require.Error(t, err) - return nil - } - require.NoError(t, err) - service := corev1.Service{} - helm.UnmarshalK8SYaml(t, output, &service) - return &service -} diff --git a/appuio/k8up/test/serviceaccount_test.go b/appuio/k8up/test/serviceaccount_test.go deleted file mode 100644 index 858ade1d..00000000 --- a/appuio/k8up/test/serviceaccount_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" - - "github.com/gruntwork-io/terratest/modules/helm" -) - -var ( - tplServiceAccount = []string{"templates/serviceaccount.yaml"} -) - -func Test_ServiceAccount_ShouldNotRender_IfDisabled(t *testing.T) { - options := &helm.Options{ - SetValues: map[string]string{ - "serviceAccount.create": "false", - }, - } - - renderServiceAccount(t, options, true) - -} - -func Test_ServiceAccount_ShouldRender_ByDefault(t *testing.T) { - want := releaseName + "-k8up" - options := &helm.Options{} - - sa := renderServiceAccount(t, options, false) - assert.Equal(t, want, sa.Name, "ServiceAccount does use configured name") -} - -func Test_ServiceAccount_ShouldRender_CustomName(t *testing.T) { - want := "test" - options := &helm.Options{ - SetValues: map[string]string{ - "serviceAccount.name": want, - }, - } - - sa := renderServiceAccount(t, options, false) - - assert.Equal(t, want, sa.Name, "ServiceAccount does use configured name") -} - -func renderServiceAccount(t *testing.T, options *helm.Options, wantErr bool) *corev1.ServiceAccount { - output, err := helm.RenderTemplateE(t, options, helmChartPath, releaseName, tplServiceAccount) - if wantErr { - require.Error(t, err) - return nil - } - require.NoError(t, err) - sa := corev1.ServiceAccount{} - helm.UnmarshalK8SYaml(t, output, &sa) - return &sa -} diff --git a/appuio/k8up/test/testdata/deployment_1.yaml b/appuio/k8up/test/testdata/deployment_1.yaml deleted file mode 100644 index 2157ea70..00000000 --- a/appuio/k8up/test/testdata/deployment_1.yaml +++ /dev/null @@ -1,14 +0,0 @@ -k8up: - envVars: - - name: VARIABLE - value: VALUE - -affinity: - nodeAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - nodeSelectorTerms: - - matchExpressions: - - key: kubernetes.io/hostname - operator: In - values: - - host From cd286b090691087fc7bc30591b34e937df7c5d97 Mon Sep 17 00:00:00 2001 From: ccremer Date: Thu, 14 Jul 2022 11:04:22 +0200 Subject: [PATCH 4/4] Ignore K8up in Renovate --- renovate.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/renovate.json b/renovate.json index 0e631c80..1c34b7a9 100644 --- a/renovate.json +++ b/renovate.json @@ -22,5 +22,8 @@ ], "prBodyNotes": [ "- [ ] PR contains the label that identifies the chart, e.g. `chart/`" + ], + "ignorePaths": [ + "**/appuio/k8up/**" ] }