apiVersion: v1 kind: Service metadata: name: influxdb spec: type: NodePort selector: app: influxdb ports: - name: web port: 8086 protocol: TCP targetPort: 8086 nodePort: 30201 --- apiVersion: apps/v1 kind: StatefulSet metadata: labels: app: influxdb name: influxdb spec: serviceName: "influxdb" replicas: 1 selector: matchLabels: app: influxdb template: metadata: labels: app: influxdb spec: containers: - name: influxdb image: registry.xslab.co.kr/lecture/influxdb:2.7.6 ports: - name: gui containerPort: 8086 volumeMounts: - name: data mountPath: /root/.influxdbv2 volumeClaimTemplates: - metadata: name: data spec: storageClassName: local-path accessModes: - ReadWriteOnce resources: requests: storage: 10Gi --- apiVersion: batch/v1 kind: Job metadata: name: influxdb-setup spec: template: spec: restartPolicy: Never initContainers: - name: wait-for-influxdb image: busybox command: ['sh', '-c', 'until nc -z -v -w30 influxdb 8086; do echo "Waiting for influxdb..."; sleep 5; done;'] containers: - name: create-credentials image: registry.xslab.co.kr/lecture/influxdb:2.7.6 command: - influx args: - setup - --host - http://influxdb.default.svc.cluster.local:8086 - --bucket - xslab-bucket - --org - xslab-org - --password - xslab1234 - --username - xslab - --token - xslab-token - --force