我是kubernetes的新手。在docker我可以使用官方的mongo图像并运行docker run --name some-mongo -d mongo --auth
然后连接到它并创建一个默认的db用户。如何在kube控制器规范中传递--auth?
复制控制器
# db-controller.yml
apiVersion: v1
kind: ReplicationController
metadata:
labels:
name: mongo
name: mongo-controller
spec:
replicas: 1
template:
metadata:
labels:
name: mongo
spec:
containers:
- image: mongo
name: mongo
ports:
- name: mongo
containerPort: 27017
hostPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
volumes:
- name: mongo-persistent-storage
gcePersistentDisk:
pdName: mongo-disk
fsType: ext4
答案 0 :(得分:4)
您可以配置pod以运行特定命令和任何参数,在您的情况下,它应该是这样的:
containers:
- image: mongo
name: mongo
command: ["mongo", "--auth"]
或
containers:
- image: mongo
name: mongo
args: ["--auth"]
可以找到更多详细信息here