Giter VIP home page Giter VIP logo

k8s-efk's Introduction

k8s-EFK 国内安装,持久化存储

官网EFK基础配置

https://github.com/kubernetes/kubernetes.git

由于github上得镜像Dockerfile和实际有出入,手动编译无法执行,还是通过官方的镜像进行操作,但国内无法下载,所以通过hub.docker.com上同步的Google镜像仓库进行下载: 涉及镜像:

es: mirrorgooglecontainers/elasticsearch:v6.3.0

fluentd-es: mirrorgooglecontainers/fluentd-elasticsearch:v2.4.0

下面是官方yaml改动说明(namesapces不做过多说明,可自定义)

# es-statefulset.yaml 改动
        volumeMounts:
        - name: elasticsearch-logging
          mountPath: /data # 官方镜像默认数据存位置
	# 部分内置变量
        env:
        - name: "NAMESPACE"
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: cluster.name
          value: k8s-logs
        - name: ES_JAVA_OPTS
          value: "-Xms512m -Xmx512m"
	# 官方yaml文件未做持久化存储,禁用
#      volumes:
#      - name: elasticsearch-logging
#        emptyDir: {}
      # Elasticsearch requires vm.max_map_count to be at least 262144.
      # If your OS already sets up this number to a higher value, feel free
      # to remove this init container.
      initContainers:
      - image: alpine:3.6
        command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"]
        name: elasticsearch-logging-init
        securityContext:
          privileged: true
#StatefulSet 通过volumeClaimTemplates 挂载存储,可以是hostpath、nfs等
  volumeClaimTemplates:
  - metadata:
      name: elasticsearch-logging
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: efk # 重要内容,创建pv时的storageClassName字段,需一一匹配,切不需要创建PVC,不需要创建PVC,不需要创建PVC,重要的事情说三遍
      resources:
        requests:
          storage: 10Gi

ES 持久化存储配置(下面是hostpath测试)

这边是创建了3个ES节点,所以对应挂载3个PV PV重点:storageClassName 需要与statefulset一致

apiVersion: v1
kind: PersistentVolume
metadata:
  name: elasticsearch-logging-0
  labels:
    name: efk
spec:
  storageClassName: efk
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /data/es/0
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: elasticsearch-logging-1
  labels:
    name: efk
spec:
  storageClassName: efk
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /data/es/1
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: elasticsearch-logging-2
  labels:
    name: efk
spec:
  storageClassName: efk
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /data/es/2

fluentd-es配置无需改动。注意镜像即可

kibana 配置,特别说明下,有点坑

#kibana-deployment.yaml
        env:
          - name: ELASTICSEARCH_URL
            value: http://elasticsearch-logging:9200
#          - name: SERVER_BASEPATH  # 此变量是个小坑,非必要参数,这边最后通过Ingress访问Kibana服务即可
#            value: /api/v1/namespaces/kube-system/services/kibana-logging/proxy

k8s-efk's People

Contributors

symenghuan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.