一、yaml文件

使用的nfs的动态存储类,需要提前搭建。

# cat lotdb.yaml 
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: logs
  namespace: lotdb
spec:
  storageClassName: "nfs-client"
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 5Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: data
  namespace: lotdb
spec:
  storageClassName: "nfs-client"
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: lotdb
  namespace: lotdb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: lotdb
  template:
    metadata:
      labels:
        app: lotdb
    spec:
      containers:
      - name: lotdb
        image: dhub.kubesre.xyz/apache/iotdb:latest
        ports:
        - containerPort: 6667
        volumeMounts:
        - name: logs
          mountPath: /iotdb/logs
        - name: data
          mountPath: /iotdb/data
        livenessProbe:
          tcpSocket:
            port: 6667
          initialDelaySeconds: 40
          periodSeconds: 10
        readinessProbe:
          tcpSocket:
            port: 6667
          initialDelaySeconds: 40
          periodSeconds: 10
      dnsPolicy: "None"
      dnsConfig:
        nameservers:
          - 10.96.0.10
        searches:
          - svc.cluster.local
          - cluster.local
      volumes:
      - name: logs
        persistentVolumeClaim:
          claimName: logs
      - name: data
        persistentVolumeClaim:
          claimName: data

---
apiVersion: v1
kind: Service
metadata:
  name: lotdb
  namespace: lotdb
spec:
  clusterIP: 10.96.201.174
  clusterIPs:
  - 10.96.201.174
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  ports:
  - nodePort: 30925
    port: 6667
    protocol: TCP
    targetPort: 6667
  selector:
    app: lotdb
  type: NodePort


## 部署
# kubectl create ns lotdb
# kubectl apply -f lotdb.yaml 

二、需要修改的地方

三、查看

# docker pull dhub.kubesre.xyz/apache/iotdb:latest

四、测试;

## 登录
# start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root

IoTDB> CREATE DATABASE root.ln

IoTDB> show databases;

IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN

IoTDB>  CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE

IoTDB>  show TIMESERIES

IoTDB> SHOW TIMESERIES root.ln.wf01.wt01.status

IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status) values(100,true);

IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)

IoTDB> SELECT status FROM root.ln.wf01.wt01

IoTDB> SELECT * FROM root.ln.wf01.wt01

IoTDB> SET time_zone=+08:00
Time zone has set to +08:00

IoTDB> SHOW time_zone
Current time zone: Asia/Shanghai

 五、参考;

IoTDB是否支持k8s部署 (Whether support K8S) · Issue #1614 · apache/iotdb · GitHub

iotdb/docker at master · apache/iotdb · GitHub

# https://github.com/apache/iotdb/tree/master/docker
# https://github.com/apache/iotdb/issues/1614

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐