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": "[email protected]", "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": "[email protected]", "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": "[email protected]", "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": "[email protected]", "pass": "xxx" } } }
docker run --entrypint sh -it yapipro/yapi entrypint 要写在前面
标签:mongo,yapi,部署,app,metadata,k8s,spec,name From: https://www.cnblogs.com/qgbo/p/18347245