新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
58
learn/learn-kubernetes-master/kiamol/ch14/todo-list/db.yaml
Normal file
58
learn/learn-kubernetes-master/kiamol/ch14/todo-list/db.yaml
Normal file
@@ -0,0 +1,58 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: todo-db
|
||||
namespace: kiamol-ch14-test
|
||||
spec:
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
selector:
|
||||
app: todo-db
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: todo-db-secret
|
||||
namespace: kiamol-ch14-test
|
||||
type: Opaque
|
||||
stringData:
|
||||
POSTGRES_PASSWORD: "kiamol-2*2*"
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-db
|
||||
namespace: kiamol-ch14-test
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-db
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-db
|
||||
annotations:
|
||||
prometheus.io/scrape: "false"
|
||||
spec:
|
||||
containers:
|
||||
- name: db
|
||||
image: postgres:11.6-alpine
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD_FILE
|
||||
value: /secrets/postgres_password
|
||||
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
|
||||
emptyDir: {}
|
||||
@@ -0,0 +1,77 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: todo-proxy
|
||||
namespace: kiamol-ch14-test
|
||||
spec:
|
||||
ports:
|
||||
- port: 8015
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: todo-proxy
|
||||
type: LoadBalancer
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: todo-proxy-config
|
||||
namespace: kiamol-ch14-test
|
||||
data:
|
||||
nginx.conf: |-
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
location / {
|
||||
proxy_pass http://todo-web;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /stub_status {
|
||||
stub_status;
|
||||
}
|
||||
}
|
||||
}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-proxy
|
||||
namespace: kiamol-ch14-test
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-proxy
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-proxy
|
||||
annotations:
|
||||
prometheus.io/scrape: "false"
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx:1.17-alpine
|
||||
name: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
name: http
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: "/etc/nginx/"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: todo-proxy-config
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-db
|
||||
namespace: kiamol-ch14-test
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-db
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-db
|
||||
annotations:
|
||||
prometheus.io/port: "9187"
|
||||
spec:
|
||||
containers:
|
||||
- name: db
|
||||
image: postgres:11.6-alpine
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD_FILE
|
||||
value: /secrets/postgres_password
|
||||
volumeMounts:
|
||||
- name: secret
|
||||
mountPath: "/secrets"
|
||||
- name: data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: exporter
|
||||
image: wrouesnel/postgres_exporter:v0.8.0
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9187
|
||||
env:
|
||||
- name: DATA_SOURCE_URI
|
||||
value: localhost?sslmode=disable
|
||||
- name: DATA_SOURCE_USER
|
||||
value: postgres
|
||||
- name: DATA_SOURCE_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: POSTGRES_PASSWORD
|
||||
name: todo-db-secret
|
||||
volumeMounts:
|
||||
- name: secret
|
||||
mountPath: "/secrets"
|
||||
volumes:
|
||||
- name: secret
|
||||
secret:
|
||||
secretName: todo-db-secret
|
||||
defaultMode: 0400
|
||||
items:
|
||||
- key: POSTGRES_PASSWORD
|
||||
path: postgres_password
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
@@ -0,0 +1,38 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-proxy
|
||||
namespace: kiamol-ch14-test
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-proxy
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-proxy
|
||||
annotations:
|
||||
prometheus.io/port: "9113"
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx:1.17-alpine
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: "/etc/nginx/"
|
||||
readOnly: true
|
||||
- name: exporter
|
||||
image: nginx/nginx-prometheus-exporter:0.8.0
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9113
|
||||
args:
|
||||
- -nginx.scrape-uri=http://localhost/stub_status
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: todo-proxy-config
|
||||
|
||||
83
learn/learn-kubernetes-master/kiamol/ch14/todo-list/web.yaml
Normal file
83
learn/learn-kubernetes-master/kiamol/ch14/todo-list/web.yaml
Normal file
@@ -0,0 +1,83 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: todo-web
|
||||
namespace: kiamol-ch14-test
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: todo-web
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: todo-web-config
|
||||
namespace: kiamol-ch14-test
|
||||
data:
|
||||
config.json: |-
|
||||
{
|
||||
"ConfigController": {
|
||||
"Enabled" : true
|
||||
},
|
||||
"Database" : {
|
||||
"Provider" : "Postgres"
|
||||
},
|
||||
"Metrics" : {
|
||||
"Enabled" : true
|
||||
}
|
||||
}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: todo-web-secret
|
||||
namespace: kiamol-ch14-test
|
||||
type: Opaque
|
||||
stringData:
|
||||
secrets.json: |-
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"ToDoDb": "Server=todo-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;"
|
||||
}
|
||||
}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-web
|
||||
namespace: kiamol-ch14-test
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-web
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch04-todo-list
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: "/app/config"
|
||||
readOnly: true
|
||||
- name: secret
|
||||
mountPath: "/app/secrets"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: todo-web-config
|
||||
items:
|
||||
- key: config.json
|
||||
path: config.json
|
||||
- name: secret
|
||||
secret:
|
||||
secretName: todo-web-secret
|
||||
defaultMode: 0400
|
||||
items:
|
||||
- key: secrets.json
|
||||
path: secrets.json
|
||||
Reference in New Issue
Block a user