SkyWalking集成
服务端部署
SkyWalking ShowCase
拉取git https://github.com/apache/skywalking-showcase.git docker 部署 make deploy.docker K8s 部署 make deploy.kubernetes ps: 部署时可指定 FEATURE_FLAGS=single-node,grafana,agent ui "General Service" 加载不了的话就部署上 grafana 能看到 jvm 相关信息和请求图表,docker部署比较方便,agent只能docker部署时指定,它会启动一起agent服务创造数据
SkyWalking Helm
git拉取
https://github.com/apache/skywalking-helm.git
根据下面的values调整一下进行部署
https://github.com/apache/skywalking-helm/blob/master/chart/skywalking/values.yaml
主要调整内容:(没ES把enabled改为true就成config去掉)
oap:
image:
tag: 10.1.0
storageType: elasticsearch
replicas: 1
ui:
image:
tag: 10.1.0
elasticsearch:
enabled: false
config: # For users of an existing elasticsearch cluster,takes effect when `elasticsearch.enabled` is false
host: elasticsearch-master.elk.svc.cluster.local
port:
http: 9200
user: "elastic" # [optional]
password: "elasticsearch123" # [optional]
部署:
export SKYWALKING_RELEASE_VERSION=4.7.0 # change the release version according to your need
export SKYWALKING_RELEASE_NAME=skywalking # change the release name according to your scenario
export SKYWALKING_RELEASE_NAMESPACE=skywalking
helm install "${SKYWALKING_RELEASE_NAME}" \
oci://registry-1.docker.io/apache/skywalking-helm \
--version "${SKYWALKING_RELEASE_VERSION}" \
-n "${SKYWALKING_RELEASE_NAMESPACE}" \
-f ./values-my-es.yaml
PS: K8s用这个部署方式比较好,showcase好像有啥毛病来着,而且它是用于展示的示例部署方式
客户端部署
本地部署
下载agant 9.4.0的,要别的版本或者客户端可下载 解压后调整运行jar命令: java -javaagent:path/skywalking-agent/skywalking-agent.jar \ -Dskywalking.agent.service_name=trip \ -Dskywalking.collector.backend_service=172.22.8.15:11800 -jar app.jar Idea添加运行参考Add VM Options: -javaagent:path/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=xxx -Dskywalking.collector.backend_service=172.22.8.15:11800 -Dskywalking.agent.namespace=prod
K8s 部署
握草,发现它有给image,不过自己做定制化也高 制作image: 下载: https://www.apache.org/dyn/closer.cgi/skywalking/java-agent/9.4.0/apache-skywalking-java-agent-9.4.0.tgz 解压 tar -zxvf apache-skywalking-java-agent-9.4.0.tgz 创建dockerfile写入: FROM busybox ADD skywalking-agent /skywalking-agent 没登录先docker login下 docker build -t your-image-store/namespace/skywalking-agent-gateway:9.4.0 docker push your-image-store/namespace/skywalking-agent-gateway:9.4.0 PS: build前看看需要哪些插件,从options-plugin mv to plugin 部署k8s
关键内容
- env:
- name: JAVA_TOOL_OPTIONS
value: -javaagent:/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=mate-component
-Dskywalking.collector.backend_service=172.22.8.15:11800 -Dskywalking.agent.namespace=prod
volumeMounts:
- mountPath: /skywalking-agent
name: skywalking-agent
- mountPath: /skywalking-agent/logs
name: logs
initContainers:
- command:
- sh
- -c
- cp -r /skywalking-agent/* /skywalking-agent-dst/
image: registry.scwlhyy.com/public-repository/public/skywalking-agent:9.4.0
imagePullPolicy: IfNotPresent
name: skywalking-agent-init
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /skywalking-agent-dst
name: skywalking-agent
volumes:
- emptyDir: {}
name: skywalking-agent
- emptyDir: {}
name: logs
完整参考
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: prod
name: voyage-trip
labels:
app: voyage-trip
group: cloud-voyage
spec:
replicas: 2
selector:
matchLabels:
app: voyage-trip
group: cloud-voyage
template:
metadata:
labels:
app: voyage-trip
group: cloud-voyage
spec:
imagePullSecrets:
- name: gitlab-login-registry-secret-ssl
volumes:
- emptyDir: {}
name: skywalking-agent
- name: logs
emptyDir: {}
initContainers:
- command:
- sh
- -c
- cp -r /skywalking-agent/* /skywalking-agent-dst/
image: registry.scwlhyy.com/public-repository/public/skywalking-agent:9.4.0
imagePullPolicy: IfNotPresent
name: skywalking-agent-init
resources: { }
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /skywalking-agent-dst
name: skywalking-agent
containers:
- name: voyage-trip
image: registry.scwlhyy.com/backend/cloudvoyage/voyage-trip:latest-prod
imagePullPolicy: Always
ports:
- containerPort: 21001
env:
- name: JAVA_TOOL_OPTIONS
value: -javaagent:/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=voyage-trip
-Dskywalking.collector.backend_service=172.22.8.15:11800 -Dskywalking.agent.namespace=prod
- name: JAVA_OPTS
value: "-Xms1824M -Xmx1824M -XX:MaxMetaspaceSize=256M -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:InitiatingHeapOccupancyPercent=45 -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -XX:+UseContainerSupport -XX:MaxRAMPercentage=70.0"
- name: APP_NAME
value: "voyage-trip"
volumeMounts:
- mountPath: /skywalking-agent
name: skywalking-agent
- mountPath: /skywalking-agent/logs
name: logs
- name: logs
mountPath: /app/logs
readinessProbe:
httpGet:
path: /actuator/health
port: 21001
initialDelaySeconds: 30
periodSeconds: 15
livenessProbe:
httpGet:
path: /actuator/health
port: 21001
initialDelaySeconds: 90
periodSeconds: 20
resources:
requests:
cpu: "2"
memory: "2048Mi"
limits:
cpu: "4"
memory: "3Gi"
restartPolicy: Always