在k8s上部署cerebro访问集群外部署的es

news/2024/7/7 5:47:14 标签: elasticsearch, kubernetes, docker

需求:公司购买的是阿里云 Elasticsearch 服务,阿里云提供 kibana 用于可视化控制,而没有 corebro,所以需要在 k8s 集群中安装一个 cerebro,用于查看 k8s 集群外的 Elasticsearch 服务

1 Elastic 信息

查看 elastic 信息

curl -u esuser:123456 http://192.168.1.101:9200/_cat/nodes

2 k8s 集群中设置

2.1 设置一个 external 的 service

本质上是自己手动创建 endpoint,如果外部是域名的话更简单的是用 externalName,不过这个更通用一些

Endpoint 是 kubernetes 中的一个资源对象,存储在 etcd 中,用来记录一个 service 对应的所有 pod 的访问地址,它是根据 service 配置文件中 selector 描述产生的。 Endpoints 是实现实际服务的端点集合。换句话说,service 和 pod 之间的联系是通过 endpoints 实现的。

rancher 设置

在这里插入图片描述

查看 yaml 信息

root@ai:~# kubectl -n bi-dev get svc ali-external-elastic-svc -o yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    field.cattle.io/creatorId: u-sr2hlj3sdd
    field.cattle.io/ipAddresses: '["192.168.1.101"]'
    field.cattle.io/targetDnsRecordIds: "null"
    field.cattle.io/targetWorkloadIds: "null"
  creationTimestamp: "2022-07-22T10:25:23Z"
  labels:
    cattle.io/creator: norman
  name: ali-external-elastic-svc
  namespace: bi-dev
  resourceVersion: "792651920"
  selfLink: /api/v1/namespaces/log/services/ali-external-elastic-svc
  uid: 9885e2f8-09a8-11ed-b08a-00163e104bcb
spec:
  clusterIP: None
  ports:
  - name: external-elastic-port
    port: 9200
    protocol: TCP
    targetPort: 9200
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
root@ai:~#

查看 ep 信息

root@ai:~# kubectl -n bi-dev get ep ali-external-elastic-svc -o yaml
apiVersion: v1
kind: Endpoints
metadata:
  creationTimestamp: "2022-07-22T10:25:23Z"
  labels:
    cattle.io/creator: norman
  name: ali-external-elastic-svc
  namespace: bi-dev
  ownerReferences:
  - apiVersion: v1
    controller: true
    kind: Service
    name:  ali-external-elastic-svc
    uid: 9885e2f8-09a8-11ed-b08a-00163e104bcb
  resourceVersion: "792651923"
  selfLink: /api/v1/namespaces/log/endpoints/ali-external-elastic-svc
  uid: 98877a10-09a8-11ed-9356-00163e12ec0c
subsets:
- addresses:
  - ip: 192.168.1.101
  ports:
  - name: external-elastic-port
    port: 9200
    protocol: TCP
root@ai:~#

2.2 发布 cerebro

cerebro 配置文件信息

root@ai:~# kubectl -n bi-dev get cm cerebro-application -o yaml
apiVersion: v1
data:
  application.conf: |
    es = {
      gzip = true
    }
    auth = {
      type: basic
      settings {
        username = "admin"
        password = "123456"
      }
    }
    hosts = [
      {
        host = "http:// ali-external-elastic-svc:9200"  # external service 地址
        name = "ali-cerebro"
        auth = {
          username = "esuser"
          password = "123456"
        }
      }
    ]
kind: ConfigMap
metadata:
  creationTimestamp: "2022-07-22T10:18:32Z"
  name: cerebro-application
  namespace: bi-dev
  resourceVersion: "792652495"
  selfLink: /api/v1/namespaces/log/configmaps/cerebro-application
  uid: a32a8ec2-09a7-11ed-b292-00163e0b609f
root@ai:~#

cerebro 的 Deployment、svc、ingress 信息

cat <<EOF | kubectl apply -f - -n bi-dev
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: cerebro
  name: cerebro
  namespace: bi-dev
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cerebro
  template:
    metadata:
      labels:
        app: cerebro
      name: cerebro
    spec:
      containers:
      - image: lmenezes/cerebro:0.8.3
        imagePullPolicy: IfNotPresent
        name: cerebro
        resources:
          limits:
            cpu: 1
            memory: 1Gi
          requests:
            cpu: 1
            memory: 1Gi
        volumeMounts:
          - name: cerebro-conf
            mountPath: /etc/cerebro
      volumes:
      - name: cerebro-conf
        configMap:
          name: cerebro-application

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: cerebro
  name: cerebro
  namespace: bi-dev
spec:
  ports:
  - port: 9000
    protocol: TCP
    targetPort: 9000
  selector:
    app: cerebro
  type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: cerebro
  namespace: bi-dev
spec:
  rules:
  - host: ali-cerebro.test.cn
    http:
      paths:
      - backend:
         serviceName: cerebro
         servicePort: 9000
        path: /
EOF

查看 pod

root@ai:~# kubectl -n bi-dev get pod |grep cerebro
cerebro-56ddd6984d-p9jch           1/1     Running            0          17h
root@ai:~#

2.3 域名解析

解析域名到 k8s 集群的 ingress

ali-cerebro.test.cn  A 1.1.1.1

接下来访问域名即可


http://www.niftyadmin.cn/n/1570294.html

相关文章

kubeadm修改pod数(默认值110)

背景&#xff1a;k8s 默认每个 node 可以启动 110 个 pod&#xff0c;而这个数字可以自行&#xff08;依据机器配置&#xff09;修改 查看 kubelet 的启动文件 rootsh-cpu035:~# systemctl status kubelet ● kubelet.service - Kubernetes KubeletLoaded: loaded (/etc/syst…

docker 夯住,无法启动

背景&#xff1a;IDC 机架调整&#xff0c;master 机器挪动之后&#xff0c;docker 夯住&#xff0c;无法启动 有一些警告信息 your kernel does not support swap memory limit Your kernel does not support cgroup rt period Your kernel does not support cgroup rt runti…

Jenkins部署与基础配置(2)

1 Jenkinsfile 可以对 jenkins pipline 中的指令进行备份 避免 pipline 中配置被误操作 可以对 jenkinsfile 进行版本控制 [rootjenkins-master ~]# cd /opt/ [rootjenkins-master /opt]# git clone http://172.18.8.9/baichuan/app1.git Cloning into app1... Username fo…

18张图带你入门最新版JumpServer

环境要求 docker-cePython3mysql5.6Redis 1 Ubuntu 安装 docker-ce 环境 参考文档 https://docs.docker.com/engine/install/debian/ https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/卸载旧版 sudo apt-get remove docker docker-engine docker.io containerd runc…

3.linux中获得帮助及输入输出管理

1.命令行获得帮助 whatis whatis rm ##查看命令的基本用途 ##查看过程中出现 rm: nothing appropriate. 1.表示要查看内容没有帮助 2.系统帮助数据未更新用mandb命令更新 "注意&#xff1a;当执行whatis命令出现 nothing appropriate 时大多数情况是因为系统的帮…

8.Linux系统中的软件管理

1.Linux中软件包的类型 1.DEB #UBlinux DEBlinux 2.RPM #redhat centOS fadora 3.bz2|gz|xz #1.需要源码安装需要编译 #2.绿色软件&#xff0c;直接可用 #ntfs-3g_ntfsprogs-2017.3.23.tgz 需要编译 "configure" #Firefox-la…

9. Linux下的虚拟化部署

kvm安装条件 1.inter cpu ----> vmx 2.amd cpu -------> svm kvm虚拟化安装 dnf group install "Virtualization Client" "Virtualization Hypervisor" "Virtualization Tools" -y Virtualization Client ##虚拟化客户端 Virtualization T…

1.Java概述

1、计算机概述 计算机&#xff08;Computer&#xff09;全称&#xff1a;电子计算机&#xff0c;俗称电脑。是一种能够按照程序运行&#xff0c;自动、高速处理海量数据的现代化智能电子设备。什么是硬件? 计算机硬件&#xff08;Computer Hardware&#xff09;是指计算机…