Deploying InfluxDB on Kubernetes

This document outlines the steps to deploy InfluxDB within a Kubernetes cluster, specifically version 1.15.2. Below is a sample YAML configuration file that defines both the InfluxDB deployment and its corresponding service.

InfluxDB Deployment Configuration

apiVersion: apps/v1
kind: Deployment
metadata:
  name: monitoring-influxdb
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: influxdb
  template:
    metadata:
      labels:
        k8s-app: influxdb
        task: monitoring
    spec:
      containers:
      - name: influxdb
        image: registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-influxdb-amd64:v1.5.2
        volumeMounts:
        - mountPath: /data
          name: influxdb-storage
      volumes:
      - name: influxdb-storage
        emptyDir: {}

InfluxDB Service Configuration

apiVersion: v1
kind: Service
metadata:
  name: monitoring-influxdb
  namespace: kube-system
  labels:
    task: monitoring
    kubernetes.io/cluster-service: 'true'
    kubernetes.io/name: monitoring-influxdb
spec:
  ports:
  - port: 8086
    targetPort: 8086
  selector:
    k8s-app: influxdb

Checking Deployment Status

After applying the configuration, you can check the status of your deployment using the following command:

kubectl get deployment -n kube-system

If the pod is not available, you might see output similar to this:

NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
monitoring-influxdb    0/1     0            0           11m

Troubleshooting Pod Issues

If your pod is not running, you can check the logs of the deployment. However, if no pods are available, you can describe the deployment to gather more information:

kubectl describe deployments monitoring-influxdb -n kube-system

To view logs for a specific pod, you can use:

kubectl logs -n kube-system <pod-name>

Replace <pod-name> with the actual name of your InfluxDB pod.

If you encounter a timeout error, ensure that the deployment is correctly configured and that the image is accessible.

Conclusion

This guide provides a basic setup for deploying InfluxDB on Kubernetes. For further customization, consider adjusting resource limits, environment variables, and persistent storage options based on your production needs.