SkyWalking部署-K8S

一、安装K8S集群

kubeadm部署K8s集群V1.19.0

二、部署skywalking

2.1.创建命名空间

kubectl create ns skywalking

2.2.给节点打标签

kubectl label node 节点名 nodetype=wedesign

2.3.skywalking-oap.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: oap
  namespace: skywalking
spec:
  replicas: 1
  selector:
    matchLabels:
      app: oap
      release: skywalking
  template:
    metadata:
      labels:
        app: oap
        release: skywalking
    spec:
      nodeSelector:
       nodetype: wedesign
      containers:
        - name: oap
          image: apache/skywalking-oap-server:6.6.0-es6
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 11800
              name: grpc
            - containerPort: 12800
              name: rest
---
apiVersion: v1
kind: Service
metadata:
  name: oap
  namespace: skywalking
  labels:
    service: oap
spec:
  ports:
    - port: 12800
      name: rest
    - port: 11800
      name: grpc
  selector:
    app: oap
kubectl apply -f skywalking-oap.yml

2.4.skywalking-ui.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ui-deployment
  namespace: skywalking
  labels:
    app: ui
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ui
  template:
    metadata:
      labels:
        app: ui
    spec:
      nodeSelector:
       nodetype: wedesign
      containers:
        - name: ui
          image: apache/skywalking-ui:6.6.0
          ports:
            - containerPort: 8080
              name: page
          env:
            - name: SW_OAP_ADDRESS
              value: oap:12800
---
apiVersion: v1
kind: Service
metadata:
  name: ui
  namespace: skywalking
  labels:
    service: ui
spec:
  ports:
    - port: 8080
      name: page
      nodePort: 31008
  type: NodePort
  selector:
    app: ui
kubectl apply -f skywalking-ui.yml
2.5.访问

http://NodeIP:31008

三、sidecar 模式挂载 agent

参考文章:https://skywalking.apache.org/zh/blog/2019-08-30-how-to-use-Skywalking-Agent.html

四、微服务对接skywalking

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: web
  replicas: 1
  template:
    metadata:
      labels:
        app: web
    spec:
      initContainers:
        - image: spring2go/skywalking-agent-sidecar:6.6.0
          name: sw-agent-sidecar
          imagePullPolicy: IfNotPresent
          command: ["sh"]
          args:
            [
              "-c",
              "mkdir -p /skywalking/agent && cp -r /usr/skywalking/agent/* /skywalking/agent",
            ]
          volumeMounts:
            - mountPath: /skywalking/agent
              name: sw-agent
      containers:
        - name: web
          image: spring2go/spring-petclinic-web-app:1.0.0.RELEASE
          env:
            - name: JAVA_OPTS
              value: -javaagent:/usr/skywalking/agent/skywalking-agent.jar
            - name: SW_AGENT_NAME
              value: petclinic-web
            - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
              value: oap.skywalking:11800 # FQDN: servicename.namespacename.svc.cluster.local
            - name: SERVER_PORT
              value: "8080"
            - name: VISITS_SERVICE_ENDPOINT
              value: http://visits:8080
            - name: CUSTOMERS_SERVICE_ENDPOINT
              value: http://customers:8080
          volumeMounts:
            - mountPath: /usr/skywalking/agent
              name: sw-agent
      volumes:
        - name: sw-agent
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: web
  labels:
    svc: web
spec:
  selector:
    app: web
  ports:
    - name: http
      port: 8080
      targetPort: 8080
  type: ClusterIP

**注意:**在java启动jar包时需要在java后面添加${JAVA_OPTS}变量,如java ${JAVA_OPTS} -jar /opt/app.jar;如果不是用root用户启动java程序【例如devops】,还需要修改/usr/skywalking目录的所有者为devops

chown -R devops.devops /usr/skywalking
相关推荐
€☞扫地僧☜€1 小时前
docker 拉取MySQL8.0镜像以及安装
运维·数据库·docker·容器
全能全知者2 小时前
docker快速安装与配置mongoDB
mongodb·docker·容器
景天科技苑8 小时前
【云原生开发】K8S多集群资源管理平台架构设计
云原生·容器·kubernetes·k8s·云原生开发·k8s管理系统
wclass-zhengge9 小时前
K8S篇(基本介绍)
云原生·容器·kubernetes
颜淡慕潇9 小时前
【K8S问题系列 |1 】Kubernetes 中 NodePort 类型的 Service 无法访问【已解决】
后端·云原生·容器·kubernetes·问题解决
川石课堂软件测试11 小时前
性能测试|docker容器下搭建JMeter+Grafana+Influxdb监控可视化平台
运维·javascript·深度学习·jmeter·docker·容器·grafana
昌sit!17 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
A ?Charis20 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
wclass-zhengge20 小时前
Docker篇(Docker Compose)
运维·docker·容器
北漂IT民工_程序员_ZG21 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes