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
 

  

  

  

posted @ 2023-02-13 10:44  百衲本  阅读(194)  评论(0编辑  收藏  举报
cnblogs_post_body { color: black; font: 0.875em/1.5em "微软雅黑" , "PTSans" , "Arial" ,sans-serif; font-size: 15px; } cnblogs_post_body h1 { text-align:center; background: #333366; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 23px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h2 { text-align:center; background: #006699; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 20px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h3 { background: #2B6695; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 18px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } 回到顶部 博客侧边栏 回到顶部 页首代码 回到顶部 页脚代码