kysnm / metabase-gke

Metabase deployment in Google Kuberenetes Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Metabase in Google Kubernetes Engine

This repo demonstrates deploying Metabase as a docker container in Google Kubernetes Engine (GKE).

Kubernetes config

Specifically, this Kubernetes (k8s) configuration comprises:

  • k8-deployment.yaml
    Deployment of pod template with metabase docker image and "sidecar" container running GCP cloud sql proxy for database access.

  • k8-service.yaml
    NodePort service to open automatic "high port" on each node that the loadbalancer can proxy

  • k8-ingress.yaml
    Ingress resource that loadbalances traffic and terminates SSL/TLS. This configuration utilizes the "gce" loadbalancer class

Preparation

  • Download the GKE credentials:
gcloud container clusters get-credentials <cluster_name>
  • Apply GKE credentials as kubectl context:

    • List available contexts:
    kubectl config get-contexts
    • Set context:
    kubectl config use-context <context>
  • Reserve a GCP static ip:

gcloud compute addresses create metabase-ip --global
gcloud sql instances create metabase-db --tier=<tier> --region=<regeion>
gcloud sql users create proxyuser cloudsqlproxy~% --instance=metabase-db --password=<password>
mysql -u proxyuser -h 127.0.0.1 -P 3306 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 101786
Server version: 5.7.14-google (Google)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database metabase;
kubectl apply -f k8-certificate.yaml
  • Modify ./metabase/k8-deployment.yaml:

    • replace <INSTANCE_CONNETION_STRING> with your cloud_sql_proxy connection string
    • Update all environment vars prefixed MB_DB_... to match your cloud_sql_proxy configuration
  • Create ./secrets/cloudsql-gcp-key.json with GCP service account key

  • Create metabase user credentials as text files:

echo -n "proxyuser" > secrets/metabase-db-username.txt
echo -n <password> > secrets/metabase-db-password.txt

Run

Provided shell script k8.sh can create and delete this Kuberentes configuration in the cluster.

  • To create secrets, issue k8.sh secrets
  • Deploy metabase to the cluster with k8.sh create
  • Delete everything with k8.sh delete

Resources

About

Metabase deployment in Google Kuberenetes Engine


Languages

Language:Shell 100.0%