代码改变世界

yapi 部署k8s

  qgbo  阅读(11)  评论(0编辑  收藏  举报
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
apiVersion: v1
kind: Namespace
metadata:
  name: yapi-ns
---
apiVersion: v1
kind: Service
metadata:
  name: mongo
  namespace: yapi-ns
  labels:
    app: mongo
spec:
  ports:
    - port: 27017
      targetPort: 27017
      name: mongo
  selector:
    app: mongo
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo
  namespace: yapi-ns
  labels:
    app: mongo
spec:
  serviceName: mongo
  selector:
    matchLabels:
      app: mongo
  template:
    metadata:
      labels:
        app: mongo
    spec:
      imagePullSecrets:
      - name: registry-pull-secret
      containers:
        - name: mongo
          image: mongo
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              cpu: 500m
              memory: 1024Mi
            requests:
              cpu: 200m
              memory: 512Mi
          env:
          - name: TZ
            value: Asia/Shanghai
          - name: MONGO_INITDB_DATABASE
            value: yapi
          - name: MONGO_INITDB_ROOT_USERNAME
            value: yapipro
          - name: MONGO_INITDB_ROOT_PASSWORD
            value: yapipro1024
          ports:
          - name: mongo
            containerPort: 27017
            protocol: TCP
          volumeMounts:
          - name: mongo-pvc
            mountPath: /data/db
  volumeClaimTemplates:
  - metadata:
      name: mongo-pvc
    spec:
      accessModes: [ "ReadWriteMany"
      storageClassName: "nfs-client" 
      resources:
        requests:
          storage: 2Gi
---
apiVersion: v1
kind: Service
metadata:
  name: yapi
  namespace: yapi-ns
  labels:
    app: yapi
spec:
  ports:
    - port: 32368
      targetPort: 3000
      name: yapi
      nodePort: 32368
  type: NodePort
  selector:
    app: yapi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: yapi
  namespace: yapi-ns
  labels:
    app: yapi
spec:
  selector:
    matchLabels:
      app: yapi
  template:
    metadata:
      labels:
        app: yapi
    spec:
      containers:
      - name: yapi-init
        ports:
        - containerPort: 3000
        image: yapipro/yapi
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh","-c", "echo $config > /yapi/config.json && node server/install.js"]
        env:
          - name: config
            value: |
              {
                "port": "3000",
                "adminAccount": "hexiaohei1024@gmail.com",
                "timeout":120000,
                "db": {
                  "servername": "mongo",
                  "DATABASE": "yapi",
                  "port": 27017,
                  "user": "yapi",
                  "pass": "yapi123456",
                  "authSource": ""
                },
                "mail": {
                  "enable": true,
                  "host": "smtp.gmail.com",
                  "port": 465,
                  "from": "*",
                  "auth": {
                    "user": "hexiaohei1024@gmail.com",
                    "pass": "xxx"
                  }
                }
              }
---             
apiVersion: apps/v1
kind: Deployment
metadata:
  name: yapi
  namespace: yapi-ns
  labels:
    app: yapi
spec:
  selector:
    matchLabels:
      app: yapi
  template:
    metadata:
      labels:
        app: yapi
    spec:
      containers:
      - name: yapi-init
        ports:
        - containerPort: 3000
        image: yapipro/yapi
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh","-c", "echo $config > /yapi/config.json && server/app.js"]
        env:
          - name: config
            value: |
              {
                "port": "3000",
                "adminAccount": "hexiaohei1024@gmail.com",
                "timeout":120000,
                "db": {
                  "servername": "mongo",
                  "DATABASE": "yapi",
                  "port": 27017,
                  "user": "yapi",
                  "pass": "yapi123456",
                  "authSource": ""
                },
                "mail": {
                  "enable": true,
                  "host": "smtp.gmail.com",
                  "port": 465,
                  "from": "*",
                  "auth": {
                    "user": "hexiaohei1024@gmail.com",
                    "pass": "xxx"
                  }
                }
              }

  docker run   --entrypoint sh  -it yapipro/yapi       #entrypint  要写在前面

docker run --entrypoint "/bin/sh"  -it --rm f42f7299bbef 

相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
历史上的今天:
2020-08-07 .Netcore 2.2 和3.1 的模板
点击右上角即可分享
微信分享提示