Navigation

MongoDB Enterprise Kubernetes Operator Troubleshooting

Review the Logs

Review Logs from the Kubernetes Operator

To review the Kubernetes Operator logs, invoke this command:

kubectl logs -f deployment/mongodb-enterprise-operator -n <metadata.namespace>

You could check the Ops Manager Logs as well to see if any issues were reported to Ops Manager.

Find a Specific Pod

To find which pods are available, invoke this command first:

kubectl get pods -n <metadata.namespace>

See also

Kubernetes documentation on kubectl get.

Review Logs from Specific Pod

If you want to narrow your review to a specific pod, you can invoke this command:

kubectl logs <podName> -n <metadata.namespace>

Example

If your replica set is labeled myrs, the pod log command is invoked as:

kubectl logs myrs-0 -n <metadata.namespace>

This returns the Automation Agent Log for this replica set.

View MongoDB Kubernetes resource Specifications

View All Replica Set MongoDB Kubernetes resource Specifications

To view all replica set MongoDB Kubernetes resource specifications in the provided namespace:

kubectl get mrs -n <namespace>

View All Sharded Cluster MongoDB Kubernetes resource Specifications

To view all sharded cluster MongoDB Kubernetes resource specifications in the provided namespace:

kubectl get msc -n <namespace>

View All Standalone MongoDB Kubernetes resource Specifications

To view all standalone MongoDB Kubernetes resource specifications in the provided namespace:

kubectl get mst -n <namespace>

Example

To read details about the dublin standalone resource, invoke this command:

kubectl get mst dublin -n <namespace> -o yaml

This returns the following response:

apiVersion: mongodb.com/v1
kind: MongoDbStandalone
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"mongodb.com/v1","kind":"MongoDbStandalone","metadata":{"annotations":{},"name":"dublin","namespace":"mongodb"},"spec":{"credentials":"alis-credentials","persistent":false,"podSpec":{"memory":"1G"},"project":"my-om-config","version":"4.0.0-ent"}}
  clusterName: ""
  creationTimestamp: 2018-09-12T17:15:32Z
  generation: 1
  name: dublin
  namespace: mongodb
  resourceVersion: "337269"
  selfLink: /apis/mongodb.com/v1/namespaces/mongodb/mongodbstandalones/dublin
  uid: 7442095b-b6af-11e8-87df-0800271b001d
spec:
  credentials: my-credentials
  persistent: false
  podSpec:
    memory: 1G
  project: my-om-config
  version: 4.0.0-ent

Remove a MongoDB Kubernetes resource

To remove any instance that Kubernetes deployed, you must use Kubernetes.

Important

You can only use the Kubernetes Operator to remove Kubernetes-deployed instances. If you use Ops Manager to remove the instance, Ops Manager throws an error.

Example

To remove a standalone MongoDB instance you created using Kubernetes:

kubectl delete mongodbstandalone <name> -n <metadata.namespace>

To remove all MongoDB instances you created using Kubernetes:

kubectl delete [mrs|msc|mst] --all -n <metadata.namespace>

You can refer to the MongoDB Kubernetes resources by either their long or short names:

MongoDB Deployment Item Resource Long Name Resource Short Name
MongoDB Replica Set mongodbreplicaset mrs
MongoDB Sharded Cluster mongodbshardedcluster msc
MongoDB Standalone Deployment mongodbstandalone mst

Remove the Kubernetes Operator

To remove the Kubernetes Operator:

  1. Remove all Kubernetes resources:

    kubectl delete [mrs|msc|mst] --all -n <metadata.namespace>
    
  2. Remove the Kubernetes Operator:

    kubectl delete deployment mongodb-enterprise-operator -n <metadata.namespace>
    

Removing Databases after Operator was deleted

If you have already removed the Kubernetes Operator but still have running databases, you need to remove the finalizer header from errant resources:

kubectl patch [mrs|msc|mst] <name> -n <metadata.namespace> \
  --type json -p='[{"op": "remove", "path": "/metadata/finalizers"}]'

This deletes all of the resources immediately.

Remove the namespace

To remove the namespace:

  1. Remove all Kubernetes resources:

    kubectl delete [mrs|msc|mst] --all -n <metadata.namespace>
    
  2. Remove the namespace:

    kubectl delete namespace <metadata.namespace>
    

Remove the CustomResourceDefinitions

To remove the CustomResourceDefinitions:

  1. Remove all Kubernetes resources:

    kubectl delete [mrs|msc|mst] --all -n <metadata.namespace>
    
  2. Remove the CustomResourceDefinitions:

    kubectl delete crd --all