Skip to content

Commit

Permalink
Merge branch 'main' into update-readme
Browse files Browse the repository at this point in the history
Signed-off-by: Susa Tünker <[email protected]>
  • Loading branch information
sujaya-sys authored Jul 1, 2024
2 parents 803a594 + 725f628 commit 5aa3a49
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ Generally, users will want to copy in the provisioners files that work with thei

For details of how the standard "template" provisioner works, see the `template://example-provisioners/example-provisioner` provisioner [here](internal/provisioners/default/zz-default.provisioners.yaml). For details of how the standard "cmd" provisioner works, see the `cmd://bash#example-provisioner` provisioner [here](internal/provisioners/default/zz-default.provisioners.yaml).

## Provisioner support

`score-k8s` comes with out-of-the-box support for:

| Type | Class | Params | Output |
| ------------- | ------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| volume | default | (none) | `source` |
| redis | default | (none) | `host`, `port`, `username`, `password` |
| postgres | default | (none) | `host`, `port`, `name` (aka `database`), `username`, `password` |
| mysql | default | (none) | `host`, `port`, `name` (aka `database`), `username`, `password` |
| dns | default | (none) | `host` |
| route | default | `host`, `path`, `port` | |

Users are encouraged to write their own custom provisioners to support new resource types or to modify the implementations above.

## Commands

### Init
Expand Down
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 5aa3a49

Please sign in to comment.