본문 바로가기

컨테이너/Kubernetes

InfluxDB2 on Kubernetes(k8s) / 쿠버네티스 환경에서 InfluxDB2 올리는 법

InfluxDB2 on Kubernetes(k8s) / 쿠버네티스 환경에서 InfluxDB 올리는 방법

- manifest 방식

- 환경 : kubernetes 1.25 버전

 

 

아래의 방법을 차례로 진행하면 10분안에 쿠버네티스 환경에 InfluxDB2를 manifest 방식으로 올릴 수 있다.

 

1. 네임스페이스 monitoring 생성

 

kubectl create namespace monitoring

 

 

2. 기본 네임스페이스를 monitoring 으로 사용

kubectl config set-context --current --namespace=monitoring

 

 

3. pvc 생성

 

pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app: influxdb
  name: influxdb-pvc
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

 

kubectl apply -f pvc.yaml

 

 

4. 시크릿 생성

 

secret.yaml

apiVersion: v1
kind: Secret
metadata:
  name: influxdb-secrets
type: Opaque
stringData:
  INFLUXDB_DB: telegraf
  INFLUXDB_URL: http://influxdb:8086
  INFLUXDB_USER: ${user id}
  INFLUXDB_USER_PASSWORD: ${user pw}

 

k create secret generic influxdb-secrets --from-file=secret.yaml

 

 

5. influxDB2 deployment와 service 생성

 

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: monitoring
  annotations:
  creationTimestamp: null
  generation: 1
  labels:
    app: influxdb
  name: influxdb
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: influxdb
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: influxdb
    spec:
      containers:
      - envFrom:
        - secretRef:
            name: influxdb-secrets
        image: influxdb:2.7.0
        imagePullPolicy: IfNotPresent
        name: influxdb
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /var/lib/influxdb
          name: var-lib-influxdb
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - name: var-lib-influxdb
        persistentVolumeClaim:
          claimName: influxdb-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: influxdb-lb
spec:
  type: LoadBalancer
  ports:
  - name: "http-port"
    protocol: "TCP"
    port: 8086
    targetPort: 8086
  selector:
    app: influxdb

 

kubectl apply -f deployment.yaml

 

 

각각의 pvc / secret / pod / service 가 monitoring 네임스페이스에 생성되었다.

 

 

6. EXTERNAL-IP와 8086 포트를 사용하여 influxDB2 웹에 접근한다.

 

 

 

웹에 접근된 것을 알 수 있다.