influxdb2.0 beta填坑

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了influxdb2.0 beta填坑相关的知识,希望对你有一定的参考价值。

参考技术A 其中networks、label配置的是traefik反向代理的标签,将 influxdb.api.mydomain.com 这个域名代理到容器内部的9999端口,可以去除,但是要做9999的端口映射,用于访问influxdb。如果需要进行数据持久化,可以将容器内/root/.influxdbv2挂载到宿主机,参考 官方建议k8s配置文件 。

默认在9999端口提供webUI以及API服务,安装成功后直接访问 http://localhost:9999 ,可以在前面配置反向代理,如traefik、nginx等,但是注意必须要代理在根路径下,否则无法加载webUI的静态文件。相关 issue
首次进入登录页会提醒设置账号密码:

在2.0版本升级后,数据操作的api都改为restful的webAPI,改变很大,所以Python的SDK也重做了,区别于1.x版本。
对写入数据的格式也有比较大的改变。

21,k8s 监控之Heapster+InfluxDB+Grafana:

Heapster+InfluxDB+Grafana:

[root@centos7 ~]# cat influxdb.yaml 
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: monitoring-influxdb
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: influxdb
    spec:
      containers:
      - name: influxdb
        image: registry.cn-hangzhou.aliyuncs.com/google-containers/heapster-influxdb-amd64:v1.1.1
        volumeMounts:
        - mountPath: /data
          name: influxdb-storage
      volumes:
      - name: influxdb-storage
        emptyDir: {}

---

apiVersion: v1
kind: Service
metadata:
  labels:
    task: monitoring
    kubernetes.io/cluster-service: ‘true‘
    kubernetes.io/name: monitoring-influxdb
  name: monitoring-influxdb
  namespace: kube-system
spec:
  ports:
  - port: 8086
    targetPort: 8086
  selector:
    k8s-app: influxdb
[root@centos7 ~]# 
[root@centos7 ~]# kubectl apply -f influxdb.yaml




[root@centos7 ~]# 
[root@centos7 ~]# cat heapster.yaml 
apiVersion: v1
kind: ServiceAccount
metadata:
  name: heapster
  namespace: kube-system

---

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: heapster
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
subjects:
  - kind: ServiceAccount
    name: heapster
    namespace: kube-system

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: heapster
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: heapster
    spec:
      serviceAccountName: heapster
      containers:
      - name: heapster
        image: registry.cn-hangzhou.aliyuncs.com/google-containers/heapster-amd64:v1.4.2
        imagePullPolicy: IfNotPresent
        command:
        - /heapster
        - --source=kubernetes:https://kubernetes.default
        - --sink=influxdb:http://monitoring-influxdb:8086

---

apiVersion: v1
kind: Service
metadata:
  labels:
    task: monitoring
    kubernetes.io/cluster-service: ‘true‘
    kubernetes.io/name: Heapster
  name: heapster
  namespace: kube-system
spec:
  ports:
  - port: 80
    targetPort: 8082
  selector:
    k8s-app: heapster
[root@centos7 ~]# 
[root@centos7 ~]# 
[root@centos7 ~]# kubectl apply -f heapster.yaml


[root@centos7 ~]# cat grafana.yaml 
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: monitoring-grafana
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: grafana
    spec:
      containers:
      - name: grafana
        image: registry.cn-hangzhou.aliyuncs.com/google-containers/heapster-grafana-amd64:v4.4.1
        ports:
          - containerPort: 3000
            protocol: TCP
        volumeMounts:
        - mountPath: /var
          name: grafana-storage
        env:
        - name: INFLUXDB_HOST
          value: monitoring-influxdb
        - name: GF_AUTH_BASIC_ENABLED
          value: "false"
        - name: GF_AUTH_ANONYMOUS_ENABLED
          value: "true"
        - name: GF_AUTH_ANONYMOUS_ORG_ROLE
          value: Admin
        - name: GF_SERVER_ROOT_URL
          value: /
      volumes:
      - name: grafana-storage
        emptyDir: {}

---

apiVersion: v1
kind: Service
metadata:
  labels:
    kubernetes.io/cluster-service: ‘true‘
    kubernetes.io/name: monitoring-grafana
  name: monitoring-grafana
  namespace: kube-system
spec:
  type: NodePort
  ports:
  - port : 80
    targetPort: 3000
  selector:
    k8s-app: grafana
[root@centos7 ~]# 
[root@centos7 ~]# 
[root@centos7 ~]# kubectl apply -f grafana.yaml

  

以上是关于influxdb2.0 beta填坑的主要内容,如果未能解决你的问题,请参考以下文章

Influxdb2.0文档翻译——开始使用InfluxDB

influxd安装

InfluxDB 2.0 中的存储桶、度量和保留策略之间的逻辑联系是啥?

influxdb 2.0 证书验证失败:证书已过期 (_ssl.c:1129)

Node学习笔记:gulp+express+io.socket部署angularJs2(填坑篇)

访问 InfluxDB 2.0 记录中的多个字段