k8s安装YAPI
一、前置条件
提前安装MongoDB
二、YAML文件
namespace 自行替换
Deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: yapi
namespace: ops-share
labels:
app: yapi
release: yapi
spec:
selector:
matchLabels:
app: yapi
release: yapi
template:
metadata:
labels:
app: yapi
release: yapi
spec:
containers:
- name: yapi
image: registry.cn-hangzhou.aliyuncs.com/mq_basic/yapi:1.9.5
command: ["node","server/app.js"]
ports:
- containerPort: 3000
name: yapi
protocol: TCP
volumeMounts:
- name: config
mountPath: /yapi/config.json
subPath: config.json
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: 1000m
memory: 1024Mi
volumes:
- name: config
configMap:
name: yapi-config
svc.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: yapi-svc
name: yapi-svc
namespace: ops-share
spec:
ports:
- name: http-3000
port: 3000
protocol: TCP
targetPort: 3000
selector:
app: yapi
configMap.yaml(即config.json,YAPI配置文件,根据实际情况填写)
apiVersion: v1
data:
config.json: |-
{
"closeRegister":true,
"port": "3000",
"adminAccount": "example@xxx.com",
"db": {
"servername": "10.0.0.112",
"DATABASE": "yapi",
"port": "27017",
"user": "yapi",
"pass": "yapi@123"
},
"mail": {
"enable": false,
"host": "smtp.163.com",
"port": 465,
"from": "***@163.com",
"auth": {
"user": "***@163.com",
"pass": "*****"
}
}
}
kind: ConfigMap
metadata:
name: yapi-config
namespace: ops-share
ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: yapi-inktech-ltd
namespace: ops-share
spec:
rules:
- host: yapi.inktech.ltd
http:
paths:
- backend:
service:
name: yapi-svc
port:
number: 3000
path: /
pathType: ImplementationSpecific
"一劳永逸" 的话,有是有的,而 "一劳永逸" 的事却极少