yapi项目
代码语言:javascript复制https://github.com/YMFE/yapi/tags
镜像
代码语言:javascript复制https://hub.docker.com/r/jayfong/yapi
创建资源清单
vim yapi.yaml
代码语言:javascript复制apiVersion: v1
kind: Namespace
metadata:
name: yapi
---
apiVersion: v1
kind: Service
metadata:
name: mongo
namespace: yapi
labels:
app: mongo
spec:
ports:
- port:
targetPort:
name: mongo
selector:
app: mongo
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
namespace: yapi
labels:
app: mongo
spec:
serviceName: mongo
replicas:
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
imagePullSecrets:
- name: registry-pull-secret
containers:
- name: mongo
image: harbor.myit.icu/yapi/mongo:latest # mongo:latest
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 500m
memory: 1024Mi
requests:
cpu: 200m
memory: 512Mi
env:
- name: TZ
value: Asia/Shanghai
ports:
- name: mongo
containerPort:
protocol: TCP
volumeMounts:
- name: mongo-pvc
mountPath: /data/db
volumeClaimTemplates:
- metadata:
name: mongo-pvc
spec:
accessModes: [ "ReadWriteMany" ] # 有的为RWO
storageClassName: nfs-storage # sc名字
resources:
requests:
storage: 100Gi
---
apiVersion: v1
kind: Service
metadata:
name: yapi
namespace: yapi
labels:
app: yapi
spec:
ports:
- port:
targetPort:
name: yapi
# nodePort: 32368
# type: NodePort
type: ClusterIP
selector:
app: yapi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: yapi
namespace: yapi
labels:
app: yapi
spec:
replicas:
selector:
matchLabels:
app: yapi
strategy:
rollingUpdate:
maxSurge:
maxUnavailable:
template:
metadata:
labels:
app: yapi
spec:
containers:
- name: yapi
image: harbor.myit.icu/yapi/yapi:latest
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 500m
memory: 1024Mi
requests:
cpu: 200m
memory: 512Mi
env:
- name: TZ
value: Asia/Shanghai
- name: VERSION
value: 1.8.0
- name: LOG_PATH
value: /tmp/yapi.log
- name: HOME
value: /home
- name: PORT
value: "32368"
- name: ADMIN_EMAIL
value: deanmr@qq.com
- name: DB_SERVER
value: mongo
- name: DB_NAME
value: yapi
- name: DB_PORT
value: "27017"
ports:
- name: yapi
containerPort:
protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: yapi
namespace: yapi
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: '3600'
nginx.ingress.kubernetes.io/proxy-send-timeout: '3600'
nginx.ingress.kubernetes.io/proxy-body-size: 1g
spec:
# tls:
# - hosts:
# - 'yapi.myit.icu'
# secretName: local
rules:
- host: yapi.myit.icu
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: yapi
port:
name: yapi
查看资源情况
代码语言:javascript复制[15:27:39root@k8s-master1 ~]#kubectl get all -n yapi
NAME READY STATUS RESTARTS AGE
pod/mongo-0 1/1 Running 0 21m
pod/yapi-5dd5ddf4c9-t9jtl 1/1 Running 0 21m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/mongo ClusterIP 10.108.24.188 <none> 27017/TCP 21m
service/yapi ClusterIP 10.107.43.72 <none> 32368/TCP 21m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/yapi 1/1 1 1 21m
NAME DESIRED CURRENT READY AGE
replicaset.apps/yapi-5dd5ddf4c9 1 1 1 21m
NAME READY AGE
statefulset.apps/mongo 1/1 21m
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/pvc-ffc0edbd-e400-42bf-8a90-6e7e8275f948 100Gi RWX Delete Bound yapi/mongo-pvc-mongo-0 nfs 22m
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/mongo-pvc-mongo-0 Bound pvc-ffc0edbd-e400-42bf-8a90-6e7e8275f948 100Gi RWX nfs 22m
查看yapi的Pod的日志
代码语言:javascript复制依赖库安装完成,正在初始化数据库mongodb...
> yapi-vendor@1.8.0 install-server /home/vendors/vendors
> node server/install.js
log: mongodb load success...
初始化管理员账号成功,账号名:"deanmr@qq.com",密码:"ymfe.org"
部署成功,请切换到部署目录,输入: "node vendors/server/app.js" 指令启动服务器, 然后在浏览器打开 http://127.0.0.1:32368 访问
log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
log: 服务已启动,请打开下面链接访问:
http://127.0.0.1:32368/
log: mongodb load success...
查看账户密码
代码语言:javascript复制[15:18:22root@k8s-master1 ~]#kubectl logs -n yapi yapi-5dd5ddf4c9-t9jtl | grep deanmr
初始化管理员账号成功,账号名:"deanmr@qq.com",密码:"ymfe.org"