Dra-M Dra-M
首页
技术
冥思
哲学
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

莫小龙

保持理智,相信未来。
首页
技术
冥思
哲学
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Java

  • Golang

  • 编程思想

  • 微服务

  • 中间件

  • Python

  • 运维

    • Linux

    • Bash

    • DevOps

      • 前言:搭建一套自有的围绕K8S的DevOps工具
      • 部署K8S -- kubeasz
      • 部署NFS服务器
      • 为K8S添加StorageClass
      • 学习用NodePort暴露K8S服务
      • 外部nginx代理到nodeport
      • 使用Docker安装LDAP
      • 使用K8S部署LDAP管理面板
      • 使用Docker部署第三方K8S面板Kuboard,并连接LDAP
      • 使用K8S部署GitLab,并连接LDAP
      • 使用K8S部署Jenkins,并连接LDAP
      • 使用K8S部署Nexus,并连接LDAP
      • Nexus Maven私服配置
      • Nexus Docker私服配置+K8S拉取私服镜像
      • Jenkins Pipeline 从 K8s Agent 启动构建
      • Jenkins Pipeline 拉取Git代码 获取提交信息
      • Jenkins Pipeline Maven打包
      • Jenkins Pipeline BuildDockerImage 推送到私服
      • Jenkins Pipeline 部署程序到K8S
      • Jenkins Pipeline 共享库
      • Loki日志收集+K8S
      • SkyWalking链路追踪+K8S、
        • 服务器部署
        • 前端部署
        • Agent部署
        • SpringCloud Gateway
      • SpringCloud+K8S联调说明
      • DevOps WebHook汇总 (Gitlab,Jenkins,K8S Event)
  • 技术
  • 运维
  • DevOps
莫小龙
2022-04-11
目录

SkyWalking链路追踪+K8S、

# 服务器部署

---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: skywalking
  name: skywalking
  namespace: iot-dev
spec:
  replicas: 1
  selector:
    matchLabels:
      app: skywalking
  template:
      labels:
        app: skywalking
    spec:
      containers:
        - envFrom:
            - configMapRef:
                name: skywalking-cm
              prefix: SW_
          image: 'apache/skywalking-oap-server:8.9.1'
          imagePullPolicy: IfNotPresent
          name: skywalking
          ports:
            - containerPort: 12800
              name: http
              protocol: TCP
            - containerPort: 11800
              name: grpc
              protocol: TCP
          volumeMounts:
            - mountPath: /etc/localtime
              name: volume-localtime
      volumes:
        - hostPath:
            path: /etc/localtime
            type: ''
          name: volume-localtime

---
apiVersion: v1
kind: Service
metadata:
  annotations: {}
  labels:
    app: skywalking
  name: skywalking
  namespace: iot-dev
spec:
  ports:
    - name: http
      port: 12800
      protocol: TCP
      targetPort: 12800
    - name: grpc
      port: 11800
      protocol: TCP
      targetPort: 11800
  selector:
    app: skywalking
  type: ClusterIP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

# 前端部署

---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: skywalking-ui
    k8s.kuboard.cn/name: skywalking-ui
  name: skywalking-ui
  namespace: iot-dev
spec:
  replicas: 1
  selector:
    matchLabels:
      app: skywalking-ui
  template:
    metadata:
      labels:
        app: skywalking-ui
    spec:
      containers:
        - env:
            - name: SW_OAP_ADDRESS
              value: 'http://skywalking:12800'
          image: 'apache/skywalking-ui:8.9.1'
          imagePullPolicy: IfNotPresent
          name: skywalking-ui
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
          volumeMounts:
            - mountPath: /etc/localtime
              name: volume-localtime
      volumes:
        - hostPath:
            path: /etc/localtime
            type: ''
          name: volume-localtime
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: skywalking-ui
  name: skywalking-ui
  namespace: iot-dev
spec:
  ports:
    - name: http
      nodePort: 31234
      port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: skywalking-ui
  type: NodePort
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

# Agent部署

先启动一个初始化容器,把Agent.jar复制出来。

再通过环境变量让java -jar 通过JVM代理Agent.jar启动。

挂载Skywalking后的java yaml模板如下:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations: {}
  labels:
    k8s.kuboard.cn/name: #{appname}
  name: #{appname}
  namespace: iot-dev
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s.kuboard.cn/name: #{appname}
  template:
    metadata:
      creationTimestamp: null
      labels:
        k8s.kuboard.cn/name: #{appname}
    spec:
      initContainers:
        - name: agent-container
          image: apache/skywalking-java-agent:8.9.0-alpine
          volumeMounts:
            - name: skywalking-agent
              mountPath: /agent
          command: [ "/bin/sh" ]
          args: [ "-c", "cp -R /skywalking/agent /agent/" ]
      containers:
        - name: #{appname}
          image: '192.168.1.177:30303/#{appname}:#{apptag}'
          volumeMounts:
            - name: skywalking-agent
              mountPath: /skywalking
          imagePullPolicy: IfNotPresent
          env:
            - name: JAVA_TOOL_OPTIONS
              value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
            - name: SW_AGENT_NAME
              value: '#{appname}'
            - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
              value: "skywalking:11800"
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
            - containerPort: 30652
              name: debug
              protocol: TCP
      imagePullSecrets:
        - name: mydocker
      restartPolicy: Always
      volumes:
        - name: skywalking-agent
          emptyDir: { }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

# SpringCloud Gateway

因为SpringCloud使用WebFlux,需要加载插件才能正常收集。

配置文件如下(区别在于多复制一个Gateway插件):

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations: {}
  labels:
    k8s.kuboard.cn/name: #{appname}
  name: #{appname}
  namespace: iot-dev
spec:
  selector:
    matchLabels:
      k8s.kuboard.cn/name: #{appname}
  template:
    metadata:
      labels:
        k8s.kuboard.cn/name: #{appname}
    spec:
      initContainers:
        - name: agent-container
          image: apache/skywalking-java-agent:8.9.0-alpine
          volumeMounts:
            - name: skywalking-agent
              mountPath: /agent
          command: [ "/bin/sh" ]
          args: [ "-c", "cp /skywalking/agent/optional-plugins/apm-spring-cloud-gateway-3.x-plugin-8.9.0.jar /skywalking/agent/plugins/ && cp -R /skywalking/agent /agent/"]
      containers:
        - name: #{appname}
          image: '192.168.1.177:30303/#{appname}:#{apptag}'
          volumeMounts:
            - name: skywalking-agent
              mountPath: /skywalking
          imagePullPolicy: IfNotPresent
          env:
            - name: JAVA_TOOL_OPTIONS
              value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
            - name: SW_AGENT_NAME
              value: '#{appname}'
            - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
              value: "skywalking:11800"
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
            - containerPort: 30652
              name: debug
              protocol: TCP
      imagePullSecrets:
        - name: mydocker
      volumes:
        - name: skywalking-agent
          emptyDir: { }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

#DevOps#K8S#运维#SkyWalking
上次更新: 10/23/2024
Loki日志收集+K8S
SpringCloud+K8S联调说明

← Loki日志收集+K8S SpringCloud+K8S联调说明→

最近更新
01
mosquito配置ws协议
10-23
02
Pip包的离线下载和安装
10-23
03
stable diffusion 相关收藏
02-24
更多文章>
Theme by Vdoing | Copyright © 2019-2024 Dra-M
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式