Skip to content

1. Introduction

InfluxDB is a popular time-series database. It is written in Go, requires no external dependencies, and is easy to install and configure, making it suitable for building monitoring systems for large-scale distributed systems.

Key features:

1) Time-series based, supporting time-related functions (such as max, min, sum, etc.)

2) Measurability: you can compute large amounts of data in real time.

3) Event-based: it supports arbitrary event data.

2. Prerequisites

  • A Kubernetes cluster must be deployed
  • OpenEBS storage plugin driver must be installed

3. Installation Preparation

Since InfluxDB is resource-intensive and requires exclusive cluster resources, cluster scheduling must be configured in advance.

4. Cluster Label Settings

4.1 Label the Cluster Nodes

# According to the cluster plan, tag the Kubernetes nodes that will host the InfluxDB service.
# xxx represents the actual cluster nodes. Separate multiple node IPs with spaces, or use the Tab key in the terminal.
kubectl label nodes xxx influxdb=true

4.2 Verify the Labels

kubectl get nodes --show-labels  | grep 'influxdb'

5. Cluster Taint Settings

5.1 Apply Taints to the Cluster

kubectl taint node  xxxx infrastructure=middleware:NoExecute

6. Configure StorageClass

6.1 Create a Dedicated StorageClass for InfluxDB

# Copy the following YAML content to the Kubernetes cluster and save it as sc-influxdb.yaml. Modify as needed before deployment.
apiVersion: storage.k8s.io/v1
allowVolumeExpansion: true
kind: StorageClass
metadata:
  annotations:
    cas.openebs.io/config: |
      - name: StorageType
        value: "hostpath"
      - name: BasePath
        value: "/data/influxdb"  # This path can be modified according to actual needs. Ensure sufficient storage space.
  name: openebs-influxdb  # The name must be unique within the cluster. Update the deployment file /etc/kubeasz/guance/infrastructure/yaml/taos.yaml accordingly before installation.
provisioner: openebs.io/local
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer

Ensure the /data/influxdb directory has sufficient disk capacity.

6.2 Configure InfluxDB Data Storage Space

# Enter /etc/kubeasz/guance/infrastructure/yaml/influxdb.yaml and modify as needed.
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: influx-data
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi  # Adjust the storage size according to actual requirements.
  volumeMode: Filesystem
  storageClassName: openebs-hostpath

7. Installation

# Default admin username: admin
# Default login password: "B8vBISUItYEH4uhk"
# To customize the password, modify /etc/kubeasz/guance/infrastructure/yaml/influxdb.yaml before installation.

# Create the namespace
kubectl  create  ns middleware
# Deploy the InfluxDB service
kubectl  apply  -f /etc/kubeasz/guance/infrastructure/yaml/influxdb.yaml  -n middleware

8. Verify Deployment

# Default admin username: admin
# Default login password: "B8vBISUItYEH4uhk"
[root@k8s-node01 ~]# kubectl  get pods -n middleware
NAME                        READY   STATUS    RESTARTS   AGE
influxdb-7ff9db677f-v4877   1/1     Running   0          3m42s

[root@k8s-node01 ~]# kubectl  exec -it -n middleware  influxdb-xxxx influx
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Connected to http://localhost:8086 version 1.7.8
InfluxDB shell version: 1.7.8
> auth
username: admin
password:
> show databases;
name: databases
name
----
_internal
>

Feedback

Is this page helpful?