一、创建命名空间:
> kubectl create ns kong
二、创建yaml文件(deploy.yaml),内容如下
##1、创建 postgres 数据库:
apiVersion: apps/v1
kind: Deployment
metadata:
name: kong-pgs
namespace: kong
spec:
replicas: 1
selector:
matchLabels:
application: kong-pgs
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
application: kong-pgs
spec:
containers:
- name: kong-pgs
env:
- name: POSTGRES_USER
value: kong
- name: POSTGRES_DB
value: kong
- name: POSTGRES_PASSWORD
value: kong
- name: PGDATA
value: "/var/lib/postgresql/data"
image: postgres:9.6
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5432
protocol: TCP
name: postgresql-port
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: pgs-storage
restartPolicy: Always
terminationGracePeriodSeconds: 30
volumes:
- name: pgs-storage
hostPath:
path: /kong/pgs