云原生(四十) | Kubernetes篇之整合EFK

Posted Lansonli

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了云原生(四十) | Kubernetes篇之整合EFK相关的知识,希望对你有一定的参考价值。

文章目录

整合EFK

一、安装operator

二、部署ES集群

1、本地访问密码测试

2、部署ingress访问

三、部署kibana

1、访问密码

2、配置Ingress

四、部署FileBeats


整合EFK

部署前预习

 使用Es官方Operator方式

一、安装operator

Quickstart | Elastic Cloud on Kubernetes [2.4] | Elastic

kubectl apply -f https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml

#查看状态
kubectl -n elastic-system logs -f statefulset.apps/elastic-operator

ECK安装的每个组件如何配置

二、部署ES集群

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: es-cluster
  # 可以指定名称空间
spec:
  version: 7.13.1
  nodeSets:
  - name: masters
    count: 3
    config:
      node.roles: ["master"]
      xpack.ml.enabled: true
    volumeClaimTemplates:
    - metadata:
        name: es-master
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi
        storageClassName: "rook-ceph-block"
  - name: data
    count: 4
    config:
      node.roles: ["data", "ingest", "ml", "transform"]
    volumeClaimTemplates:
    - metadata:
        name: es-node
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi
        storageClassName: "rook-ceph-block"

测试访问

Deploy an Elasticsearch cluster | Elastic Cloud on Kubernetes [2.4] | Elastic

1、本地访问密码测试

## elastic的访问
kubectl get secret es-cluster-es-elastic-user -o=jsonpath='.data.elastic' | base64 --decode; echo

## 1、集群内组件访问
###账号 elastic
###密码 t5upEg4l5J37629558659y8Ww
curl -u "elastic:2WC5On8Xio6E767K4x4ph1T7Q54" -k "https://es-cluster-es-http:9200"
curl -u "elastic:2WC5On8Xio6E767K4x4ph1T7Q54" -k "https://10.96.9.9:9200"

## 2、集群本地访问
kubectl port-forward service/es-cluster-es-http 9200
curl -u "elastic:$PASSWORD" -k "https://localhost:9200"

## 3、做成下面的Ingress访问

 

2、部署ingress访问

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: elastic-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    nginx.ingress.kubernetes.io/server-snippet: |
      proxy_ssl_verify off;
spec:
  tls:
  - hosts:
      - elastic.it.com
    secretName: it.com
  rules:
  - host: elastic.it.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: es-cluster-es-http
            port:
              number: 9200

三、部署kibana

apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: kibana
spec:
  version: 7.13.1
  count: 1
  elasticsearchRef:
    name: es-cluster

1、访问密码

kubectl get secret es-cluster-es-elastic-user -o=jsonpath='.data.elastic' | base64 --decode; echo
### 账号  elastic 
### 密码  618FAZBH5a26990707098798798
###登录即可

2、配置Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kibana-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    nginx.ingress.kubernetes.io/server-snippet: |
      proxy_ssl_verify off;
spec:
  tls:
  - hosts:
      - kibana.it.com
    secretName: it.com
  rules:
  - host: kibana.it.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: kibana-kb-http
            port:
              number: 5601

四、部署FileBeats

apiVersion: beat.k8s.elastic.co/v1beta1
kind: Beat
metadata:
  name: beats
spec:
  type: filebeat
  version: 7.13.1
  elasticsearchRef:
    name: es-cluster
  config:
    filebeat.inputs:
    - type: container
      paths:
      - /var/log/containers/*.log
  daemonSet:
    podTemplate:
      spec:
        dnsPolicy: ClusterFirstWithHostNet
        hostNetwork: true
        securityContext:
          runAsUser: 0
        containers:
        - name: filebeat
          volumeMounts:
          - name: varlogcontainers
            mountPath: /var/log/containers
          - name: varlogpods
            mountPath: /var/log/pods
          - name: varlibdockercontainers
            mountPath: /var/lib/docker/containers
        volumes:
        - name: varlogcontainers
          hostPath:
            path: /var/log/containers
        - name: varlogpods
          hostPath:
            path: /var/log/pods
        - name: varlibdockercontainers
          hostPath:
            path: /var/lib/docker/containers

  • 📢博客主页:https://lansonli.blog.csdn.net
  • 📢欢迎点赞 👍 收藏 ⭐留言 📝 如有错误敬请指正!
  • 📢本文由 Lansonli 原创,首发于 CSDN博客🙉
  • 📢停下休息的时候不要忘了别人还在奔跑,希望大家抓紧时间学习,全力奔赴更美好的生活✨ 

以上是关于云原生(四十) | Kubernetes篇之整合EFK的主要内容,如果未能解决你的问题,请参考以下文章

云原生(三十一) | Kubernetes篇之Kubernetes平台基本预装资源

云原生(三十三) | Kubernetes篇之平台存储系统部署

云原生(三十九) | Kubernetes篇之kustomize入门了解

云原生(三十) | Kubernetes篇之应用商店-Helm

云原生(三十六) | Kubernetes篇之Harbor入门和安装

云原生(三十七) | Kubernetes篇之Gitlab入门和安装