helm安裝EFK


原文地址: 點這里

 

 0. 簡介

  之前相信大家聽過ELK工具棧,E: elasticsearch、L:logstash、K: kabana,其中logstash的缺點太重量級,Logstash性能低、資源消耗比較多、並且不支持消息隊列緩存及存在數據丟失等問題,隨后就有Fluentd出現,相比它更易用、資源消耗更少、性能更高,在數據處理上更高效可靠,受到企業歡迎,成為logstash的替代方案,亞馬遜稱其為數據收集的最佳方案EFK。
 
1. 系統環境
  • 系統版本號CentOS 7.6
  • docker Client版本號18.09.7, Server版本號18.09.7
  • k8s版本號v1.16.2
  • helm Client版本號v2.13.1,Server版本號v2.13.1

 

 確認helm鏡像源並更新鏡像倉庫

[root@ops1 test]# helm repo add stable http://mirror.azure.cn/kubernetes/charts/   
[root@ops1 test]# helm repo list
NAME            URL                                                
local           http://127.0.0.1:8879/charts                       
stable          http://mirror.azure.cn/kubernetes/charts/          
incubator       http://mirror.azure.cn/kubernetes/charts-incubator/
[root@ops1 test]# helm repo update
[root@ops1 test]# kubectl create namespace efk

 

 

2. 快速安裝EFK
注意我用的存儲是storageClass "nfs2",請注意修改。
 
2.1 helm安裝elasticsearch
[root@ops1 test]# cat <<EOF> elasticsearch-values.yaml
image:
  repository: "docker.elastic.co/elasticsearch/elasticsearch-oss"
  # repository: "registry.cn-beijing.aliyuncs.com/wangzt/k8s/elasticsearch-oss:6.7.0" 個人鏡像倉庫
  tag: "6.7.0"
client:
  serviceType: "NodePort"
  httpNodePort: 30920
master:
  persistence:
    enabled: true  #  elasticsearch-master使用pvc永久存儲,如果是測試,可以換成false
    storageClass: "nfs2"
data:
  persistence:
    enabled: true  #elasticsearch-data使用pvc永久存儲,如果是測試,可以換成false
    storageClass: "nfs2"
EOF
[root@ops1 test]# helm install --name elasticsearch -f elasticsearch-values.yaml  \
                --namespace=efk --version=1.32.4 stable/elasticsearch 
[root@ops1 test]# kubectl get all -n efk
# 等到全部pod顯示正常后,訪問k8s工作節點
[root@ops1 test]# curl http://127.0.0.1:30920/
{
  "name" : "elasticsearch-client-65bfdd647c-kl9zb",
  "cluster_name" : "elasticsearch",
   ...
  "tagline" : "You Know, for Search"
}

 

2.2 helm安裝fluented
# 配置可不加,我是為了日志量太大,和添加監控顯示的
[root@ops1 test]# cat <<EOF> fluentd-values.yaml
image:
  repository: gcr.io/google-containers/fluentd-elasticsearch # 默認地址可能不可用
  # repository: registry.cn-beijing.aliyuncs.com/wangzt/kubernetes/fluentd-elasticsearch
elasticsearch:
  buffer_chunk_limit: 32M  # 內存緩沖區
service:  #啟動監控monitor-agent
  type: NodePort
  ports:
    - name: "monitor-agent"
      port: 24231
env:      
  OUTPUT_BUFFER_CHUNK_LIMIT: "32M" # 設置buffer緩存區大小
podAnnotations: # 讓prometheus監控monitor-agent
  prometheus.io/scrape: "true"
  prometheus.io/port: "24231"
tolerations:  #監控master
  - key: node-role.kubernetes.io/master
    operator: Exists
    effect: NoSchedule
EOF
[root@ops1 test]# helm install --name fluentd-elasticsearch -f fluentd-values.yaml --namespace=efk --version=2.0.7 stable/fluentd-elasticsearch 
[root@ops1 test]# kubectl get pod -n efk | grep fluentd
#等服務全部正常后,可以看到有索引產生
[root@ops1 test]# curl http://127.0.0.1:30920/_cat/indices
green open logstash-2020.03.18 om-LUsRXQUGcBfww4ioa3w 5 1  26071 0  27.9mb  13.9mb
green open logstash-2020.03.16 3RAWut3DQkqlLWgQu9DxSQ 5 1  22269 0  23.7mb  11.8mb

 

2.3 helm安裝kibana
[root@ops1 test]# cat <<EOF> kibana-values.yaml
files:
  kibana.yml:
    elasticsearch.hosts: http://elasticsearch-client:9200
service:
  type: NodePort 
  nodePort: 30922    
persistentVolumeClaim:
  enabled: true  # 如果不使用pvc永久存儲,只做測試就改為false
  storageClass: "nfs2"      
EOF
[root@ops1 test]# helm install --name kibana -f kibana-values.yaml  --namespace=efk --version=3.2.6 stable/kibana  
[root@ops1 test]# kubectl get pod -n efk | grep kibana
kibana-7bf95fb48-nb2z4                  1/1     Running            0          36s 

 

2.4等待服務都起來,訪問界面即可
 
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM