-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from mintel/INFRA-30570-mariadb-extrausers
[INFRA-30570] add extraUsers for mariadb
- Loading branch information
Showing
7 changed files
with
344 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
charts/standard-application-stack/templates/mariadb-py-dba.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{{- if (and .Values.mariadb .Values.mariadb.enabled) }} | ||
{{- if (and .Values.mariadb.extraUsers .Values.mariadb.extraUsers.enabled) }} | ||
--- | ||
{{- $data := dict "Release" $.Release "Chart" $.Chart "Values" $.Values "component" .name }} | ||
apiVersion: {{ include "common.capabilities.job.apiVersion" $ }} | ||
kind: Job | ||
metadata: | ||
name: {{ include "mintel_common.fullname" $data }} | ||
labels: {{ include "mintel_common.labels" $data | nindent 4 }} | ||
annotations: | ||
{{- include "mintel_common.commonAnnotations" $ | nindent 4 }} | ||
{{ if .argo }} | ||
{{ include "mintel_common.argoAnnotations" .argo | nindent 4 }} | ||
{{ end }} | ||
helm.sh/chart: {{ include "mintel_common.chart" $ }} | ||
namespace: {{ $.Release.Namespace }} | ||
spec: | ||
ttlSecondsAfterFinished: 600 | ||
template: | ||
spec: | ||
{{- include "mintel_common.imagePullSecrets" $ | nindent 6 }} | ||
securityContext: | ||
runAsUser: 1000 | ||
runAsNonRoot: true | ||
serviceAccountName: {{ $.Values.serviceAccount.name | default (include "mintel_common.fullname" $)}} | ||
restartPolicy: "Never" | ||
containers: | ||
- name: main | ||
image: 551844124467.dkr.ecr.us-east-2.amazonaws.com/gitlab/mintel/satoshi/tools/py-dba:v0.1.0 | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: 'CONFIG_FILE' | ||
value: '/etc/config/py-dba-config' | ||
- name: DB_ENGINE | ||
value: mariadb | ||
- name: USER_SECRET_PREFIX | ||
value: {{ (printf "%s/%s/mariadb" (.Release.Namespace) (include "mintel_common.fullname" .)) }} | ||
envFrom: | ||
- secretRef: | ||
name: {{ (printf "%s-mariadb" (include "mintel_common.fullname" .)) }} | ||
resources: | ||
limits: | ||
cpu: 200m | ||
memory: 64Mi | ||
requests: | ||
cpu: 100m | ||
memory: 32Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /etc/config | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: {{ (printf "%s-py-dba-config" (include "mintel_common.fullname" .)) }} | ||
--- | ||
{{- $data := dict "Release" $.Release "Chart" $.Chart "Values" $.Values "component" .name }} | ||
apiVersion: {{ include "common.capabilities.configmap.apiVersion" . }} | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ (printf "%s-py-dba-config" (include "mintel_common.fullname" .)) }} | ||
labels: {{ include "mintel_common.labels" $data | nindent 4 }} | ||
annotations: | ||
{{ include "mintel_common.commonAnnotations" $data | nindent 4 }} | ||
{{ if .argo }} | ||
{{ include "mintel_common.argoAnnotations" .argo | nindent 4 }} | ||
{{ end }} | ||
namespace: {{ .Release.Namespace }} | ||
data: | ||
{{- with .Values.mariadb.extraUsers.users }} | ||
py-dba-config: | {{ (printf "users:\n%s" (toYaml .)) | nindent 10 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
176 changes: 176 additions & 0 deletions
176
charts/standard-application-stack/tests/__snapshot__/mariadb_py_dba_test.yaml.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
adds correct config to configmap: | ||
1: | | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
annotations: | ||
app.mintel.com/placeholder: placeholder | ||
helm.sh/chart: standard-application-stack-5.10.0 | ||
labels: | ||
app.kubernetes.io/component: app | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: test-app | ||
app.mintel.com/env: local | ||
app.mintel.com/region: local | ||
name: test-app | ||
name: test-app | ||
namespace: test-namespace | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- env: | ||
- name: CONFIG_FILE | ||
value: /etc/config/py-dba-config | ||
- name: DB_ENGINE | ||
value: mariadb | ||
- name: USER_SECRET_PREFIX | ||
value: test-namespace/test-app/mariadb | ||
envFrom: | ||
- secretRef: | ||
name: test-app-mariadb | ||
image: 551844124467.dkr.ecr.us-east-2.amazonaws.com/gitlab/mintel/satoshi/tools/py-dba:v0.1.0 | ||
imagePullPolicy: IfNotPresent | ||
name: main | ||
resources: | ||
limits: | ||
cpu: 200m | ||
memory: 64Mi | ||
requests: | ||
cpu: 100m | ||
memory: 32Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
volumeMounts: | ||
- mountPath: /etc/config | ||
name: config-volume | ||
imagePullSecrets: | ||
- name: image-pull-gitlab | ||
- name: image-pull-docker-hub | ||
restartPolicy: Never | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
serviceAccountName: test-app | ||
volumes: | ||
- configMap: | ||
name: test-app-py-dba-config | ||
name: config-volume | ||
ttlSecondsAfterFinished: 600 | ||
2: | | ||
apiVersion: v1 | ||
data: | ||
py-dba-config: | | ||
users: | ||
- database: test_db | ||
tables: | ||
- permissions: | ||
- ALL | ||
table: table1 | ||
username: user1 | ||
kind: ConfigMap | ||
metadata: | ||
annotations: | ||
app.mintel.com/placeholder: placeholder | ||
labels: | ||
app.kubernetes.io/component: app | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: test-app | ||
app.mintel.com/env: local | ||
app.mintel.com/region: local | ||
name: test-app | ||
name: test-app-py-dba-config | ||
namespace: test-namespace | ||
extraUsers adds job and configmap: | ||
1: | | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
annotations: | ||
app.mintel.com/placeholder: placeholder | ||
helm.sh/chart: standard-application-stack-5.10.0 | ||
labels: | ||
app.kubernetes.io/component: app | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: test-app | ||
app.mintel.com/env: local | ||
app.mintel.com/region: local | ||
name: test-app | ||
name: test-app | ||
namespace: test-namespace | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- env: | ||
- name: CONFIG_FILE | ||
value: /etc/config/py-dba-config | ||
- name: DB_ENGINE | ||
value: mariadb | ||
- name: USER_SECRET_PREFIX | ||
value: test-namespace/test-app/mariadb | ||
envFrom: | ||
- secretRef: | ||
name: test-app-mariadb | ||
image: 551844124467.dkr.ecr.us-east-2.amazonaws.com/gitlab/mintel/satoshi/tools/py-dba:v0.1.0 | ||
imagePullPolicy: IfNotPresent | ||
name: main | ||
resources: | ||
limits: | ||
cpu: 200m | ||
memory: 64Mi | ||
requests: | ||
cpu: 100m | ||
memory: 32Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
volumeMounts: | ||
- mountPath: /etc/config | ||
name: config-volume | ||
imagePullSecrets: | ||
- name: image-pull-gitlab | ||
- name: image-pull-docker-hub | ||
restartPolicy: Never | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
serviceAccountName: test-app | ||
volumes: | ||
- configMap: | ||
name: test-app-py-dba-config | ||
name: config-volume | ||
ttlSecondsAfterFinished: 600 | ||
2: | | ||
apiVersion: v1 | ||
data: | ||
py-dba-config: | | ||
users: | ||
- database: test_db | ||
tables: | ||
- permissions: | ||
- ALL | ||
table: table1 | ||
username: user1 | ||
kind: ConfigMap | ||
metadata: | ||
annotations: | ||
app.mintel.com/placeholder: placeholder | ||
labels: | ||
app.kubernetes.io/component: app | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: test-app | ||
app.mintel.com/env: local | ||
app.mintel.com/region: local | ||
name: test-app | ||
name: test-app-py-dba-config | ||
namespace: test-namespace |
56 changes: 56 additions & 0 deletions
56
charts/standard-application-stack/tests/mariadb_py_dba_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
suite: Test MariaDB py-dba configs | ||
templates: | ||
- mariadb-py-dba.yaml | ||
release: | ||
namespace: test-namespace | ||
tests: | ||
- it: extraUsers adds job and configmap | ||
set: | ||
global.name: test-app | ||
mariadb: | ||
enabled: true | ||
extraUsers: | ||
enabled: true | ||
users: | ||
- username: user1 | ||
database: test_db | ||
tables: | ||
- table: table1 | ||
permissions: ["ALL"] | ||
|
||
asserts: | ||
- matchSnapshot: {} # Check for regressions and unexpected changes. | ||
- isKind: | ||
of: ConfigMap | ||
documentIndex: 1 | ||
- isKind: | ||
of: Job | ||
documentIndex: 0 | ||
|
||
- it: adds correct config to configmap | ||
set: | ||
global.name: test-app | ||
mariadb: | ||
enabled: true | ||
extraUsers: | ||
enabled: true | ||
users: | ||
- username: user1 | ||
database: test_db | ||
tables: | ||
- table: table1 | ||
permissions: ["ALL"] | ||
|
||
asserts: | ||
- matchSnapshot: {} # Check for regressions and unexpected changes. | ||
- equal: | ||
path: data.py-dba-config | ||
value: | | ||
users: | ||
- database: test_db | ||
tables: | ||
- permissions: | ||
- ALL | ||
table: table1 | ||
username: user1 | ||
documentIndex: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters