Skip to content

Instantly share code, notes, and snippets.

@fntlnz
Last active November 7, 2024 17:21
Show Gist options
  • Save fntlnz/31b3acafbdb26607d3d3733d880f1bce to your computer and use it in GitHub Desktop.
Save fntlnz/31b3acafbdb26607d3d3733d880f1bce to your computer and use it in GitHub Desktop.
InfluxDB and Chronograf deployed in Kubernetes

InfluxDB and Chronograf in Kubernetes

  1. Create the namespace
kubectl create ns monitoring
  1. Deploy influxdb
kubectl apply -f influxdb.yml
  1. Deploy chronograf
kubectl apply -f chronograf.yml
---
# Section: chronograf configmap
apiVersion: v1
kind: ConfigMap
metadata:
namespace: monitoring
name: chronograf
labels:
app: chronograf
component: chronograf
data:
monitor.src: |-
{
"id": "5000",
"name": "internal",
"url": "http://{{ .INFLUXDB_SERVICE_HOST }}:{{ .INFLUXDB_SERVICE_PORT}}",
"type": "influx",
"insecureSkipVerify": false,
"default": true,
"telegraf": "cloud",
"organization": "influx"
}
---
# Section: chronograf service
apiVersion: v1
kind: Service
metadata:
namespace: monitoring
name: chronograf
spec:
ports:
- port: 80
targetPort: 8888
name: server
selector:
app: chronograf
---
# Section: chronograf deployment
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: monitoring
name: chronograf
labels:
app: chronograf
component: chronograf
spec:
strategy:
type: "Recreate"
selector:
matchLabels:
app: chronograf
replicas: 1
template:
metadata:
name: chronograf
labels:
app: chronograf
component: chronograf
spec:
containers:
- name: chronograf
image: quay.io/influxdb/chronograf:nightly
env:
- name: RESOURCES_PATH
value: "/usr/share/chronograf/resources"
- name: LOG_LEVEL
value: "error"
ports:
- containerPort: 8888
name: server
volumeMounts:
- name: data
mountPath: /var/lib/chronograf
- name: config
mountPath: /usr/share/chronograf/resources
volumes:
- name: data
persistentVolumeClaim:
claimName: chronograf
- name: config
configMap:
name: chronograf
---
# Section: chronograf service
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
namespace: monitoring
name: chronograf
labels:
app: chronograf
component: chronograf
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
---
# vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^#\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':
# Section: influxdb service
apiVersion: v1
kind: Service
metadata:
namespace: monitoring
name: influxdb
labels:
component: influxdb
app: influxdb
spec:
clusterIP: None
ports:
- port: 8086
name: server
selector:
component: influxdb
publishNotReadyAddresses: true
---
# Section: influxdb statefulset
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: monitoring
name: influxdb
labels:
component: influxdb
app: influxdb
spec:
serviceName: influxdb
selector:
matchLabels:
component: influxdb
replicas: 1
template:
metadata:
name: influxdb
labels:
component: influxdb
app: influxdb
spec:
containers:
- name: influxdb
image: docker.io/influxdb:1.6
lifecycle:
postStart:
exec:
command:
- /bin/sh
- "-c"
- until curl -s http://localhost:8086/ping; do sleep 1; done; influx -execute "CREATE DATABASE \"${MONITOR_DATABASE}\" WITH DURATION 30d NAME ${MONITOR_RP}"
env:
- name: INFLUXDB_IFQL_ENABLED
value: "true"
- name: INFLUXDB_LOGGING_LEVEL
value: "error"
- name: INFLUXDB_HTTP_LOG_ENABLED
value: "false"
- name: MONITOR_RP
value: "monthly"
- name: MONITOR_DATABASE
value: "monitor"
volumeMounts:
- name: data
mountPath: /var/lib/influxdb
ports:
- containerPort: 8086
name: server
- containerPort: 8082
name: ifql
volumeClaimTemplates:
- metadata:
namespace: monitoring
name: data
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 10Gi
---
# vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^#\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment