Skip to content

Commit

Permalink
feat(provisioners): added default mysql provisioner
Browse files Browse the repository at this point in the history
  • Loading branch information
astromechza committed Jun 27, 2024
1 parent d097cbc commit 48d5e2b
Showing 1 changed file with 131 additions and 0 deletions.
131 changes: 131 additions & 0 deletions internal/provisioners/default/zz-default.provisioners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,134 @@
ports:
- port: 6379
targetPort: 6379
- uri: template://default-provisioners/mysql
type: mysql
init: |
randomDatabase: db-{{ randAlpha 8 }}
randomUsername: user-{{ randAlpha 8 }}
randomPassword: {{ randAlphaNum 16 | quote }}
state: |
service: mysql-{{ .SourceWorkload }}-{{ substr 0 8 .Guid | lower }}
database: {{ dig "database" .Init.randomDatabase .State | quote }}
username: {{ dig "username" .Init.randomUsername .State | quote }}
password: {{ dig "password" .Init.randomPassword .State | quote }}
outputs: |
host: {{ .State.service }}
port: 3306
name: {{ .State.database }}
database: {{ .State.database }}
username: {{ .State.username }}
password: {{ encodeSecretRef .State.service "MYSQL_PASSWORD" }}
manifests: |
- apiVersion: v1
kind: Secret
metadata:
name: {{ .State.service }}
annotations:
k8s.score.dev/source-workload: {{ .SourceWorkload }}
k8s.score.dev/resource-uid: {{ .Uid }}
k8s.score.dev/resource-guid: {{ .Guid }}
labels:
app.kubernetes.io/managed-by: score-k8s
app.kubernetes.io/name: {{ .State.service }}
app.kubernetes.io/instance: {{ .State.service }}
data:
MYSQL_PASSWORD: {{ .State.password | b64enc }}
MYSQL_ROOT_PASSWORD: {{ .State.password | b64enc }}
- apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .State.service }}
annotations:
k8s.score.dev/source-workload: {{ .SourceWorkload }}
k8s.score.dev/resource-uid: {{ .Uid }}
k8s.score.dev/resource-guid: {{ .Guid }}
labels:
app.kubernetes.io/managed-by: score-k8s
app.kubernetes.io/name: {{ .State.service }}
app.kubernetes.io/instance: {{ .State.service }}
spec:
replicas: 1
serviceName: {{ .State.service }}
selector:
matchLabels:
app.kubernetes.io/instance: {{ .State.service }}
template:
metadata:
labels:
app.kubernetes.io/managed-by: score-k8s
app.kubernetes.io/name: {{ .State.service }}
app.kubernetes.io/instance: {{ .State.service }}
annotations:
k8s.score.dev/source-workload: {{ .SourceWorkload }}
k8s.score.dev/resource-uid: {{ .Uid }}
k8s.score.dev/resource-guid: {{ .Guid }}
spec:
containers:
- name: mysql-db
image: mysql:8.0
ports:
- name: mysql
containerPort: 3306
env:
- name: MYSQL_USER
value: {{ .State.username | quote }}
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .State.service }}
key: MYSQL_PASSWORD
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .State.service }}
key: MYSQL_ROOT_PASSWORD
- name: MYSQL_DATABASE
value: {{ .State.database | quote }}
volumeMounts:
- name: data
mountPath: /var/lib/mysql
readinessProbe:
exec:
command:
- mysqladmin
- ping
- -h
- localhost
periodSeconds: 3
volumeClaimTemplates:
- metadata:
name: data
annotations:
k8s.score.dev/source-workload: {{ .SourceWorkload }}
k8s.score.dev/resource-uid: {{ .Uid }}
k8s.score.dev/resource-guid: {{ .Guid }}
labels:
app.kubernetes.io/managed-by: score-k8s
app.kubernetes.io/name: {{ .State.service }}
app.kubernetes.io/instance: {{ .State.service }}
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
- apiVersion: v1
kind: Service
metadata:
name: {{ .State.service }}
annotations:
k8s.score.dev/source-workload: {{ .SourceWorkload }}
k8s.score.dev/resource-uid: {{ .Uid }}
k8s.score.dev/resource-guid: {{ .Guid }}
labels:
app.kubernetes.io/managed-by: score-k8s
app.kubernetes.io/name: {{ .State.service }}
app.kubernetes.io/instance: {{ .State.service }}
spec:
selector:
app.kubernetes.io/instance: {{ .State.service }}
type: ClusterIP
ports:
- port: 3306
targetPort: 3306

0 comments on commit 48d5e2b

Please sign in to comment.