apiVersion: v1
kind: Service
metadata:
  name: influxdb
  labels:
    app: influxdb
spec:
  type: ClusterIP 
  ports:
  - port: 8086
    targetPort: 8086
    name: http
  selector:
    app: influxdb
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: influxdb
  labels:
    app: influxdb
spec:
  selector:
    matchLabels:
      app: influxdb
  strategy:
    type: Recreate    
  template:
    metadata:
      labels:
        app: influxdb
    spec:
      restartPolicy: Always      
      containers:
      - name: influxdb
        image: influxdb-image
        imagePullPolicy: Never
        ports:
        - containerPort: 8086
        volumeMounts:
          - mountPath: "/var/lib/influxdb"
            name: influxdb-data
          - name: influxdb
            mountPath: /etc/influxdb/influxdb.conf
            subPath: influxdb.conf
            readOnly: true
      volumes:
      - name: influxdb-data
        persistentVolumeClaim:
          claimName: influxdb-data-disk
      - name: influxdb
        configMap:
          name: influxdb
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: influxdb
  labels:
    app: influxdb
data:
  influxdb.conf: |
    bind-adress="172.17.0.1:8088"
    [meta]
      dir="/var/lib/influxdb/meta"
    [data]
      dir="/var/lib/influxdb/data"
      wal-dir = "/var/lib/influxdb/wal"
      trace-logging-enable=true
    [http]
      bind-addres=":8086"
      log-enabled=true
    [[graphite]]
      database="telegraf"
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: influxdb-data
  labels:
    type: local
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 1Gi
  hostPath:
    path: "/mnt/influx"
    type: DirectoryOrCreate
  claimRef:
    name: influxdb-data-disk
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: influxdb-data-disk
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi