这可能是在nfs共享中或在nodemon中可配置的,不确定...
基本上,对于使用minikube并具有持久卷声明的生产k8s系统的本地开发,其中卷是本地定义的nfs份额。
/ etc / exports:
/path/to/nfs/share -alldirs -mapall=501:20 192.168.99.100
volume.yml:
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-volume
spec:
capacity:
storage: 15Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: standard
nfs:
server: 192.168.99.1
path: /path/to/nfs/share
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: cr-volume
spec:
storageClassName: standard
accessModes:
- ReadWriteMany
resources:
requests:
storage: 15Gi
deployment.yml:
...(relevant section to mounting nfs share into container)
containers:
- name: user
image: image_name
imagePullPolicy: Always
command:
- npm
args:
- run
- dev-start
ports:
- containerPort: 5600
- containerPort: 5898
volumeMounts: # mount host directory for local development
- mountPath: /usr/src/app
name: user-mount
subPath: backend/services/user
volumes:
- name: user-mount
persistentVolumeClaim:
claimName: cr-volume
...
此处的命令(npm run dev-start)是. ./config/development/export-env.sh && DEBUG=user:* node_modules/nodemon/bin/nodemon.js --inspect=0.0.0.0:5898 --legacy-watch -L ./bin/www
,而不是prod npm start node ./bin/www
因此,所有这些工作和在本地模拟了prod env,并允许我在本地文件系统上进行更改,这些更改将通过它们进入容器并重新加载。我唯一的问题是,nodemon通常在30到60秒之间不会接收对文件的更改。
我对nfs的份额以及守护程序如何广播更改以及对nodemon与其传统手表标志的监视方式了解得不够了解,但是我很想能够解决此问题,因此希望对它进行更改重新加载更快。