/knative-source-mongodb

Primary LanguageGoApache License 2.0Apache-2.0

This is not an officially supported Google product.

GoDoc Go Report Card LICENSE Build Status

Knative Source - MongoDB

The MongoDb Event source adds support of MongoDb resources to Knative Eventing.

Prerequisites

  1. Install Knative Eventing in your Kubernetes Cluster.

  2. Either:

    • Install MongoDb on your Kubernetes Cluster and create a Replica Set. Instructions available here.

    • Create a MongoDb Cluster on Atlas, through GCP for example. Link available here.

  3. Install ko and then execute:

    ko apply -f ./config
    

Usage

  1. Create a secret containing the data needed to access your MongoDb service. For example:

     apiVersion: v1
     kind: Secret
     metadata:
         name: my-mongo-secret
         namespace: default
     stringData:
             URI: mongodb://USERNAME:PASSWORD@IP:PORT/USERDB

    The URI is the connection string of your Mongo Database or Cluster. USERDB is the database your user account pertains to (can be admin).

  2. Create the MongoDbSource custom object, by configuring the required database has to be provided, but collection is optional. For example, with a Knative Service as a sink:

     apiVersion: sources.google.com/v1alpha1
     kind: MongoDbSource
     metadata:
         name: mongodb-example-source
         namespace: default
     spec:
         database: db1
         collection: coll1  # optional
         secret:
             name: my-mongo-secret
     sink:
         ref:
           apiVersion: serving.knative.dev/v1
           kind: Service
           name: event-display
           namespace: mongodb