This repo demonstrates deploying Metabase as a docker container in Google Kubernetes Engine (GKE).
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
- 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
-
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
- replace
-
Create
./secrets/cloudsql-gcp-key.json
with GCP service account key -
Create metabase user credentials as text files:
echo -n "metabase" > secrets/metabase-db-username.txt
echo -n "password" > secrets/metabase-db-password.txt
- Store the SSL/TLS cert and private key as
secrets/tls.crt
andsecrets/tls.key
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