InfluxDB has become a popular choice for time-series databases, especially for DevOps monitoring, real-time analytics, and IoT applications. In this guide, we will explore how to deploy InfluxDB on Kubernetes cluster using K3s and Helm.
We will assume that you already have K3s installed and Helm configured. If K3s and Helm are not installed you learn how to install them here. We will also assume that you have a single K3s cluster without nodes. Let’s get started.
Introduction to the Tools
Before we dive into the deployment, let’s understand the tools we are using:
- K3s: It’s a lightweight Kubernetes distribution designed for developers and edge computing. It’s easy to install and consumes less resources, making it ideal for IoT and edge use cases.
- Helm: It’s the package manager for Kubernetes. It simplifies the deployment of applications on Kubernetes clusters.
- InfluxDB: It’s an open-source time-series database developed by InfluxData. It’s written in Go and optimized for fast, high-availability storage and retrieval of time series data in fields such as operations monitoring, application metrics, IoT sensor data, and real-time analytics.
Step 1: Preparing the Kubernetes Cluster
Since you have a single k3s cluster without nodes, we will use it for our deployment. Verify the cluster’s status using the following command:
kubectl get nodes
You should see your master node in the output.
Step 2: Add the InfluxData Helm Repository
For installing InfluxDB on Kubernetes, InfluxData offers a Helm chart. The InfluxData Helm repository must be added to your Helm client in order to use this chart. Execute the upcoming command:
helm repo add influxdata https://helm.influxdata.com/
Then, update your Helm client with the latest charts:
helm repo update
Step 3: Configure InfluxDB Helm Chart
You must customize the InfluxDB Helm chart to meet your needs before deploying InfluxDB. Make a influxdb-values.yaml file with the configurations you want. For instance:
persistence:
enabled: true
size: 8Gi
service:
type: LoadBalancer
This configuration enables persistent storage with a size of 8Gi and sets the service type to LoadBalancer.
Step 4: Deploy InfluxDB on Kubernetes
Now that you have configured the InfluxDB Helm chart, you can deploy InfluxDB on your Kubernetes cluster. Use the following command:
helm install influxdb influxdata/influxdb -f influxdb-values.yaml
This command deploys InfluxDB on your Kubernetes cluster using the configurations in the influxdb-values.yaml
file.
Step 5: Verify InfluxDB on Kubernetes Deployment
To verify that InfluxDB has been deployed successfully, run the following command:
kubectl get pods
You should see the InfluxDB pod in the output.
Step 6: Accessing InfluxDB on Kubernetes
Now that InfluxDB is running on your Kubernetes cluster, you need to access it. If you set the service type to LoadBalancer in the influxdb-values.yaml
file, you can access InfluxDB using the LoadBalancer’s IP address. Get the IP address using the following command:
kubectl get svc
You should see the LoadBalancer’s IP address in the output.
Step 7: Using InfluxDB on Kubernetes
You can use InfluxDB now that you have access to it. For instance, the following command can be used to create a database:
curl -XPOST 'http://<LoadBalancer-IP>:8086/query' --data-urlencode 'q=CREATE DATABASE mydb'
Replace <LoadBalancer-IP>
with the LoadBalancer’s IP address.
The response {"results":[{"statement_id":0}]}
indicates that the statement was processed without any errors.
Final Thoughts
In this article, we explored the k3s and Helm deployment of InfluxDB on a Kubernetes cluster. We began with one k3s cluster that was empty of nodes, added the InfluxData Helm repository, set up the InfluxDB Helm chart, deployed InfluxDB, and checked the deployment. We then created a database by connecting to InfluxDB.
InfluxDB on Kubernetes is set up simply in this guide. The configurations might need to be changed based on your needs. You might need to set up authentication, scale InfluxDB to handle more traffic, or set up InfluxDB to use an external storage, for instance.
1 Comment
How To Use InfluxDB With Python On Ubuntu 22.04 - Virtono Community · August 9, 2023 at 9:13 AM
[…] can use the official InfluxData repository to install InfluxDB on Ubuntu 22.04. First, add the InfluxData repository using the […]