Dapr进阶-01-Debug dapr

2023-12-09 21:38
文章标签 debug 进阶 01 dapr

本文主要是介绍Dapr进阶-01-Debug dapr,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1. 安装golang

CentOS 8 安装golang_敦格-CSDN博客CentOS 8 安装golanghttps://shuaihj.blog.csdn.net/article/details/123018041

2. 以debug模式编译源码

Debug daprd on Kubernetes | Dapr DocsHow to debug the Dapr sidecar (daprd) on your Kubernetes clusterhttps://docs.dapr.io/developing-applications/debugging/debug-k8s/debug-daprd/

2.1. 下载dapr源码

git clone https://github.com/dapr/dapr.git

2.2. 目录定位

cd dapr

2.3. 修改Dockerfile中的GOPROXY为国内镜像源

vi ./docker/Dockerfile-debug
  • 关键参数如下 
GOPROXY=https://goproxy.cn,direct
  • 结果 

2.4. 编译

make release GOOS=linux GOARCH=amd64 DEBUG=1

3. 生成debug模式的dapr镜像到你自己的docker库

3.1. 登录你的docker hub

docker login

3.2. 提前下载gcr.io的docker镜像

gcr.io/distroless/static:nonroot

国内无法访问gcr.io的解决办法_敦格-CSDN博客国内无法访问gcr.io的解决办法https://shuaihj.blog.csdn.net/article/details/123022325

3.3. 验证本地docker镜像

docker images | grep static

3.4. Build 并 Push到docker hub

export DAPR_TAG=dev
export DAPR_REGISTRY=k8schina
make docker-push DEBUG=1

3.5. 验证docker hub

4. 安装debug模式的的dapr

4.1. 创建values.yaml文件

vi values.yaml
global:registry: docker.io/k8schinatag: "dev-linux-amd64"logAsJson: true
dapr_operator:debug:enabled: true
dapr_sidecar_injector:hostNetwork: truedebug:enabled: true
dapr_placement:debug:enabled: true
dapr_sentry:debug:enabled: true

4.2. 卸载旧版本

helm uninstall dapr --namespace dapr-system

4.3. 安装debug版本

  • 必须 进入dapr源码目录
cd dapr
  • 自定义安装 
helm install dapr charts/dapr \
--namespace dapr-system \
--create-namespace \
--values values.yaml \
--wait

4.4. 验证

docker images | grep dev

5. Debug Dapr 控制面组件

5.1. 查看要debug的控制面pod

kubectl get pods -n dapr-system -o wide

5.2. debug监控你的控制面pod

kubectl port-forward dapr-operator-7878f94fcd-6bfx9 40000:40000 -n dapr-system

6. Debug 微服务的 daprd sidecar

Debug daprd on Kubernetes | Dapr DocsHow to debug the Dapr sidecar (daprd) on your Kubernetes clusterhttps://docs.dapr.io/developing-applications/debugging/debug-k8s/debug-daprd/

6.1. 配置你的deployment为可debug

dapr.io/enable-debug: "true"
apiVersion: v1
kind: Namespace
metadata:name: dapr-demo
---
apiVersion: apps/v1
kind: Deployment
metadata:name: service01namespace: dapr-demolabels:app: service01
spec:replicas: 2selector:matchLabels:app: service01template:metadata:labels:app: service01annotations:dapr.io/enabled: "true"dapr.io/app-id: "service01"dapr.io/app-port: "80"dapr.io/sidecar-liveness-probe-delay-seconds: "10"dapr.io/sidecar-readiness-probe-delay-seconds: "10"dapr.io/log-as-json: "true"dapr.io/enable-debug: "true"spec:containers:- name: service01image: docker.io/k8schina/service01:v1ports:- containerPort: 80imagePullPolicy: Always
---
apiVersion: apps/v1
kind: Deployment
metadata:name: service02namespace: dapr-demolabels:app: service02
spec:replicas: 1selector:matchLabels:app: service02template:metadata:labels:app: service02annotations:dapr.io/enabled: "true"dapr.io/app-id: "service02"dapr.io/app-port: "80"dapr.io/sidecar-liveness-probe-delay-seconds: "10"dapr.io/sidecar-readiness-probe-delay-seconds: "10"dapr.io/log-as-json: "true"dapr.io/enable-debug: "true"spec:containers:- name: service02image: docker.io/k8schina/service02:v1ports:- containerPort: 80imagePullPolicy: Always
---
apiVersion: v1
kind: Service
metadata:name: service02namespace: dapr-demo
spec:type: NodePortselector:app: service02ports:- port: 80targetPort: 80nodePort: 30006

6.2. 部署你的微服务

kubectl apply -f http://k8schina.corecore.cn/DaprDemo.yaml

6.3. 查看要debug的微服务pod

kubectl get pods -n dapr-demo -o wide

6.4. debug监控你的目标pod

kubectl port-forward dapr-operator-7878f94fcd-6bfx9 40000:40000 -n dapr-demo

这篇关于Dapr进阶-01-Debug dapr的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/475153

相关文章

Spring Boot + MyBatis Plus 高效开发实战从入门到进阶优化(推荐)

《SpringBoot+MyBatisPlus高效开发实战从入门到进阶优化(推荐)》本文将详细介绍SpringBoot+MyBatisPlus的完整开发流程,并深入剖析分页查询、批量操作、动... 目录Spring Boot + MyBATis Plus 高效开发实战:从入门到进阶优化1. MyBatis

Java进阶学习之如何开启远程调式

《Java进阶学习之如何开启远程调式》Java开发中的远程调试是一项至关重要的技能,特别是在处理生产环境的问题或者协作开发时,:本文主要介绍Java进阶学习之如何开启远程调式的相关资料,需要的朋友... 目录概述Java远程调试的开启与底层原理开启Java远程调试底层原理JVM参数总结&nbsMbKKXJx

MySQL进阶之路索引失效的11种情况详析

《MySQL进阶之路索引失效的11种情况详析》:本文主要介绍MySQL查询优化中的11种常见情况,包括索引的使用和优化策略,通过这些策略,开发者可以显著提升查询性能,需要的朋友可以参考下... 目录前言图示1. 使用不等式操作符(!=, <, >)2. 使用 OR 连接多个条件3. 对索引字段进行计算操作4

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

Goland debug失效详细解决步骤(合集)

《Golanddebug失效详细解决步骤(合集)》今天用Goland开发时,打断点,以debug方式运行,发现程序并没有断住,程序跳过了断点,直接运行结束,网上搜寻了大量文章,最后得以解决,特此在这... 目录Bug:Goland debug失效详细解决步骤【合集】情况一:Go或Goland架构不对情况二:

Python进阶之Excel基本操作介绍

《Python进阶之Excel基本操作介绍》在现实中,很多工作都需要与数据打交道,Excel作为常用的数据处理工具,一直备受人们的青睐,本文主要为大家介绍了一些Python中Excel的基本操作,希望... 目录概述写入使用 xlwt使用 XlsxWriter读取修改概述在现实中,很多工作都需要与数据打交

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

Java进阶13讲__第12讲_1/2

多线程、线程池 1.  线程概念 1.1  什么是线程 1.2  线程的好处 2.   创建线程的三种方式 注意事项 2.1  继承Thread类 2.1.1 认识  2.1.2  编码实现  package cn.hdc.oop10.Thread;import org.slf4j.Logger;import org.slf4j.LoggerFactory

hdu 2602 and poj 3624(01背包)

01背包的模板题。 hdu2602代码: #include<stdio.h>#include<string.h>const int MaxN = 1001;int max(int a, int b){return a > b ? a : b;}int w[MaxN];int v[MaxN];int dp[MaxN];int main(){int T;int N, V;s

[MySQL表的增删改查-进阶]

🌈个人主页:努力学编程’ ⛅个人推荐: c语言从初阶到进阶 JavaEE详解 数据结构 ⚡学好数据结构,刷题刻不容缓:点击一起刷题 🌙心灵鸡汤:总有人要赢,为什么不能是我呢 💻💻💻数据库约束 🔭🔭🔭约束类型 not null: 指示某列不能存储 NULL 值unique: 保证某列的每行必须有唯一的值default: 规定没有给列赋值时的默认值.primary key: