helm部署skywalking实战

本文主要介绍Kubernetes中如何用Helm3部署skywalking,并对pod应用进行链路追踪。

部署skywalking oap和ui

# 添加仓库
helm repo add skywalking https://apache.jfrog.io/artifactory/skywalking-helm
# 拉取chart到本地修改
helm pull skywalking/skywalking
# 解压编辑
tar -zxvf skywalking-4.3.0.tgz
cd skywalking
# 基于已经存在es部署skywalking,es部署方式不多作介绍
vim values-my-es.yaml
# 编辑结果如下
# values-my-es.yaml
oap:
  image:
    tag: 9.2.0
  storageType: elasticsearch

ui:
  image:
    tag: 9.2.0

elasticsearch:
  enabled: false
  config:
    host: 10.81.48.56
    port:
      http: 9200
    user: "elastic"         # [optional]
    password: "*******"     # [optional]

# helm 部署
helm install -n skywalking skywalking /root/skywalking --values /root/skywalking/values-my-es.yaml

等待pod启动成功

helm部署skywalking实战_第1张图片

添加agent

下载地址

https://dlcdn.apache.org/skywalking/java-agent/8.14.0/apache-skywalking-java-agent-8.14.0-src.tgz

解压后新建Dockerfile文件,内容如下

FROM busybox:latest
COPY / /usr/skywalking/agent/

打包镜像上传到私服上

docker build -t skywalking-agent:latest .
docker login harbor-host -u admin -p ******
docker tag skywalking-agent:latest horbor-host/project-name/skywalking-agent:latest
docker push horbor-host/project-name/skywalking-agent:latest

配置deployement.yaml

kind: Deployment
apiVersion: apps/v1
metadata:
  name: test-skywalking
  namespace: default
spec:
  replicas: 1
  template:
    spec:
      volumes:
        - name: sw-agent
          emptyDir: {}
      initContainers:
        - name: sw-agent-sidecar
          image: horbor-host/project-name/skywalking-agent:latest
          command:
            - sh
          args:
            - '-c'
            - >-
              mkdir -p /skywalking/agent && cp -r /usr/skywalking/agent/*
              /skywalking/agent
          resources: {}
          volumeMounts:
            - name: sw-agent
              mountPath: /skywalking/agent
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      containers:
        - name: server
          image: dev-docker-mirrors.******.com/test-skywalking:dev
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          env:
            - name: JAVA_TOOL_OPTIONS
              value: >-
                -javaagent:/usr/skywalking/agent/skywalking-agent.jar
            - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
              value: skywalking-oap.skywalking:11800
            - name: SW_AGENT_NAME
              value: test-skywalking
          resources: {}
          volumeMounts:
            - name: sw-agent
              mountPath: /usr/skywalking/agent
          imagePullPolicy: Always
          securityContext: {}
      schedulerName: default-scheduler

agent服务部署成功后访问skywalking-ui

http://skywalking-ui.skywalking/ (不能访问的需要暴漏nodePort或者ingress访问)

helm部署skywalking实战_第2张图片

大功告成,具体使用方式不多作介绍

skywalking忽略指定路径

#将apm-trace-ignore-plugin-8.14.0.jar拷贝到plugin目录中,重新打包镜像
cp optional-plugins/apm-trace-ignore-plugin-8.14.0.jar plugins/

#新增环境变量(需要忽略的访问地址)
-Dskywalking.trace.ignore_path=/actuator/**,Kafka/**,Lettuce/**,GET:/actuator/**,GET:/doc/openapi.json,MongoDB/**,HikariCP/**,Mysql/**

#重启agent即可

你可能感兴趣的:(微服务,skywalking,运维,云计算)