k8s部署grafana beyla实现app应用服务依赖图可观测

简介: k8s部署grafana beyla实现app应用服务依赖图可观测

k8s部署grafana beyla
OS:
Static hostname: test
Icon name: computer-vm
Chassis: vm
Machine ID: 22349ac6f9ba406293d0541bcba7c05d
Boot ID: 83bb7e5dbf27453c94ff9f1fe88d5f02
Virtualization: vmware
Operating System: Ubuntu 22.04.4 LTS
Kernel: Linux 5.15.0-105-generic
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware Virtual Platform

kubespray version:
2.25.0

kubernetes version:
1.29.5

部署测试用nginx
cat > nginx.yaml <<EOF
kind: Deployment
apiVersion: apps/v1
metadata:
name: docs
spec:
replicas: 2
selector:
matchLabels:
app: docs
template:
metadata:
labels:
app: docs
spec:
containers:

    - name: docs-server
      image: httpd:latest
      ports:
        - containerPort: 80
          protocol: TCP
          name: http

apiVersion: v1
kind: Service
metadata:
name: docs
spec:
selector:
app: docs
ports:

- protocol: TCP
  port: 80

kind: Deployment
apiVersion: apps/v1
metadata:
name: website
spec:
replicas: 2
selector:
matchLabels:
app: website
template:
metadata:
labels:
app: website
spec:
containers:

    - name: website-server
      image: dockerhub.timeweb.cloud/httpd:latest
      ports:
        - containerPort: 80
          protocol: TCP
          name: http

apiVersion: v1
kind: Service
metadata:
name: website
spec:
selector:
app: website
ports:

- protocol: TCP
  port: 80

EOF

创建

kubectl apply -f nginx.yaml

转发端口

kubectl port-forward services/website 8080:80
kubectl port-forward services/docs 8081:80

部署grafana beyla

创建命名空间

kubectl create namespace beyla

创建serviceaccount

cat > beyla-serviceaccount.yaml <<EOF
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: beyla

name: beyla

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: beyla
rules:

  • apiGroups: ["apps"]
    resources: ["replicasets"]
    verbs: ["list", "watch"]
  • apiGroups: [""]
    resources: ["pods"]
    verbs: ["list", "watch"]

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: beyla
subjects:

  • kind: ServiceAccount
    name: beyla
    namespace: beyla
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: beyla
    EOF

kubectl apply -f beyla-serviceaccount.yaml

cat > beyla.yaml <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
namespace: beyla
name: beyla-config
data:
beyla-config.yml: |

# this is required to enable kubernetes discovery and metadata
attributes:
  kubernetes:
    enable: true
# this will provide automatic routes report while minimizing cardinality
routes:
  unmatched: heuristic
# let's instrument only the docs server
discovery:
  services:
    - k8s_deployment_name: "^docs$"
    # uncomment the following line to also instrument the website server
    # - k8s_deployment_name: "^website$"

apiVersion: apps/v1
kind: DaemonSet
metadata:
namespace: beyla
name: beyla
spec:
selector:
matchLabels:
instrumentation: beyla
template:
metadata:
labels:
instrumentation: beyla
spec:
serviceAccountName: beyla
hostPID: true # mandatory!
containers:

    - name: beyla
      image: dockerhub.timeweb.cloud/grafana/beyla:1.2
      imagePullPolicy: IfNotPresent
      securityContext:
        privileged: true # mandatory!
        readOnlyRootFilesystem: true
      volumeMounts:
        - mountPath: /config
          name: beyla-config
        - mountPath: /var/run/beyla
          name: var-run-beyla
      env:
        - name: BEYLA_CONFIG_PATH
          value: "/config/beyla-config.yml"
        - name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
          value: "http://10.1.1.71:4318/v1/traces"
        - name: OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
          value: "http/protobuf"

- name: OTEL_EXPORTER_OTLP_HEADERS

valueFrom:

secretKeyRef:

name: grafana-credentials

key: otlp-headers

  volumes:
    - name: beyla-config
      configMap:
        name: beyla-config
    - name: var-run-beyla
      emptyDir: {}

EOF

kubectl apply -f beyla.yaml

安装grafana
apt-get install -y adduser libfontconfig1 musl
wget https://dl.grafana.com/oss/release/grafana_10.4.2_amd64.deb
dpkg -i grafana_10.4.2_amd64.deb
systemctl start grafana-server
systemctl enable grafana-server

相关实践学习
深入解析Docker容器化技术
Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化,容器是完全使用沙箱机制,相互之间不会有任何接口。Docker是世界领先的软件容器平台。开发人员利用Docker可以消除协作编码时“在我的机器上可正常工作”的问题。运维人员利用Docker可以在隔离容器中并行运行和管理应用,获得更好的计算密度。企业利用Docker可以构建敏捷的软件交付管道,以更快的速度、更高的安全性和可靠的信誉为Linux和Windows Server应用发布新功能。 在本套课程中,我们将全面的讲解Docker技术栈,从环境安装到容器、镜像操作以及生产环境如何部署开发的微服务应用。本课程由黑马程序员提供。 &nbsp; &nbsp; 相关的阿里云产品:容器服务 ACK 容器服务 Kubernetes 版(简称 ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情: https://www.aliyun.com/product/kubernetes
相关文章
|
7月前
|
数据采集 弹性计算 运维
打造您的专属赛事神经中枢 | 专业比分网/APP开发服务
我们为体育俱乐部、媒体、社区等打造专属实时比分平台,覆盖全球赛事,支持多终端访问,提供毫秒级更新、精准数据与个性化推送,助力高效观赛体验。
|
4月前
|
Java 应用服务中间件 API
【App Service】部署War包到Azure云上遇404错误
Java应用部署至Azure App Service for Windows后报404,本地运行正常。经排查,日志提示类文件版本不兼容:应用由Java 17(class file version 61.0)编译,但环境仅支持到Java 11(55.0)。错误根源为Java版本不匹配。调整App Service的Java版本至17后问题解决,成功访问接口。
224 1
|
9月前
|
人工智能 文件存储 数据中心
Ollama部署本地大模型并通过Infortress APP远程访问保姆级教程
本文介绍如何快速上手本地大模型部署工具Ollama及AI远程访问工具Infortress。通过Ollama,开发者可轻松部署如Llama、Deepseek等主流开源模型,仅需几行命令即可完成安装与运行。结合Infortress,用户能实现对本地大模型的远程访问,支持多设备无缝对接,同时提供便捷的模型切换与知识库管理功能。Infortress更兼具NAS软件特性,成为个人AI数据中心的理想选择。
|
8月前
|
域名解析 监控 NoSQL
即时通讯APP应用开发的部署策略
随着移动互联网发展,即时通讯APP成为生活和工作的必备工具。本文探讨其开发部署的关键环节,包括用户界面设计、通讯协议选择、数据库设计与服务器搭建等方面,以及部署过程中的环境准备、应用打包、服务器部署、域名解析和监控维护等步骤。通过优化每个环节,确保APP稳定高效运行,提升用户体验,在市场中保持竞争力。
|
人工智能 自然语言处理 前端开发
从0开始打造一款APP:前端+搭建本机服务,定制暖冬卫衣先到先得
通义灵码携手科技博主@玺哥超carry 打造全网第一个完整的、面向普通人的自然语言编程教程。完全使用 AI,再配合简单易懂的方法,只要你会打字,就能真正做出一个完整的应用。
11405 29
|
网络协议 容器
【Container App】部署Contianer App 遇见 Failed to deploy new revision: The Ingress's TargetPort or ExposedPort must be specified for TCP apps.
Failed to deploy new revision: The Ingress's TargetPort or ExposedPort must be specified for TCP apps.
198 27
|
人工智能 自然语言处理 芯片
上千人挑战,用通义灵码从 0 开始打造一款 App 爆火 | 第二课:搭建本机服务
通义灵码携手科技博主@玺哥超carry 打造全网第一个完整的、面向普通人的自然语言编程教程。完全使用 AI,再配合简单易懂的方法,只要你会打字,就能真正做出一个完整的应用。
1407 9
|
JavaScript C++ 容器
【Azure Bot Service】部署NodeJS ChatBot代码到App Service中无法自动启动
2024-11-12T12:22:40.366223350Z Error: Cannot find module 'dotenv' 2024-11-12T12:40:12.538120729Z Error: Cannot find module 'restify' 2024-11-12T12:48:13.348529900Z Error: Cannot find module 'lodash'
197 11
|
开发框架 监控 .NET
【Azure App Service】部署在App Service上的.NET应用内存消耗不能超过2GB的情况分析
x64 dotnet runtime is not installed on the app service by default. Since we had the app service running in x64, it was proxying the request to a 32 bit dotnet process which was throwing an OutOfMemoryException with requests >100MB. It worked on the IaaS servers because we had the x64 runtime install
319 5
|
Kubernetes 开发者 微服务
简化Kubernetes应用部署工具-Helm之Hook
本文讲的是简化Kubernetes应用部署工具-Helm之Hook【编者的话】微服务和容器化给复杂应用部署与管理带来了极大的挑战。Helm是目前Kubernetes服务编排领域的唯一开源子项目,做为Kubernetes应用的一个包管理工具,可理解为Kubernetes的apt-get / yum,由Deis 公司发起,该公司已经被微软收购。
2760 0

推荐镜像

更多