Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to deploy the mongodb using kubernetes #118

Open
irparajababu opened this issue May 24, 2020 · 1 comment
Open

Trying to deploy the mongodb using kubernetes #118

irparajababu opened this issue May 24, 2020 · 1 comment

Comments

@irparajababu
Copy link


apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
name: mongo
spec:
ports:

  • port: 27017
    targetPort: 27017
    clusterIP: None
    selector:
    role: mongo

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
spec:
selector:
matchLabels:
role: mongo
serviceName: "mongo"
replicas: 3
template:
metadata:
labels:
role: mongo
spec:
terminationGracePeriodSeconds: 10
containers:
- name: mongo
image: mongo
command:
- mongod
- "--replSet"
- rs0
- "--smallfiles"
- "--noprealloc"
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
- name: mongo-sidecar
image: cvallance/mongo-k8s-sidecar
env:
- name: MONGO_SIDECAR_POD_LABELS
value: "role=mongo"
volumeClaimTemplates:

  • metadata:
    name: mongo-persistent-storage
    spec:
    accessModes: [ "ReadWriteOnce" ]
    storageClassName: standard
    resources:
    requests:
    storage: 10Gi

i am getting the below error.
error log:
error: a container name must be specified for pod mongo-0, choose one of: [mongo mongo-sidecar]

@jschroed91
Copy link

@irparajababu That error is actually an error from kubectl itself and not the container. Since the pod is running two containers, you need to specify which container to listen on in whatever kubectl command you're running (I'm assuming it's kubectl logs mongo-0)

Run this instead: kubectl logs mongo-0 mongo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants