
Metabase is an open-source business intelligence tool that lets you create charts and dashboards from data. It supports databases like MySQL, PostgreSQL, MongoDB, and Redshift. By choosing to deploy Metabase on Kubernetes, you can ensure scalable real-time analytics and seamless data sharing across teams, boosting collaboration and KPI tracking.
This article explains how to deploy Metabase on a Kubernetes cluster. You will create a database and load up a sample dataset, install Metabase, and integrate the database to create a dashboard to visualize data. In addition, you will install Nginx Ingress controller to expose Metabase securely using a domain name in your cluster.
Before you begin, you need to:
The Sakila sample database is a fictitious database designed to represent a DVD rental store featuring films, actors, film-actor relationships, and a central inventory table that connects films, stores, and rentals. Follow the steps below to set up the Sakila database to use with Metabase.
Install Unzip if it's not available on your workstation.
Download the Sakila database archive from the MySQL downloads page.
Extract files from the sakila-db.zip archive.
The Sakila archive contains three files, sakila-schema.sql, sakila-data.sql, and sakila.mwb.
Log in to your remote MySQL database server. Replace <HOST_ENDPOINT> with your actual MySQL hostname and <DATABASE_PORT> with the database server port.
Enter your password when prompted and press Enter to log in.
Create a new sakila database.
Execute the sakila-schema.sql script to create the database structure.
Execute the sakila-data.sql script to populate the database.
Follow the steps below to deploy Metabase by creating a deployment using the latest Metabase image and a metabase-svc load balancer service in your cluster.
Create a new metabase.yaml deployment YAML file.
Add the following configurations to the file to create a new deployment and service.
Save and close the file.
Apply the configuration to your Kubernetes cluster to deploy Metabase.
View the cluster deployments and verify that the metabase resource is ready.
Output:
View all cluster services and verify the external IP of the metabase-svc service.
192.0.2.9 is the external metabase-svc IP address based on the above output. The external IP address assignment may delay as the load balancer deploys to your cluster. Wait for at least 3 minutes and refresh the cluster services if the address is not available in your output.
Access the Metabase port 8080 using the external IP to load Metabase in your web browser.
Verify that the Metabase welcome page displays in your browser.
Follow the steps below to configure Metabase to use the Sakila sample database you created earlier.
Click Let's get started on the Metabase page.
Select your preferred language.
Enter your first name, last name, email, company name, and specify a strong password in the respective fields.
Select your purpose for using Metabase.
Select MySQL as the database engine.
Enter a descriptive label in the Display name field to associate with the database.
Enter your MySQL host, port, database name, user name, and password information in the respective fields.
Click Connect Database.
Select your usage data-sharing preferences and click Finish.
Click Take me to Metabase to redirect to the Metabase dashboard.
Follow the steps below to create a Metabase dashboard.
Click + New in the top right corner and select Dashboard.
Enter the dashboard details in the respective fields and click Create.
Click Add a chart within the dashboard.
Click the New SQL query and select your database.
Add following query to get the total revenue of all stores by date in the Sakila dataset.
Click Run Query on the right navigation menu to view the results in a tabular format.
To visualize the output,
Click Visualization at the bottom left, select the Line option, and click Done.
Verify that a line chart displays your results.
Click Save, specify a name for your chart, and save it.
Verify a line chart with your results displays in the dashboard.
Follow the steps below to secure Metabase with TLS encryption and expose the application using the Nginx Ingress controller with trusted SSL certificates.
Patch the metabase-svc service and change the type from LoadBalancer to ClusterIP.
Get all cluster services and verify that the metabase-svc status changes to ClusterIP.
Output:
Use Helm to install the Nginx Ingress controller to enable TLS encryption for your Metabase deployment.
The above command installs the latest Nginx Ingress controller chart from the official repository in a new ingress-nginx namespace.
Get all cluster services and verify the nginx service's public IP address and set up a domain A record pointing to the address.
Install Cert-Manager.
The above command installs cert-manager version v1.17.0 in a new cert-manager namespace. Visit the official releases page to verify the latest version to install in your cluster.
Create a new cert-issuer.yaml manifest to set up an Issuer resource.
Add the following contents to the cert-issuer.yaml file to specify Let's Encrypt CA and email.
Save and close the file.
Apply the Issuer resource to your cluster.
Create a new ingress.yaml manifest for the Ingress resource.
Add the following contents to the ingress.yaml file. Replace example.com with your actual domain that's pointing to the Nginx Ingress Controller's external IP address.
Save and close the file.
Apply the Ingress resource to the cluster.
View all Ingress resources in your cluster.
The first ingress resource created by the cert-manager handles ACME challenges to verify the domain ownership. Verify that the ingress-metabase address changes to your controller's public IP.
Get all certificates and verify that the my-webapp-tls resource is ready.
Sample output:
Open your Metabase dashboard using your domain name with TLS encryption.
You have deployed Metabase in a Kubernetes cluster and integrated a database with sample data to visualize it. You accessed Metabase with a load-balancer service, allowing you to secure connections ot the cluster. You can use Metabase to visualize data by creating charts and databases using the graphical web interface. Visit the Metabase documentation for more information and configuration options.
0 Comments
Be the first to comment and share your perspective with the community.