基于kubernetes实现链路监控
介绍
- 官方文档:https://skywalking.apache.org/docs/main/latest/readme/
- chart包地址:https://github.com/apache/skywalking-kubernetes
实践
Install released version using Helm repository
下载chart包
export REPO=skywalking
helm repo add ${REPO} https://apache.jfrog.io/artifactory/skywalking-helm
helm pull skywalking/skywalking
修改value文件
由于前期有搭ES来收集日志,所以直接引用外部ES来做存储。
elasticsearch:
enabled: false
config: # For users of an existing elasticsearch cluster,takes effect when `elasticsearch.enabled` is false
host: elasticsearch-master.logs
port:
http: 9200
user: "elastic" # [optional]
password: "vRIfHvcdhNZJDGJ0" # [optional]
helm install
helm install skywalking -f ./values-my-es.yaml ../skywalking --namespace=skywalking
ingress 配置
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: skywalking
namespace: skywalking
spec:
tls:
- hosts:
- uatk8s-skywalking.jackhe.com
secretName: leyaoyao
rules:
- host: uatk8s-skywalking.jackhe.com
http:
paths:
- path: /
backend:
service:
name: skywalking-ui
port:
number: 80
pathType: Prefix
集成应用
制作agent镜像
这里我们以sidecar 模式接入 skywalking
Dockerfile
下载agent包: https://archive.apache.org/dist/skywalking/8.1.0/apache-skywalking-apm-es7-8.1.0.tar.gz
FROM busybox:latest
LABEL maintainer="Jackhe"
COPY apache-skywalking-apm-bin-es7/agent/ /opt/agent/
deployment配置
- helm 模板
{{- if .Values.initContainers.SkyWalking.enabled }}
- mountPath: /skywalking
name: apm-agent
{{- end }}
initContainers:
{{- if .Values.initContainers.SkyWalking.enabled }}
- command:
- cp
- -rf
- /opt/agent
- /skywalking
image: tengxunharbor.jackhe.com/lyy-gz/skywalking:8.1.0
name: skywalking-agent
imagePullPolicy: Always
volumeMounts:
- mountPath: /skywalking
name: apm-agent
{{- end }}
volumes:
{{- if .Values.initContainers.SkyWalking.enabled }}
- emptyDir: {}
name: apm-agent
{{- end }}
应用configmap
appConfig:
JAVA_TOOL_OPTIONS: -javaagent:/skywalking/agent/skywalking-agent.jar
SW_AGENT_COLLECTOR_BACKEND_SERVICES: skywalking-oap.skywalking:11800
SW_AGENT_NAME: '[middle]user-member-sky'
如对您有帮助,支持下呗!
微信
支付宝