# mongos-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: mongos spec: replicas: 2 selector: matchLabels: app: mongos template: metadata: labels: app: mongos spec: securityContext: fsGroup: 999 initContainers: - name: prepare-keyfile image: busybox:1.36 command: - sh - -c - | cp /secret/keyfile /work/keyfile chown 999:999 /work/keyfile chmod 400 /work/keyfile volumeMounts: - name: keyfile-secret mountPath: /secret - name: keyfile-work mountPath: /work containers: - name: mongos image: mongo:8.0 command: - mongos - "--configdb" - "configReplSet/configsvr-0.configsvr.mongodb.svc.cluster.local:27019,configsvr-1.configsvr.mongodb.svc.cluster.local:27019,configsvr-2.configsvr.mongodb.svc.cluster.local:27019" - "--bind_ip_all" - "--keyFile" - "/etc/mongo-keyfile/keyfile" ports: - containerPort: 27017 volumeMounts: - name: keyfile-work mountPath: /etc/mongo-keyfile readOnly: true volumes: - name: keyfile-secret secret: secretName: mongodb-keyfile - name: keyfile-work emptyDir: {}