k8s 使用yapi

部署

直接上yaml,参考文档:https://github.com/fjc0k/docker-YApi

---
kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app: yapi-pod
  name: yapi-pod
spec:
  selector:
    matchLabels:
      app: yapi-pod
  template:
    metadata:
      labels:
        app: yapi-pod
    spec:
      restartPolicy: Always
      containers:
        #mongo
        - image: mongo:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 27017
          name: mongo
          env:
            - name: MONGO_INITDB_ROOT_USERNAME
              value: "yapi"
            - name: MONGO_INITDB_ROOT_PASSWORD
              value: "admin.yapi"
            - name: MONGO_INITDB_DATABASE
              value: "yapi"
          volumeMounts:
            - name: mongo-db
              mountPath: /data/db
        #yapi
        - image: jayfong/yapi:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
          name: yapi
          env:
            #管理员账号,禁止注册,默认密码: ymfe.org 登录请修改
            - name: YAPI_ADMIN_ACCOUNT
              value: "admin@qq.com"
            - name: YAPI_ADMIN_PASSWORD
              value: "admin123"
            - name: YAPI_CLOSE_REGISTER
              value: "true"
            #mongodb 配置
            - name: YAPI_DB_SERVERNAME
              value: "127.0.0.1"
            - name: YAPI_DB_PORT
              value: "27017"
            - name: YAPI_DB_DATABASE
              value: "yapi"
            - name: YAPI_DB_USER
              value: "yapi"
            - name: YAPI_DB_PASS
              value: "admin.yapi"
            - name: YAPI_DB_AUTH_SOURCE
              value: "admin"
            #mail 邮件功能
            - name: YAPI_MAIL_ENABLE
              value: "true"
            - name: YAPI_MAIL_HOST
              value: "smtp.exmail.qq.com"
            - name: YAPI_MAIL_PORT
              value: "465"
            - name: YAPI_MAIL_FROM
              value: "admin@qq.com"
            - name: YAPI_MAIL_AUTH_USER
              value: "xxx"
            - name: YAPI_MAIL_AUTH_PASS
              value: "xxx"
            #ldap 功能
            - name: YAPI_LDAP_LOGIN_ENABLE
              value: "false"
      volumes:
        - name: mongo-db
          hostPath:
            path: /data/yapi/mongo
            type: DirectoryOrCreate 
---
apiVersion: v1
kind: Service
metadata:
  name: yapi-svc
spec:
  type: NodePort
  selector:
    app: yapi-pod
  ports:
  - protocol: TCP
    port: 3000
    nodePort: 30000

如果给管理员设置账号的同时,你还开启mail 服务的话,管理员登录邮箱得填写 mail 服务发件者账号,不然启动会提示初始化管理员账号密码错误,登录时不可以使用自定义设置的密码,只能使用默认密码(ymfe.org)

执行

kubectl  apply  -f yapi.yaml

检查

k8s 使用yapi
k8s 使用yapi

浏览器访问:http:///localhost:30000

上一篇:python zmail 收发谷歌邮箱邮件采坑


下一篇:SpringBoot学习笔记——异步、定时、邮件任务