From 571ae62bf0e9eb1a1835b2b999dad682148b2def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ma=CC=88der?= Date: Fri, 10 Sep 2021 15:21:11 +0200 Subject: [PATCH 1/9] Update to k8up v2.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian Mäder --- appuio/k8up/Chart.yaml | 5 ++--- appuio/k8up/README.md | 18 ++++++------------ appuio/k8up/rbac-kustomize/kustomization.yaml | 2 +- appuio/k8up/values.yaml | 6 +++--- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/appuio/k8up/Chart.yaml b/appuio/k8up/Chart.yaml index c379dfba..d5137257 100644 --- a/appuio/k8up/Chart.yaml +++ b/appuio/k8up/Chart.yaml @@ -6,11 +6,10 @@ keywords: - backup - operator - restic -version: 1.1.0 -appVersion: v1.2.0 +version: 1.2.0 +appVersion: v2.0.0 sources: - https://github.com/vshn/k8up - - https://github.com/vshn/wrestic maintainers: - name: APPUiO Team email: info@appuio.ch diff --git a/appuio/k8up/README.md b/appuio/k8up/README.md index ef65f889..c9667708 100644 --- a/appuio/k8up/README.md +++ b/appuio/k8up/README.md @@ -1,6 +1,6 @@ # k8up -![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square) ![AppVersion: v1.2.0](https://img.shields.io/badge/AppVersion-v1.2.0-informational?style=flat-square) +![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square) ![AppVersion: v2.0.0](https://img.shields.io/badge/AppVersion-v2.0.0-informational?style=flat-square) Kubernetes and OpenShift Backup Operator based on restic @@ -14,9 +14,9 @@ helm install k8up appuio/k8up ``` ```bash # Install CRDs for K8s >= 1.16: -kubectl apply -f https://github.com/vshn/k8up/releases/download/v1.2.0/k8up-crd.yaml +kubectl apply -f https://github.com/vshn/k8up/releases/download/v2.0.0/k8up-crd.yaml # Install CRDs for K8s <= 1.15 (e.g. OpenShift 3.11): -kubectl apply -f https://github.com/vshn/k8up/releases/download/v1.2.0/k8up-crd-legacy.yaml +kubectl apply -f https://github.com/vshn/k8up/releases/download/v2.0.0/k8up-crd-legacy.yaml ``` diff --git a/appuio/k8up/rbac-kustomize/kustomization.yaml b/appuio/k8up/rbac-kustomize/kustomization.yaml index e83ba2b8..04556a96 100644 --- a/appuio/k8up/rbac-kustomize/kustomization.yaml +++ b/appuio/k8up/rbac-kustomize/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - github.com/vshn/k8up/config/rbac?ref=v1.2.0 + - github.com/vshn/k8up/config/rbac?ref=v2.0.0 namePrefix: PREFIX- namespace: "{{ .Release.Namespace }}" diff --git a/appuio/k8up/values.yaml b/appuio/k8up/values.yaml index e8b483ca..4bc459f1 100644 --- a/appuio/k8up/values.yaml +++ b/appuio/k8up/values.yaml @@ -10,7 +10,7 @@ image: # -- Operator image repository repository: vshn/k8up # -- Operator image tag (version) - tag: v1.2.0 + tag: v2.0.0 imagePullSecrets: [] serviceAccount: @@ -33,9 +33,9 @@ k8up: backupImage: # -- The backup runner image repository - repository: quay.io/vshn/wrestic + repository: quay.io/vshn/k8up # -- The backup runner image tag - tag: v0.3.2 + tag: v2.0.0 # -- Specifies the timezone K8up is using for scheduling. # Empty value defaults to the timezone in which Kubernetes is deployed. From 9df364f46d96a6595436d5040c5b09ca461e37fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=A4der?= Date: Fri, 10 Sep 2021 15:40:42 +0200 Subject: [PATCH 2/9] Update appuio/k8up/Chart.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Chris Signed-off-by: Christian Mäder --- appuio/k8up/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appuio/k8up/Chart.yaml b/appuio/k8up/Chart.yaml index d5137257..d7ef5653 100644 --- a/appuio/k8up/Chart.yaml +++ b/appuio/k8up/Chart.yaml @@ -6,7 +6,7 @@ keywords: - backup - operator - restic -version: 1.2.0 +version: 2.0.0 appVersion: v2.0.0 sources: - https://github.com/vshn/k8up From e855e20f5e37f35db45fad07111cdc52401f6959 Mon Sep 17 00:00:00 2001 From: cimnine Date: Fri, 17 Sep 2021 17:34:08 +0200 Subject: [PATCH 3/9] Update vshn/k8up to k8up-io/k8up Signed-off-by: cimnine --- appuio/k8up/Chart.yaml | 2 +- appuio/k8up/README.gotmpl.md | 4 ++-- appuio/k8up/README.md | 12 ++++++------ appuio/k8up/rbac-kustomize/kustomization.yaml | 2 +- appuio/k8up/values.yaml | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/appuio/k8up/Chart.yaml b/appuio/k8up/Chart.yaml index d7ef5653..8399ae67 100644 --- a/appuio/k8up/Chart.yaml +++ b/appuio/k8up/Chart.yaml @@ -9,7 +9,7 @@ keywords: version: 2.0.0 appVersion: v2.0.0 sources: - - https://github.com/vshn/k8up + - https://github.com/k8up-io/k8up maintainers: - name: APPUiO Team email: info@appuio.ch diff --git a/appuio/k8up/README.gotmpl.md b/appuio/k8up/README.gotmpl.md index 6289f017..246f2374 100644 --- a/appuio/k8up/README.gotmpl.md +++ b/appuio/k8up/README.gotmpl.md @@ -1,8 +1,8 @@ ```bash # Install CRDs for K8s >= 1.16: -kubectl apply -f https://github.com/vshn/k8up/releases/download/{{ template "chart.appVersion" . }}/k8up-crd.yaml +kubectl apply -f https://github.com/k8up-io/k8up/releases/download/{{ template "chart.appVersion" . }}/k8up-crd.yaml # Install CRDs for K8s <= 1.15 (e.g. OpenShift 3.11): -kubectl apply -f https://github.com/vshn/k8up/releases/download/{{ template "chart.appVersion" . }}/k8up-crd-legacy.yaml +kubectl apply -f https://github.com/k8up-io/k8up/releases/download/{{ template "chart.appVersion" . }}/k8up-crd-legacy.yaml ``` -- [ ] [DCO](https://github.com/appuio/charts/blob/master/CONTRIBUTING.md#sign-your-work) signed +- [ ] I have run `make docs` - [ ] Variables are documented in the values.yaml using the format required by [Helm-Docs](https://github.com/norwoodj/helm-docs#valuesyaml-metadata). - [ ] Title of the PR contains starts with chart name e.g. `[chart]` diff --git a/Makefile b/Makefile index fcc826fc..897afd9a 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ MAKEFLAGS += --warn-undefined-variables MASTER_BRANCH=master SOURCE_README=README.gotmpl TARGET_README=README.md -CHARTS_DIR=charts/ +CHARTS_DIR=appuio HELM_DOCS_VERSION=v1.5.0 @@ -47,7 +47,7 @@ lint\:versions: ## Checks if chart versions have been changed @echo " If this target fails, one of the listed charts below has not its version updated!" @changed_charts=$$(git diff --dirstat=files,0 origin/master..HEAD -- appuio | cut -d '/' -f 2 | uniq) ; \ echo $$changed_charts ; echo ; \ - for dir in $$changed_charts; do git diff origin/master..HEAD -- "appuio/$${dir}/Chart.yaml" | grep -H --label=$${dir} "+version"; done + for dir in $$changed_charts; do git diff origin/master..HEAD -- "$(CHARTS_DIR)/$${dir}/Chart.yaml" | grep -H --label=$${dir} "+version"; done .PHONY: lint lint: lint\:fmt lint\:vet ## All-in-one linting and checks for uncommitted changes From d2d07804ebb490acd686c5b7e998a70cf8cd92ca Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 1 Nov 2021 14:50:16 +0100 Subject: [PATCH 8/9] Remove support for old k8s versions Signed-off-by: Chris --- appuio/k8up/README.gotmpl.md | 11 ++++-- appuio/k8up/README.md | 20 +++++++---- .../templates/prometheus/prometheusrule.yaml | 3 +- .../test/prometheus/prometheusrule_test.go | 34 ------------------- appuio/k8up/values.yaml | 4 --- 5 files changed, 23 insertions(+), 49 deletions(-) diff --git a/appuio/k8up/README.gotmpl.md b/appuio/k8up/README.gotmpl.md index 246f2374..059c2733 100644 --- a/appuio/k8up/README.gotmpl.md +++ b/appuio/k8up/README.gotmpl.md @@ -1,8 +1,5 @@ ```bash -# Install CRDs for K8s >= 1.16: kubectl apply -f https://github.com/k8up-io/k8up/releases/download/{{ template "chart.appVersion" . }}/k8up-crd.yaml -# Install CRDs for K8s <= 1.15 (e.g. OpenShift 3.11): -kubectl apply -f https://github.com/k8up-io/k8up/releases/download/{{ template "chart.appVersion" . }}/k8up-crd-legacy.yaml ``` diff --git a/appuio/k8up/templates/prometheus/prometheusrule.yaml b/appuio/k8up/templates/prometheus/prometheusrule.yaml index dd24b9f4..c4f357e5 100644 --- a/appuio/k8up/templates/prometheus/prometheusrule.yaml +++ b/appuio/k8up/templates/prometheus/prometheusrule.yaml @@ -1,5 +1,4 @@ {{- if and .Values.metrics.prometheusRule.enabled (or .Values.metrics.prometheusRule.createDefaultRules .Values.metrics.prometheusRule.additionalRules) -}} -{{- $jobNameLabel := ternary "job" "job_name" .Values.metrics.prometheusRule.legacyRules -}} apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: @@ -39,7 +38,7 @@ spec: summary: "K8up jobs are stuck in {{ "{{ $labels.namespace }}" }} for the last 24 hours." {{- range .Values.metrics.prometheusRule.jobFailedRulesFor }} - alert: K8up{{- . | title -}}Failed - expr: (sum(kube_job_status_failed) by({{ $jobNameLabel }}, namespace) * on({{ $jobNameLabel }}, namespace) group_right() kube_job_labels{label_k8up_syn_tools_type="{{- . -}}"}) > 0 + expr: (sum(kube_job_status_failed) by(job_name, namespace) * on(job_name, namespace) group_right() kube_job_labels{label_k8up_syn_tools_type="{{- . -}}"}) > 0 for: 1m labels: severity: critical diff --git a/appuio/k8up/test/prometheus/prometheusrule_test.go b/appuio/k8up/test/prometheus/prometheusrule_test.go index 33e3111c..ea16b283 100644 --- a/appuio/k8up/test/prometheus/prometheusrule_test.go +++ b/appuio/k8up/test/prometheus/prometheusrule_test.go @@ -1,7 +1,6 @@ package test import ( - "strconv" "strings" "testing" @@ -92,39 +91,6 @@ func Test_PrometheusRule_GivenEnabled_ConfigureEnabledRules(t *testing.T) { assert.Len(t, findFailedRules(renderWithRulesFor(rules)), 3) } -var legacyRuleSubjects = map[string]struct { - legacyRulesEnabled bool - expectRuleToContain string -}{ - "WhenLegacyRulesDisabled_ThenRenderNormalRule": { - true, "by(job,", - }, - "WhenLegacyRulesEnabled_ThenRenderLegacyRule": { - false, "by(job_name,", - }, -} - -func Test_PrometheusRule_GivenEnabled_LegacyRules(t *testing.T) { - for descr, tC := range legacyRuleSubjects { - t.Run(descr, func(t *testing.T) { - options := &helm.Options{ - SetValues: map[string]string{ - "metrics.prometheusRule.enabled": "true", - "metrics.prometheusRule.legacyRules": strconv.FormatBool(tC.legacyRulesEnabled), - }, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplPrometheusRule) - rule := monitoringv1.PrometheusRule{} - helm.UnmarshalK8SYaml(t, output, &rule) - - failedRules := findFailedRules(rule.Spec.Groups[0].Rules) - assert.NotEmpty(t, failedRules) - assert.Contains(t, failedRules[0].Expr.String(), tC.expectRuleToContain) - }) - } -} - func Test_PrometheusRule_GivenEnabled_WhenCreateDefaultRulesDisabled_ThenRenderNoTemplate(t *testing.T) { options := &helm.Options{ SetValues: map[string]string{ diff --git a/appuio/k8up/values.yaml b/appuio/k8up/values.yaml index f8700add..66b1c1d6 100644 --- a/appuio/k8up/values.yaml +++ b/appuio/k8up/values.yaml @@ -43,7 +43,6 @@ k8up: timezone: "" # -- Specifies whether leader election should be enabled. - # Disable this for K8s versions < 1.16 enableLeaderElection: true # -- Specifies the namespace in which K8up's `EffectiveSchedules` are stored. @@ -101,9 +100,6 @@ metrics: additionalLabels: {} # -- Whether the default rules should be installed createDefaultRules: true - # -- Create default rules for kube-state-metrics < v1.5.0 - # Needed for OpenShift 3.x - legacyRules: false # -- Create default rules for the given job types. # Valid values are "archive", "backup", "check", "prune", and "restore". jobFailedRulesFor: ["archive", "backup", "check", "prune", "restore"] From 2b4ca620cd80912d5e173a03101db4d6fdad5736 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 1 Nov 2021 15:30:03 +0100 Subject: [PATCH 9/9] Fix linting Signed-off-by: Chris --- appuio/k8up/templates/rbac.yaml | 118 ++++++++++++++++---------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/appuio/k8up/templates/rbac.yaml b/appuio/k8up/templates/rbac.yaml index 9897172c..3e889d41 100644 --- a/appuio/k8up/templates/rbac.yaml +++ b/appuio/k8up/templates/rbac.yaml @@ -92,6 +92,65 @@ rules: - patch - update - watch +- apiGroups: + - batch + resources: + - jobs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - batch + resources: + - jobs/finalizers + - jobs/status + verbs: + - get + - patch + - update +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - create + - get + - list + - update +- apiGroups: + - "" + resources: + - persistentvolumeclaims + verbs: + - get + - list + - watch +- apiGroups: + - "" + resources: + - pods + verbs: + - '*' +- apiGroups: + - "" + resources: + - pods/exec + verbs: + - '*' +- apiGroups: + - "" + resources: + - serviceaccounts + verbs: + - create + - delete + - get + - list - apiGroups: - k8up.io resources: @@ -257,65 +316,6 @@ rules: - get - patch - update -- apiGroups: - - batch - resources: - - jobs - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - batch - resources: - - jobs/finalizers - - jobs/status - verbs: - - get - - patch - - update -- apiGroups: - - coordination.k8s.io - resources: - - leases - verbs: - - create - - get - - list - - update -- apiGroups: - - "" - resources: - - persistentvolumeclaims - verbs: - - get - - list - - watch -- apiGroups: - - "" - resources: - - pods - verbs: - - '*' -- apiGroups: - - "" - resources: - - pods/exec - verbs: - - '*' -- apiGroups: - - "" - resources: - - serviceaccounts - verbs: - - create - - delete - - get - - list - apiGroups: - rbac.authorization.k8s.io resources: