Compliant Kubernetes Service documentation has moved

Please note: You are not reading Kubernetes documentation. If you're looking for Compliant Kubernetes Service documentation, it has moved. Read more here.

Purpose

The following steps will guide you through the process of setting up Metabase as a code service on Datica's CPaaS. This tutorial is not intended to be used as a How-to for the configuration or administration of the Metabase application.

 

Requirements

This tutorial requires the following to build, deploy, and access the Metabase service.

 

Step-by-step Guide

Configure and deploy Metabase as a code service

Prepare the code service directory

From the command line, navigate to the directory containing your repositories and execute the commands below.

# Setup the directory
mkdir metabase
cd metabase

# Setup Git
echo "# Metabase Service" > README.md
git init
git add .
git commit -m "initial commit"

# Initialize the metabase directory
# Note: the init command will prompt you to select an
# environment and service to initialize.
datica init

 

Prepare the Metabase application

curl -JL 'http://downloads.metabase.com/v0.31.2/metabase.jar' > metabase.jar
echo "web: java -jar ./metabase.jar" > Procfile
echo "java.runtime.version=1.8" > system.properties
echo '<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.metabase</groupId>
<artifactId>Metabase</artifactId>
<version>0.31.2</version>
</project>
' > pom.xml

 

Configure service environment variables

The commands below will configure the service's environment for the Metabase application to persist application data in a PostgreSQL service running in the environment. It's important to persist the data in a database because a service restart will result in a loss of all application data. See the Metabase documentation for additional configuration details.

# User prompts
{
echo "The following are case sensitive!"
read -p "Environment Name: " environment
read -p "Code Service Name: " service
read -p "Database Service Name: " database
export DATICA_ENV=${environment}
}

# Set database variables from connection string
{
database_url=${database^^}_URL ; database_url=${database_url/-/_}
variables=( $(IFS='=:@/' read -a var <<< "$(datica vars list $service | grep $database_url)" ; echo ${var[@]}) )
[ ${#variables[@]} -eq 7 ] && echo "Success :)" || echo "Failure :("
DB_TYPE=${variables[1]}
DB_USER=${variables[2]}
DB_PASS=${variables[3]}
DB_HOST=${variables[4]}
DB_PORT=${variables[5]}
}

# Add the metabase variables to configure the code service
datica vars set "$service" \
-v "MB_DB_TYPE=${DB_TYPE}" \
-v "MB_DB_USER=${DB_USER}" \
-v "MB_DB_PASS=${DB_PASS}" \
-v "MB_DB_HOST=${DB_HOST}" \
-v "MB_DB_PORT=${DB_PORT}" \
-v "MB_DB_DBNAME=metabase" \
-v "MB_JETTY_PORT=8080"

# Verify the service variables have been added
datica vars list "$service" | grep "MB_"

 

Create a database called metabase

Get a console session to the PostgeSQL database and create a DB called "metabase".

datica console database-1

catalyzeDB=# create database metabase;
CREATE DATABASE

 

Deploy the code service

git add .
git commit -m "Metabase"
git push datica master

 

Add Metabase to the service proxy

Add a CNAME record to your domain

First, get your environment's hostname. You can get this by logging into the Product Dashboard and going to the service_proxy for the environment.

Screen_Shot_2019-03-15_at_4.33.13_PM.png

Next, create a CNAME record pointing to the environments hostname on your domain. Below is an example using AWS's Route53.

Screen_Shot_2019-03-15_at_4.38.49_PM.png

 

Create a site and certificate for Metabase

Create a site so it is added to your environments service proxy. For simplicity, we'll use Let's Encrypt to create the certificate by adding the --lets-encrypt flag. You can also upload your own certificate. See the SSL Certificates Guide for details.

datica sites create metabase.qub3r.com code-1 --lets-encrypt

Created 'metabase.qub3r.com'
To make your site go live, you must redeploy your service proxy with the "datica redeploy service_proxy" command

 

Redeploy the service proxy

datica redeploy service_proxy

 

Verify the site

In your web browser, navigate to the CNAME added to the domain. For this tutorial, I'll be using metabase.qub3r.com to ensure the site is available. Note: it can take time for the DNS to propagate and for the service proxy to redeploy. If it isn't available immediately, try again in 60 minutes.

Screen_Shot_2019-03-15_at_6.00.42_PM.png