我在docker上部署InfluxDB v 1.8.10使用命令:
docker run --name influxdb -t
-e INFLUXDB_HTTP_AUTH_ENABLED=“true”
-e INFLUXDB_DB=“mydatabase”
-e INFLUXDB_USER=“user”
-e INFLUXDB_USER_PASSWORD=“user”
-e INFLUXDB_ADMIN_USER=“admin”
-e INFLUXDB_ADMIN_PASSWORD=“admin”
–restart unless-stopped
-d influxdb:1.8.10
当我连接时,我看到新的管理员用户已创建。现在我想将其部署在 Kubernetes 上,这是我的代码:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: influxdb
namespace: mon-grafana
spec:
serviceName: influxdb
replicas: 3
selector:
matchLabels:
app: influxdb
template:
metadata:
labels:
app: influxdb
spec:
containers:
- name: influxdb
image: influxdb:1.8.10
ports:
- containerPort: 8086
name: influxdb
protocol: TCP
resources:
requests:
cpu: 250m
memory: 500Mi
limits:
cpu: 2
memory: 500Mi
env:
- name: INFLUXDB_HTTP_AUTH_ENABLED
value: "true"
- name: INFLUXDB_DB
value: "mydatabase"
- name: INFLUXDB_USER
value: "user"
- name: INFLUXDB_USER_PASSWORD
value: "user"
- name: INFLUXDB_ADMIN_USER
value: "admin"
- name: INFLUXDB_ADMIN_PASSWORD
value: "admin"
volumeMounts:
- name: pvc-influxdb
mountPath: /var/lib/influxdb
- name: influxdb-config
mountPath: "/etc/influxdb/influxdb.conf"
subPath: influxdb.conf
securityContext:
allowPrivilegeEscalation: false
volumes:
- name: influxdb-config
configMap:
name: configmap
items:
- key: influxdb.conf
path: influxdb.conf
volumeClaimTemplates:
- metadata:
name: pvc-influxdb
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 2Gi
这是我的influuxdb配置文件文件:
root@influxdb-0:/# cat /etc/influxdb/influxdb.conf
reporting-enabled = false
[meta]
dir = “/var/lib/influxdb/meta”
[data]
dir = “/var/lib/influxdb/data”
wal-dir = “/var/lib/influxdb/wal”
max-series-per-database = 1000000
max-values-per-tag = 100000
index-version = “tsi1”
max-index-log-file-size = “100k”
[http]
log-enabled = false
enabled = true
bind-address = “0.0.0.0:8086”
https-enabled = false
flux-enabled = true
但未创建管理员用户,当我尝试连接时收到此错误:
root@influxdb-0:/# influx -username admin -password admin 已连接到 http://localhost:8086 版本 1.8.10 InfluxDB shell 版本:1.8.10
显示数据库;ERR:授权查询错误:首先创建管理员用户或禁用身份验证警告:此错误可能是由于未设置数据库造成的。请使用命令“use”设置数据库。