This commit is contained in:
2024-02-20 17:15:27 +08:00
committed by huty
parent 6706e1a633
commit 34158042ad
1529 changed files with 177765 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: todo-list-config
labels:
kiamol: ch20
data:
config.json: |-
{
"Database" : {
"Provider" : "MySql"
},
"MessageQueue": {
"Url": "nats://todo-list-queue:4222"
}
}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Secret
metadata:
name: todo-list-secret
labels:
kiamol: ch20
type: Opaque
stringData:
secrets.json: |-
{
"ConnectionStrings": {
"ToDoDb": "server=todo-db-mysql-master;database=todo;user=root;password=kiamol-2*2*",
"ToDoDb-ReadOnly": "server=todo-db-mysql-replicas;database=todo;user=root;password=kiamol-2*2*"
}
}

View File

@@ -0,0 +1,23 @@
apiVersion: v1
kind: Secret
metadata:
name: todo-db-secret
labels:
kiamol: ch20
type: Opaque
stringData:
ROOT_PASSWORD: "kiamol-2*2*"
---
apiVersion: mysql.presslabs.org/v1alpha1
kind: MysqlCluster
metadata:
name: todo-db
spec:
mysqlVersion: "5.7.24"
replicas: 2
secretName: todo-db-secret
podSpec:
resources:
limits:
memory: 200Mi
cpu: 200m

View File

@@ -0,0 +1,7 @@
apiVersion: nats.io/v1alpha2
kind: NatsCluster
metadata:
name: todo-list-queue
spec:
size: 3
version: "1.3.0"

View File

@@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: todo-save-handler
labels:
kiamol: ch20
spec:
selector:
matchLabels:
app: todo-list
component: save-handler
template:
metadata:
labels:
app: todo-list
component: save-handler
spec:
containers:
- name: web
image: kiamol/ch20-todo-save-handler
volumeMounts:
- name: config
mountPath: "/app/config"
readOnly: true
- name: secret
mountPath: "/app/secrets"
readOnly: true
volumes:
- name: config
configMap:
name: todo-list-config
items:
- key: config.json
path: config.json
- name: secret
secret:
secretName: todo-list-secret
defaultMode: 0400
items:
- key: secrets.json
path: secrets.json

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: todo-web
labels:
kiamol: ch20
spec:
ports:
- port: 8020
targetPort: 80
selector:
app: todo-list
component: web
type: LoadBalancer

View File

@@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: todo-web
labels:
kiamol: ch20
spec:
selector:
matchLabels:
app: todo-list
component: web
template:
metadata:
labels:
app: todo-list
component: web
spec:
containers:
- name: web
image: kiamol/ch20-todo-list
volumeMounts:
- name: config
mountPath: "/app/config"
readOnly: true
- name: secret
mountPath: "/app/secrets"
readOnly: true
volumes:
- name: config
configMap:
name: todo-list-config
items:
- key: config.json
path: config.json
- name: secret
secret:
secretName: todo-list-secret
defaultMode: 0400
items:
- key: secrets.json
path: secrets.json