新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
@@ -0,0 +1,40 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-db
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-db
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-db
|
||||
spec:
|
||||
containers:
|
||||
- name: db
|
||||
image: postgres:11.6-alpine
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD_FILE
|
||||
value: /secrets/postgres_password
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
volumeMounts:
|
||||
- name: secret
|
||||
mountPath: "/secrets"
|
||||
- name: data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
volumes:
|
||||
- name: secret
|
||||
secret:
|
||||
secretName: todo-db-secret
|
||||
defaultMode: 0400
|
||||
items:
|
||||
- key: POSTGRES_PASSWORD
|
||||
path: postgres_password
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: todo-db-pvc
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: todo-db-pvc
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 100Mi
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: todo-db-secret
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
type: Opaque
|
||||
stringData:
|
||||
POSTGRES_PASSWORD: "kiamol-2*2*"
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: todo-db
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
selector:
|
||||
app: todo-db
|
||||
@@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: todo-list-config
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
data:
|
||||
config.json: |-
|
||||
{
|
||||
"Database" : {
|
||||
"Provider" : "Postgres"
|
||||
},
|
||||
"MessageQueue": {
|
||||
"Url": "nats://message-queue:4222"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: todo-list-secret
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
type: Opaque
|
||||
stringData:
|
||||
secrets.json: |-
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"ToDoDb": "Server=todo-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;",
|
||||
"ToDoDb-ReadOnly": "Server=todo-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nats-config
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
data:
|
||||
nats.conf: |
|
||||
pid_file: "/var/run/nats/nats.pid"
|
||||
http: 8222
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: message-queue
|
||||
namespace: todo
|
||||
labels:
|
||||
app: nats
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
selector:
|
||||
app: nats
|
||||
clusterIP: None
|
||||
ports:
|
||||
- name: client
|
||||
port: 4222
|
||||
- name: cluster
|
||||
port: 6222
|
||||
- name: monitor
|
||||
port: 8222
|
||||
- name: metrics
|
||||
port: 7777
|
||||
- name: leafnodes
|
||||
port: 7422
|
||||
- name: gateways
|
||||
port: 7522
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: nats
|
||||
namespace: todo
|
||||
labels:
|
||||
app: nats
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nats
|
||||
replicas: 1
|
||||
serviceName: "nats"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nats
|
||||
spec:
|
||||
# Common volumes for the containers
|
||||
volumes:
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: nats-config
|
||||
- name: pid
|
||||
emptyDir: {}
|
||||
|
||||
# Required to be able to HUP signal and apply config reload
|
||||
# to the server without restarting the pod.
|
||||
shareProcessNamespace: true
|
||||
|
||||
#################
|
||||
# #
|
||||
# NATS Server #
|
||||
# #
|
||||
#################
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: nats
|
||||
image: nats:2.1.0-alpine3.10
|
||||
ports:
|
||||
- containerPort: 4222
|
||||
name: client
|
||||
hostPort: 4222
|
||||
- containerPort: 7422
|
||||
name: leafnodes
|
||||
hostPort: 7422
|
||||
- containerPort: 6222
|
||||
name: cluster
|
||||
- containerPort: 8222
|
||||
name: monitor
|
||||
- containerPort: 7777
|
||||
name: metrics
|
||||
command:
|
||||
- "nats-server"
|
||||
- "--config"
|
||||
- "/etc/nats-config/nats.conf"
|
||||
|
||||
# Required to be able to define an environment variable
|
||||
# that refers to other environment variables. This env var
|
||||
# is later used as part of the configuration file.
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: CLUSTER_ADVERTISE
|
||||
value: $(POD_NAME).nats.$(POD_NAMESPACE).svc
|
||||
volumeMounts:
|
||||
- name: config-volume
|
||||
mountPath: /etc/nats-config
|
||||
- name: pid
|
||||
mountPath: /var/run/nats
|
||||
|
||||
# Liveness/Readiness probes against the monitoring
|
||||
#
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8222
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8222
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
|
||||
# Gracefully stop NATS Server on pod deletion or image upgrade.
|
||||
#
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
# Using the alpine based NATS image, we add an extra sleep that is
|
||||
# the same amount as the terminationGracePeriodSeconds to allow
|
||||
# the NATS Server to gracefully terminate the client connections.
|
||||
#
|
||||
command: ["/bin/sh", "-c", "/nats-server -sl=ldm=/var/run/nats/nats.pid && /bin/sleep 60"]
|
||||
@@ -0,0 +1,45 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-save-handler
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
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
|
||||
env:
|
||||
- name: Events__events.todo.itemsaved__Publish
|
||||
value: "true"
|
||||
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
|
||||
@@ -0,0 +1,18 @@
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: todo-web
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: contour-external
|
||||
spec:
|
||||
rules:
|
||||
- host: todo.kiamol.local
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
backend:
|
||||
serviceName: todo-web
|
||||
servicePort: 80
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: todo-web
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: todo-list
|
||||
component: web
|
||||
@@ -0,0 +1,42 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-web
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
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
|
||||
Reference in New Issue
Block a user