我正在尝试部署使用nodejs和mongodb构建的应用程序。我在不同的VM上安装了mongodb,并在kubernetes集群中添加了mongodb服务器的URL作为秘密。我有一个用于mongodb secret的env变量,MONGODB_URL是保存该密钥的var,它在.js文件中声明为process.env.MONGODB_URL。但是当我尝试部署该应用程序时,我的pod的状态为crashloopbackoff,当我描述它时会收到此错误。
starting container process caused "exec: \"--env=\\\"MONGODB_URL=–n “mongodb://10.128.x.x,10.128.x.x:27017/db?replicaSet=rs0”\\n\\\"\": stat --env=\"MONGODB_URL=–n “mongodb://10.128.x.x,10.128.x.x:27017/db?replicaSet=rs0”\n\": no such file or directory"
这是我的部署yaml文件的样子
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: s-provider
spec:
selector:
matchLabels:
app: s-provider
role: provider
replicas: 1
template:
metadata:
name: s-provider
labels:
app: s-provider
role: provider
env: staging
spec:
containers:
- name: s-provider
image: gcr.io/gcr-project/sample:1.0.0
env:
- name: MONGODB_URL
valueFrom:
secretKeyRef:
name: mongo-secret
key: MONGODB_URL
#- name: API_URL
# valueFrom:
# secretKeyRef:
# name: lesvault
# key: api_url_staging
- name: NODE_ENV
value: production
resources:
limits:
memory: "500Mi"
cpu: "100m"
imagePullPolicy: Always
readinessProbe:
httpGet:
path: /
port: 3000
args: ['--env="MONGODB_URL=$(MONGODB_URL)"']
ports:
- name: s-provider
containerPort: 3000
任何人都可以告诉我该错误表示什么,并帮助我解决该问题