KOP Recipes - InfluxDB - Rafay Product Documentation

InfluxDB

InfluxDB is an open source time series database designed to handle high write and query loads. It is designed to be used for use cases involving large amounts of time stamped data such as monitoring, IoT sensor data and real time analytics. A common use case for InfluxDB with Kubernetes is centralized aggregation of Prometheus metrics data from multiple clusters for long term storage etc.


What Will You Do

In this exercise,

Important

This recipe describes the steps to create and use an InfluxDB workload using the Web Console. The entire workflow can also be fully automated and embedded into an automation pipeline.


Assumptions


Challenges

Although deploying a simple Helm chart can be trivial for a quick sniff test, there are a number of considerations that have to be factored in for a stable deployment. Some of them are described below.

Ingress

The InfluxDB service deployed on the cluster needs to be exposed externally for it to be practical. In this recipe, we will use the managed nginx Ingress Controller in the default blueprint to expose the InfluxDB service externally.


Certificate Lifecycle

InfluxDB's Ingress needs to be secured using TLS. It is impractical to manually handle certificates and private keys. In this recipe, we will use a cert-manager addon in our cluster blueprint to manage the lifecycle of certificates for the InfluxDB Server's Ingress.


Secrets Management

It is imperative to secure InfluxDB's admin user and admin password and not have users manually handle these secrets. In this recipe, we will also use the controller's Integration with HashiCorp Vault to secure InfluxDB's credentials.


Backup InfluxDB Data

It is important to regularly backup data for your InfluxDB using object storage like AWS S3 so you can restore in case of a disaster.


Step 1: Download Helm chart

Use your helm client to download the latest release of InfluxDB helm chart file influxdb-x.y.z.tgz to your machine influxdb-helm-chart

helm repo add influxdata https://influxdata.github.io/helm-charts
helm fetch influxdata/influxdb

Note

In this recipe, we used influxdb-4.8.2.tgz of the InfluxDB Helm chart


Step 2: Customize Values

In this step, we will be creating a custom "values.yaml" file with overrides for our InfluxDB deployment.

## influxdb custom values

## Specify a service type
## Change to NodePort or LoadBalancer if does not want to use ingress
##
service:
  type: ClusterIP

## Persist data to a persistent volume
##
persistence:
  enabled: true
  # storageClass: "-"
  accessMode: ReadWriteOnce
  size: 8Gi

## Configure resource requests and limits
resources:
 requests:
   memory: 256Mi
   cpu: 0.1
 limits:
   memory: 2Gi
   cpu: 2

## Configure ingress for influxdb if you would like to expose the influxdb using ingress
ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: "letsencrypt-http"
  hostname: influxdb.eks.gorafay.net
  path: /  
  tls: true
  secretName: influxdb-ingress-tls

## Add pod annotations to use the vault integration
podAnnotations:
  rafay.dev/secretstore: vault
  ## replace "infra" with your configured vault role
  vault.secretstore.rafay.dev/role: "infra"

## Add ENV for getting influxdb admin username and password from vault secret stores
env:
  ## replace infra-apps/data/influxdb#data.admin_username with the vault secret path to your influxdb admin username
  - name: INFLUXDB_ADMIN_USER
    value: secretstore:vault:infra-apps/data/influxdb#data.admin_username
  ## replace infra-apps/data/influxdb#data.admin_password with the vault secret path to your influxdb admin password
  - name: INFLUXDB_ADMIN_PASSWORD
    value: secretstore:vault:infra-apps/data/influxdb#data.admin_password

# Configure init script to create database
#
initScripts:
  enabled: true
  scripts:
    init.iql: |+
      CREATE DATABASE "prometheus" WITH DURATION 30d REPLICATION 1 NAME "rp_30d"

# Configure backup for influxdb if not yet have backup solution at cluster level
backup:
  enabled: true
  ## By default emptyDir is used as a transitory volume before uploading to object store.
  ## As such, ensure that a sufficient ephemeral storage request is set to prevent node disk filling completely.
  resources:
    requests:
      # memory: 512Mi
      # cpu: 2
      ephemeral-storage: "8Gi"
    # limits:
      # memory: 1Gi
      # cpu: 4
      # ephemeral-storage: "16Gi"
  ## If backup destination is PVC, or want to use intermediate PVC before uploading to object store.
  persistence:
    enabled: true
    # storageClass: "-"
    accessMode: ReadWriteOnce
    size: 8Gi

## Backup cronjob schedule
  schedule: "0 0 * * *"

## Amazon S3 or compatible
  ## Secret is expected to have AWS (or compatible) credentials stored in `credentials` field.
  ## for the credentials format.
  ## The bucket should already exist.
  s3:
    destination: s3://influxdb-bk/demo
    ## Optional. Specify if you're using an alternate S3 endpoint.
    #endpointUrl: ""

Step 3: Create Workload


Step 4: Verify Deployment

You can optionally verify whether the correct resources have been created on the cluster.

kubectl get pod
kubectl get pvc
kubectl get ingress
kubectl get svc

Shown below is an example for what you should see on a cluster where InfluxDB has been deployed as a Helm workload through the controller.

Alternatively, users with Infrastructure Admin or Organization Admin roles can view the status of all Kubernetes resources created by this InfluxDB workload by going to Infrastructure > Clusters > cluster_name > Resources and filter by Workloads "influxdb" as below:


Step 5: Verify InfluxDB Backup Cronjob

kubectl get cronjob
NAME              SCHEDULE     SUSPEND   ACTIVE   LAST SCHEDULE   AGE
influxdb-backup   0 0 * * *    False     0        30s             50m
kubectl get job
kubectl get pvc
kubectl get pod
kubectl logs influxdb_backup_pod_name

Recap

Congratulations! You have successfully deployed the InfluxDB time series database to a managed cluster.

You can now start using this InfluxDB time series database for your applications.

One example is to use InfluxDB to store Prometheus Metrics from Kubernetes Clusters with remote_write option.

More information on how to deploy Prometheus with the controller can be found at here