/mongodb-enterprise-gke

MongoDB Enterprise on GKE for Google Marketplace

Primary LanguageShellOtherNOASSERTION

Use this file as a template for your application's README. Delete any sections that don't apply to your app. Delete this note when you start editing.


Overview

MongoDB

For more information on MongoDB, see the MongoDB website.

About Google Click to Deploy

Popular open source software stacks on Kubernetes packaged by Google and made available in Google Cloud Marketplace.

Installation

Quick install with Google Cloud Marketplace

Get up and running with a few clicks! Install this MongoDB to a Google Kubernetes Engine cluster using Google Cloud Marketplace. Follow the on-screen instructions.

Command line instructions

You can use Google Cloud Shell or a local workstation to follow the steps below.

Open in Cloud Shell

Prerequisites

Set up command line tools

You'll need the following tools in your development environment. If you are using Cloud Shell, gcloud, kubectl, Docker, and Git are installed in your environment by default.

Configure gcloud as a Docker credential helper:

gcloud auth configure-docker

Create a Google Kubernetes Engine cluster

Create a cluster from the command line. If you already have a cluster that you want to use, this step is optional.

export CLUSTER=sample-app-cluster
export ZONE=us-west1-a

gcloud container clusters create "$CLUSTER" --zone "$ZONE"

Configure kubectl to connect to the cluster

gcloud container clusters get-credentials "$CLUSTER" --zone "$ZONE"

Clone this repo

Clone this repo and the associated tools repo:

git clone --recursive https://github.com/GoogleCloudPlatform/click-to-deploy.git

Install the Application resource definition

An Application resource is a collection of individual Kubernetes components, such as Services, Deployments, and so on, that you can manage as a group.

To set up your cluster to understand Application resources, run the following command:

kubectl apply -f "https://raw.githubusercontent.com/GoogleCloudPlatform/marketplace-k8s-app-tools/master/crd/app-crd.yaml"

You need to run this command once for each cluster.

The Application resource is defined by the Kubernetes SIG-apps community. The source code can be found on github.com/kubernetes-sigs/application.

Install the Application

Navigate to the sample-app directory:

cd click-to-deploy/k8s/sample-app

Configure the app with environment variables

Choose an instance name and namespace for the app. In most cases, you can use the default namespace.

export APP_INSTANCE_NAME=sample-app-1
export NAMESPACE=default

Set the sample parameter:

export SAMPLE_APP_PARAMETER1=3

Configure the container image:

export IMAGE_SAMPLE_APP="marketplace.gcr.io/google/nginx1:latest"

The image above is referenced by tag. We recommend that you pin each image to an immutable content digest. This ensures that the installed application always uses the same images until you are ready to upgrade. To get the digest for the image, use the following script:

export IMAGE_SAMPLE_APP=$(docker pull $IMAGE_SAMPLE_APP | awk -F: "/^Digest:/ {print gensub(\":.*$\", \"\", 1, \"$IMAGE_SAMPLE_APP\")\"@sha256:\"\$3}")

For the persistent disk used by the sample-app deployment, you will need to:

  • Set the StorageClass name. Check your available options using the command below:
export STORAGE_CLASS="standard" # provide your StorageClass name if not "standard"

Expand the manifest template

Use envsubst to expand the template. We recommend that you save the expanded manifest file for future updates to the application.

awk 'FNR==1 {print "---"}{print}' manifest/* \
  | envsubst '$APP_INSTANCE_NAME $NAMESPACE $IMAGE_SAMPLE_APP $SAMPLE_APP_PARAMETER1 $STORAGE_CLASS' \
  > "${APP_INSTANCE_NAME}_manifest.yaml"

Apply the manifest to your Kubernetes cluster

Use kubectl to apply the manifest to your Kubernetes cluster.

kubectl apply -f "${APP_INSTANCE_NAME}_manifest.yaml" --namespace "${NAMESPACE}"

View the app in the Google Cloud Console

To get the Console URL for your app, run the following command:

echo "https://console.cloud.google.com/kubernetes/application/${ZONE}/${CLUSTER}/${NAMESPACE}/${APP_INSTANCE_NAME}"

To view the app, open the URL in your browser.

Using the app

How to use MongoDB

How to use MongoDB

Customize the installation

To set MongoDB, follow these on-screen steps to customize your installation:

Add steps to customize the application, if applicable. Delete this note when you start editing.

Scaling

Backup and restore

How to backup and restore MongoDB

Backing up MongoDB

Restoring your data

Updating

Logging and Monitoring