我有一個 Google Kubernetes Engine 正在運行,我正在嘗試部署一個 mongo 容器。一切正常,除非我嘗試使用引數“--wiredTigerCacheSizeGB”,然后部署失敗,因為無法識別此命令。我正在使用最新的 Mongo 版本 (5.0),但我在檔案中沒有看到任何內容表明這不可行。
下面是POD創建的yml配置:
apiVersion: apps/v1
kind: StatefulSet
spec:
podManagementPolicy: OrderedReady
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
environment: test
role: mongo
serviceName: mongo
template:
metadata:
creationTimestamp: null
labels:
environment: test
role: mongo
namespace: default
spec:
containers:
- command:
- mongod
- --wiredTigerCacheSizeGB 2
image: mongo:5.0
imagePullPolicy: Always
name: mongo
ports:
- containerPort: 27017
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /data/db
name: mongo-persistent-storage
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 10
tolerations:
- effect: NoSchedule
key: dedicated
operator: Equal
value: backend
updateStrategy:
type: OnDelete
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.beta.kubernetes.io/storage-class: standard
creationTimestamp: null
name: mongo-persistent-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
volumeMode: Filesystem
uj5u.com熱心網友回復:
如果你移除--wiredTigerCacheSizeGB標志,它會起作用嗎?
我會很驚訝。
它似乎確實有效(見下文),但我無法解釋原因。我很驚訝!
如果這是影像的正確Dockerfile,則它使用 DockerCMD運行mongod.
如果是這樣,您需要使用argsnotcommand在Kubernetes 上運行映像,以便正確覆寫容器映像CMD而不是覆寫容器映像ENTRYPOINT,即
containers:
- name: mongo
args:
- mongod
- --wiredTigerCacheSizeGB=2
注意
=在標志和值之間包含以避免引入 YAML 決議問題。
我使用以下方法測驗了這個假設podman;如果您使用,您可以在以下內容中替換podman為:dockerdocker
# Does not work: Override `ENTRYPOINT` with mongod flag
# This is effectively what you're doing
podman run \
--interactive --tty --rm \
--entrypoint="mongod --wiredTigerCacheSizeGB=2" \
docker.io/mongo:5.0 \
Error: executable file `mongod --wiredTigerCacheSizeGB=2` not found in $PATH:
No such file or directory:
OCI runtime attempted to invoke a command that was not found
# Works: Override `CMD`
# This is what I thought should work
podman run \
--interactive --tty --rm \
docker.io/mongo:5.0 \
mongod \
--wiredTigerCacheSizeGB=2
# Works: Override `ENTRYPOINT` w/ mongod
# This is what I thought wouldn't work
podman run \
--interactive --tty --rm \
--entrypoint=mongod \
docker.io/mongo:5.0 \
--wiredTigerCacheSizeGB=2
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/348883.html
標籤:MongoDB Kubernetes google-kubernetes-engine
上一篇:Kubectl:無法決議主機
下一篇:將unix時間戳轉換為特定時區
