1.K8S部署的yaml文件

通过如下的yaml文件进行Excalidraw的部署,注意需要将excalidraw.wanna1314y.top修改成自己的域名地址。

apiVersion: v1
kind: Namespace
metadata:
  name: excalidraw
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redis-data-pvc
  namespace: excalidraw
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
  namespace: excalidraw
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - name: redis
        image: redis:alpine
        ports:
        - containerPort: 6379
        volumeMounts:
        - name: redis-data
          mountPath: /data
        livenessProbe:
          exec:
            command: ["redis-cli", "ping"]
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          exec:
            command: ["redis-cli", "ping"]
          initialDelaySeconds: 5
          periodSeconds: 5
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 500m
            memory: 1024Mi
      volumes:
      - name: redis-data
        persistentVolumeClaim:
          claimName: redis-data-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: redis-service
  namespace: excalidraw
spec:
  selector:
    app: redis
  ports:
  - port: 6379
    targetPort: 6379
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: excalidraw-storage
  namespace: excalidraw
spec:
  replicas: 1
  selector:
    matchLabels:
      app: excalidraw-storage
  template:
    metadata:
      labels:
        app: excalidraw-storage
    spec:
      containers:
      - name: excalidraw-storage
        image: yinhuihe/excalidraw-storage-backend:latest
        ports:
        - containerPort: 8080
        env:
          - name: STORAGE_URI
            value: redis://redis-service:6379
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 500m
            memory: 256Mi
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: excalidraw-storage-service
  namespace: excalidraw
spec:
  selector:
    app: excalidraw-storage
  ports:
  - port: 8080
    targetPort: 8080
    nodePort: 30711
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: excalidraw-room
  namespace: excalidraw
spec:
  replicas: 1
  selector:
    matchLabels:
      app: excalidraw-room
  template:
    metadata:
      labels:
        app: excalidraw-room
    spec:
      containers:
      - name: excalidraw-room
        image: yinhuihe/excalidraw-room:latest
        ports:
        - containerPort: 80
        livenessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 5
          periodSeconds: 5
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 500m
            memory: 256Mi
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: excalidraw-room-service
  namespace: excalidraw
spec:
  selector:
    app: excalidraw-room
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30712
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: excalidraw-frontend
  namespace: excalidraw
spec:
  replicas: 1
  selector:
    matchLabels:
      app: excalidraw-frontend
  template:
    metadata:
      labels:
        app: excalidraw-frontend
    spec:
      containers:
      - name: excalidraw-frontend
        image: yinhuihe/excalidraw
        ports:
        - containerPort: 80
        env:
          - name: VITE_APP_BACKEND_V2_GET_URL
            value: https://excalidraw.wanna1314y.top/api/v2/scenes/
          - name: VITE_APP_BACKEND_V2_POST_URL
            value: https://excalidraw.wanna1314y.top/api/v2/scenes/
          - name: VITE_APP_WS_SERVER_URL
            value: wss://excalidraw.wanna1314y.top
          - name: VITE_APP_FIREBASE_CONFIG
            value: "{}"
          - name: VITE_APP_HTTP_STORAGE_BACKEND_URL
            value: https://excalidraw.wanna1314y.top/api/v2
          - name: VITE_APP_STORAGE_BACKEND
            value: http
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 500m
            memory: 256Mi
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: excalidraw-frontend-service
  namespace: excalidraw
spec:
  selector:
    app: excalidraw-frontend
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30710 
  type: NodePort

2. 配置反向代理服务

接着需要在NginxProxyManager当中,配置反向代理。

image-8keg.png