k8s部署efk

环境简介:

kubernetes: v1.22.2

helm: v3.12.0

elasticsearch: 8.8.0 chart包:19.10.0

fluentd: 1.16.2 chart包: 5.9.4

kibana: 8.2.2 chart包:10.1.9

整体架构图:

一、Elasticsearch安装配置

1.1、es角色分类

  • 准主节点:主节点负责集群级别的轻量级操作,包括创建和删除索引、跟踪集群中的所有节点以及分片分配等功能
  • 数据节点:持有索引分片并负责处理数据相关的操作,例如CRUD、搜索和聚合等I/O及CPU密集型的任务。
  • 摄取节点:也称为客户端节点,它负责接收客户端发来的REST请求,并根据内部预置的一个或多个由摄取处理器组成的预处理管道完成数据的预处理,之后路由给数据节点
  • 协调节点:禁用了主节点、数据节点及摄取节点等功能后的节点即为协调节点,它可以完成路由请求、处理搜索结果合并(reduce阶段),以及协调批量索引(bulk indexing)等任务

1.2、修改values.yml

yaml 复制代码
global:
  storageClass: "nfs-client"   #创建pvc,存储日志

clusterDomain: cluster.local   #k8s集群域名
clusterName: elastic           #elasticsearch集群名称,主要用来子节点识别集群的标识

master:
  replicaCount: 2   #主节点实例数量,保持默即可
coordinating:
  replicaCount: 2   #协调节点实例数量,保持默即可
data:
  replicaCount: 2   #数据节点实例数量,保持默即可
ingest:
  enabled: true
  replicaCount: 2   #摄取节点实例数量,保持默即可

1.3、安装验证

shell 复制代码
helm install my-elasticsearch ./elasticsearch


kubectl  exec -it my-elasticsearch-master-0 bash

#查询集群的工作状态
curl http://my-elasticsearch-coordinating-hl.default.svc:9200/_cluster/health?pretty
  "cluster_name" : "elastic",
  "status" : "green",         #有green、yelllow、red三种状态
  "timed_out" : false,
  "number_of_nodes" : 8,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 19,
  "active_shards" : 38,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

#查看ES已经生产的索引
curl http://my-elasticsearch-coordinating-hl.default.svc:9200/_cat/indices

二、fluentd安装配置

2.1、Fluentd角色

两种不同角色:Fluent Bit -- 转发器(forwarder),Fluentd-- 聚合器(aggregator)

2.2、fuentd数据流

  • Input插件:Tail(文件数据源)、Systemd、Syslog、TCP和 MQTT等。
  • 解析器插件:Logfmt、LTSV和Regular Expression等。
  • 过滤器插件:Grep、Kubernetes、Record Modifier和Lua等。
  • Output插件:Forward、Kafka、Elasticsearch、File、 InfluxDB和TCP等。

2.3、修改values.yaml

yaml 复制代码
global:
  storageClass: "nfs-client"

  tolerations:                             #添加污点容忍
    - key: node-role.kubernetes.io/master
      effect: NoSchedule

#转发器
forwarder:
  configMapFiles:
    fluentd.conf: |
    fluentd-inputs.conf: |


#聚合器配置
aggregator:
    fluentd-output.conf: |
      # Throw the healthcheck to the standard output
      <match fluentd.healthcheck>
        @type stdout
      </match>

      # Send the logs to the standard output
      <match **>
        @type stdout
        Name elastic
        Match kube.*
        Host my-elasticsearch-coordinating-hl.default.svc
        Logstash_Prefix k8s-cluster  							# Logstash兼容日志格式的索引前缀
      </match>

三、kinaba安装配置

3.1、修改values.yml

shell 复制代码
global:
  storageClass: "nfs-client"

image:
  registry: registry.cn-hangzhou.aliyuncs.com/other_ns
  repository: kibana
  tag: 8.2.2-debian-10-r0

#服务对外访问为nodeport
service:
  type: NodePort
  nodePorts:
    http: "30004"
  

elasticsearch:
  hosts:
    - my-elasticsearch-coordinating-hl.default.svc.cluster.local    #配置es数据源
  port: "9200"

3.2、常用方法

查看ES索引: Managment -----> Data -----> Index Managen

相关推荐
遨游DATA42 分钟前
容器退出码 126 排查:静态资源镜像层如何改写目录权限
linux·docker·kubernetes·文件权限
骑着蜗牛撵大象3276 小时前
K8s Operator 排障:调谐循环、Finalizer 与状态漂移的 4 个坑
java·kubernetes·dubbo·operator·finalizer·状态漂移
吴声子夜歌7 小时前
Kubernetes进阶实战——Ingress与服务发布(二)
云原生·容器·kubernetes
Decay__10 小时前
配置与密钥管理 —— ConfigMap、Secret、热更新边界与 KMS 加密
运维·云原生·容器·kubernetes·k8s
雾时之林10 小时前
K8S 的认证与安全
docker·容器·kubernetes
雾时之林10 小时前
K8S HPA 自动扩缩容与 StatefulSet 有状态应用
java·容器·kubernetes
吴声子夜歌20 小时前
Kubernetes进阶实战——Pod资源调度(三)
云原生·容器·kubernetes
吴声子夜歌1 天前
Kubernetes进阶实战——Kubernetes系统扩展(一)
kubernetes
吴声子夜歌1 天前
Kubernetes进阶实战——网络模型与网络策略(四)
网络·kubernetes
吴声子夜歌1 天前
Kubernetes进阶实战——网络模型与网络策略(二)
网络·容器·kubernetes