咕watch的手表在Kubernetes中引发Sails.js出现sync:dev not found错误

时间:2018-11-13 22:32:54

标签: kubernetes gruntjs sails.js minikube

我使用Minikube模拟我的Kubernetes生产架构。 在集群中,我需要创建一个网站,然后决定使用Sails.js。

这是我的Kubernetes配置:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: white-label-storage-persistent-volume
  labels:
    type: local
    app: white-label
    role: master
    tier: backend
spec:
  storageClassName: manual
  capacity:
    storage: 5Gi
  accessModes:
  - ReadWriteMany
  hostPath:
    path: "/white-label-data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: white-label-storage-persistent-volume-claim
  labels:
    app: white-label
    role: master
    tier: backend
spec:
  storageClassName: manual
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: white-label-deployment
  labels:
    app: white-label
    role: master
    tier: backend
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: white-label
      role: master
      tier: backend
  template:
    metadata:
      labels:
        app: white-label
        role: master
        tier: backend
    spec:
      containers:
      - name: white-label
        image: pastel-white-label:v1
        imagePullPolicy: IfNotPresent
        workingDir: "/usr/src/app"
        resources:
          requests:
            memory: 2Gi
            cpu: 1
          limits:
            memory: 4Gi
            cpu: 2
        ports:
        - containerPort: 1337
          protocol: TCP
        volumeMounts:
        - mountPath: "/data"
          name: white-label-persistent-volume
      volumes:
        - name: white-label-persistent-volume
          persistentVolumeClaim:
            claimName: white-label-storage-persistent-volume-claim
---
apiVersion: v1
kind: Service
metadata:
  name: white-label-service
  labels:
    app: white-label
    role: master
    tier: backend
spec:
  type: LoadBalancer
  ports:
  - port: 1337
    protocol: TCP
    nodePort: 30003
  selector:
    app: white-label
    role: master
    tier: backend
  sessionAffinity: None
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: white-label-hpa
  labels:
    app: white-label
    role: master
    tier: backend
  namespace: default
spec:
  maxReplicas: 5
  minReplicas: 1
  scaleTargetRef:
    apiVersion: extensions/v1
    kind: Deployment
    name: white-label-deployment
  targetCPUUtilizationPercentage: 80

这是pastel-white-label:v1 Docker映像:

FROM node:10.13.0-stretch

WORKDIR /usr/src/app
COPY . ./

RUN npm install -g sails npm-check-updates
RUN npm install @sailshq/connect-redis --save
RUN npm install

CMD ["sails", "lift"]

当我启动集群并构建Pod时,一切都像魅力一样。 我的Sails.js日志一尘不染,我可以在浏览器中看到主页:完全没有问题。我开箱即用地在Web应用程序模式下使用Sails.js v1.1.0。我还可以看到Grunt已启动并正在观看。

现在,如果我编辑.less文件,我将变得不友好:

debug: -------------------------------------------------------
error: ** Grunt :: An error occurred. **
error: 
------------------------------------------------------------------------

Aborted due to warnings.
Running "watch" task
Waiting...
>> File "assets/styles/styleguide/colors.less" changed.
Loading "sync.js" tasks...ERROR
>> TypeError: Cannot read property 'length' of undefined
Warning: Task "sync:dev" not found.

我确定我的.less文件没有错误(六代码版本),我的.tmp文件夹可写(例如,触摸.tmp / foo在工作),并且我相信Grunt在出厂时已正确安装...

那我真的不知道这是怎么回事...

请问你们有个主意吗?

谢谢你

2 个答案:

答案 0 :(得分:1)

我认为您正碰上this。看起来它特定于节点版本。您可以为您的节点docker映像尝试更早的版本:

FROM node:8.12.0-stretch

答案 1 :(得分:0)

如您在docker文件中所述

  

FROM节点:10.13.0拉伸

如果您仍然想使用节点10.x +并避免出现此错误,则可以使用此处讨论的方法。简单又好:)

https://github.com/balderdashy/sails/issues/4513#issuecomment-468389534