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

本文涉及的产品
可观测可视化 Grafana 版,10个用户账号 1个月
简介: 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

相关实践学习
通过Ingress进行灰度发布
本场景您将运行一个简单的应用,部署一个新的应用用于新的发布,并通过Ingress能力实现灰度发布。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
相关文章
|
2月前
|
网络协议 容器
【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.
74 27
|
2月前
|
人工智能 自然语言处理 前端开发
从0开始打造一款APP:前端+搭建本机服务,定制暖冬卫衣先到先得
通义灵码携手科技博主@玺哥超carry 打造全网第一个完整的、面向普通人的自然语言编程教程。完全使用 AI,再配合简单易懂的方法,只要你会打字,就能真正做出一个完整的应用。
10456 29
|
2月前
|
人工智能 自然语言处理 芯片
上千人挑战,用通义灵码从 0 开始打造一款 App 爆火 | 第二课:搭建本机服务
通义灵码携手科技博主@玺哥超carry 打造全网第一个完整的、面向普通人的自然语言编程教程。完全使用 AI,再配合简单易懂的方法,只要你会打字,就能真正做出一个完整的应用。
1224 9
|
3月前
|
存储 Kubernetes Devops
Kubernetes集群管理和服务部署实战
Kubernetes集群管理和服务部署实战
102 0
|
3月前
|
存储 Kubernetes 网络协议
k8s的无头服务
Headless Service 是一种特殊的 Kubernetes 服务,其 `spec:clusterIP` 设置为 `None`,不会分配 ClusterIP,通过 DNS 解析提供服务发现。与普通服务不同,Headless Service 不提供负载均衡功能,每个 Pod 都有唯一的 DNS 记录,直接映射到其 IP 地址,适用于有状态应用的场景,如与 StatefulSet 一起部署数据库。示例中通过创建 Nginx 的 StatefulSet 和 Headless Service,展示了如何直接访问单个 Pod 并进行内容修改。
90 3
|
3月前
|
开发框架 监控 .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
|
3月前
|
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'
59 11
|
3月前
|
C#
【Azure App Service】使用Microsoft.Office.Interop.Word来操作Word文档,部署到App Service后报错COMException
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).
|
4月前
|
机器人 Shell Linux
【Azure Bot Service】部署Python ChatBot代码到App Service中
本文介绍了使用Python编写的ChatBot在部署到Azure App Service时遇到的问题及解决方案。主要问题是应用启动失败,错误信息为“Failed to find attribute &#39;app&#39; in &#39;app&#39;”。解决步骤包括:1) 修改`app.py`文件,添加`init_func`函数;2) 配置`config.py`,添加与Azure Bot Service认证相关的配置项;3) 设置App Service的启动命令为`python3 -m aiohttp.web -H 0.0.0.0 -P 8000 app:init_func`。
|
4月前
|
开发工具 git C++
【App Service】VS Code直接部署App Service时候遇见 “fatal: not a git repository (or any of the parent directories): .git”
通过VS Code发布Python App Service的时候,遇见了发布失败错误: The deployment failed with error: fatal: not a git repository (or any of the parent directories): .git . Please take a few minutes to help us improve the deployment experience
110 24

热门文章

最新文章

  • 1
    【03】仿站技术之python技术,看完学会再也不用去购买收费工具了-修改整体页面做好安卓下载发给客户-并且开始提交网站公安备案-作为APP下载落地页文娱产品一定要备案-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
    34
  • 2
    【02】仿站技术之python技术,看完学会再也不用去购买收费工具了-本次找了小影-感觉页面很好看-本次是爬取vue需要用到Puppeteer库用node.js扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
    29
  • 3
    【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡
    23
  • 4
    【Azure Function】Function App门户上的Test/Run返回错误:Failed to fetch
    31
  • 5
    陪玩APP推送配置:陪玩系统手机锁屏收不到推送?可能是这些原因!解决方案来了!
    34
  • 6
    小游戏源码开发之可跨app软件对接是如何设计和开发的
    33
  • 7
    原生鸿蒙版小艺APP接入DeepSeek-R1,为HarmonyOS应用开发注入新活力
    135
  • 8
    PiliPala:开源项目真香,B站用户狂喜!这个开源APP竟能自定义主题+去广告?PiliPala隐藏功能大揭秘
    60
  • 9
    语音app系统软件源码开发搭建新手启蒙篇
    44
  • 10
    MNN-LLM App:在手机上离线运行大模型,阿里巴巴开源基于 MNN-LLM 框架开发的手机 AI 助手应用
    884