From 24a7dfcb0b2abbbc4beddbc6e74ea90d01d69e28 Mon Sep 17 00:00:00 2001 From: Vlad Gusev Date: Fri, 17 Jan 2025 15:48:11 +0200 Subject: [PATCH] [maria-check-constraints] Add fix-constraints chart --- .github/CODEOWNERS | 1 + common/maria-check-constraints/.helmignore | 23 +++ common/maria-check-constraints/Chart.lock | 6 + common/maria-check-constraints/Chart.yaml | 16 +++ .../ci/test-values.yaml | 5 + .../templates/_helpers.tpl | 51 +++++++ .../templates/job.yaml | 39 ++++++ common/maria-check-constraints/values.yaml | 131 ++++++++++++++++++ 8 files changed, 272 insertions(+) create mode 100644 common/maria-check-constraints/.helmignore create mode 100644 common/maria-check-constraints/Chart.lock create mode 100644 common/maria-check-constraints/Chart.yaml create mode 100644 common/maria-check-constraints/ci/test-values.yaml create mode 100644 common/maria-check-constraints/templates/_helpers.tpl create mode 100644 common/maria-check-constraints/templates/job.yaml create mode 100644 common/maria-check-constraints/values.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0a71070a808..1097c779dca 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,6 +7,7 @@ /common/inventory-updater @BerndKue /common/linkerd-support @majewsky @SuperSandro2000 @VoigtS @Nuckal777 /common/manila-provisioner @jknipper # old +/common/maria-check-constraints @s10 @businessbean @galkindmitrii /common/mariadb @galkindmitrii @stefanhipfel @Carthaca @IvoGoman @fwiesel @businessbean @occamshatchet /common/mariadb-galera @businessbean @bashar-alkhateeb /common/memcached @auhlig @businessbean @bashar-alkhateeb diff --git a/common/maria-check-constraints/.helmignore b/common/maria-check-constraints/.helmignore new file mode 100644 index 00000000000..0e8a0eb36f4 --- /dev/null +++ b/common/maria-check-constraints/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/common/maria-check-constraints/Chart.lock b/common/maria-check-constraints/Chart.lock new file mode 100644 index 00000000000..af8b59402bf --- /dev/null +++ b/common/maria-check-constraints/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: owner-info + repository: oci://keppel.eu-de-1.cloud.sap/ccloud-helm + version: 1.0.0 +digest: sha256:45a74346d8c73d1b61264fa06d5cb48d3dc38abcfbaa2900b0b918fb532b52ba +generated: "2025-01-17T16:29:18.703347+02:00" diff --git a/common/maria-check-constraints/Chart.yaml b/common/maria-check-constraints/Chart.yaml new file mode 100644 index 00000000000..7733d5018b2 --- /dev/null +++ b/common/maria-check-constraints/Chart.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v2 +name: maria-check-constraints +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 +appVersion: "202501161755" +maintainers: + - name: Birk Bohne + url: https://github.com/businessbean + - name: Vlad Gusev + url: https://github.com/s10 +dependencies: + - name: owner-info + repository: oci://keppel.eu-de-1.cloud.sap/ccloud-helm + version: 1.0.0 diff --git a/common/maria-check-constraints/ci/test-values.yaml b/common/maria-check-constraints/ci/test-values.yaml new file mode 100644 index 00000000000..68d91d3a6ba --- /dev/null +++ b/common/maria-check-constraints/ci/test-values.yaml @@ -0,0 +1,5 @@ +--- +global: + region: regionOne + tld: test.corp + registryAlternateRegion: other.docker.registry diff --git a/common/maria-check-constraints/templates/_helpers.tpl b/common/maria-check-constraints/templates/_helpers.tpl new file mode 100644 index 00000000000..409f752a352 --- /dev/null +++ b/common/maria-check-constraints/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "maria-check-constraints.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "maria-check-constraints.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "maria-check-constraints.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "maria-check-constraints.labels" -}} +helm.sh/chart: {{ include "maria-check-constraints.chart" . }} +{{ include "maria-check-constraints.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "maria-check-constraints.selectorLabels" -}} +app.kubernetes.io/name: {{ include "maria-check-constraints.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/common/maria-check-constraints/templates/job.yaml b/common/maria-check-constraints/templates/job.yaml new file mode 100644 index 00000000000..407c16dbe52 --- /dev/null +++ b/common/maria-check-constraints/templates/job.yaml @@ -0,0 +1,39 @@ +{{- range $database, $config := $.Values.databases }} +{{- $secret := $config.secret | default dict}} +{{- $secretName := coalesce $secret.name $.Values.secret.name }} +{{- $secretKey := coalesce $secret.key $.Values.secret.key }} +{{- if ne $config.enabled false }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: maria-check-constraints-{{ $config.name }} + labels: + {{- include "maria-check-constraints.labels" $ | nindent 4 }} +spec: + backoffLimit: 1 + template: + spec: + restartPolicy: Never + containers: + - name: maria-check-constraints + image: {{ required ".Values.global.registryAlternateRegion is missing" $.Values.global.registryAlternateRegion }}/{{ $.Values.image.name }}:{{ $.Values.image.tag }} + command: + - /usr/bin/maria-check-constraints + - --dry-run={{ $.Values.dryRun }} + env: + - name: DB_HOST + value: {{ $config.host }}.{{ $config.namespace }}.svc.kubernetes.{{ $.Values.global.region }}.{{ $.Values.global.tld }} + - name: DB_PORT + value: {{ $config.port | quote }} + - name: DB_NAME + value: {{ $config.schema | quote }} + - name: DB_USERNAME + value: {{ $config.username | quote }} + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ tpl $secretName . }} + key: {{ $secretKey }} +{{- end }} +{{- end }} diff --git a/common/maria-check-constraints/values.yaml b/common/maria-check-constraints/values.yaml new file mode 100644 index 00000000000..4f344de8800 --- /dev/null +++ b/common/maria-check-constraints/values.yaml @@ -0,0 +1,131 @@ +--- +owner-info: + support-group: network-api + service: maria-check-constraints + maintainers: + - Vladislav Gusev + - Birk Bohne + helm-chart-url: "https://github.com/sapcc/helm-charts/tree/master/common/maria-check-constraints" + +image: + name: 'maria-check-constraints' + tag: '202501161755' + +dryRun: true + +secret: + name: "mariadb-sync-{{ $.name }}-secrets" + key: "sourceDBPW" + +databases: + barbican: + name: barbican + namespace: 'monsoon3' + host: 'barbican-mariadb' + port: '3306' + username: 'root' + schema: 'barbican' + cinder: + name: cinder + namespace: 'monsoon3' + host: 'cinder-mariadb' + port: '3306' + username: 'root' + schema: 'cinder' + desigate: + name: designate + namespace: 'monsoon3' + host: 'designate-mariadb' + port: '3306' + username: 'root' + schema: 'designate' + glance: + name: glance + namespace: 'monsoon3' + host: 'glance-mariadb' + port: '3306' + username: 'root' + schema: 'glance' + ironic: + name: ironic + namespace: 'monsoon3' + host: 'ironic-mariadb' + port: '3306' + username: 'root' + schema: 'ironic' + keystone: + name: keystone + namespace: 'monsoon3' + host: 'keystone-mariadb' + port: '3306' + username: 'root' + schema: 'keystone' + manila: + name: manila + namespace: 'monsoon3' + host: 'manila-mariadb' + port: '3306' + username: 'root' + schema: 'manila' + neutron: + name: neutron + namespace: 'monsoon3' + host: 'neutron-mariadb' + port: '3306' + username: 'root' + schema: 'neutron' + nova: + name: nova + namespace: 'monsoon3' + host: 'nova-mariadb' + port: '3306' + username: 'root' + schema: 'nova' + nova-cell0: + name: nova-cell0 + namespace: 'monsoon3' + host: 'nova-mariadb' + port: '3306' + username: 'root' + secret: + name: 'mariadb-sync-nova-secrets' + schema: 'nova_cell0' + nova-cell-vc-b-1: + enabled: false + name: nova-cell-vc-b-1 + namespace: 'monsoon3' + host: 'nova-cell-vc-b-1-mariadb' + port: '3306' + username: 'root' + schema: 'nova_cell_vc_b_1' + nova-api: + name: nova-api + namespace: 'monsoon3' + host: 'nova-api-mariadb' + port: '3306' + username: 'root' + schema: 'nova_api' + octavia: + name: octavia + namespace: 'monsoon3' + host: 'octavia-mariadb' + port: '3306' + username: 'root' + schema: 'octavia' + placement: + name: placement + namespace: 'monsoon3' + host: 'nova-api-mariadb' + port: '3306' + username: 'root' + schema: 'placement' +# placement: +# name: placement +# namespace: 'monsoon3' +# host: 'nova-api-mariadb' +# port: '3306' +# username: 'root' +# secret: +# name: 'mariadb-placement' +# key: 'root-password' +# schema: 'placement'