helm3部署skywalking

参考:https://blog.51cto.com/flyfish225/3659402

https://github.com/apache/skywalking-kubernetes

1、skywalking的组件

本文采用的是SkyWalking,简单来说分为以下几个组成部分(以本文中的部署方式划分)

skywalking-oap-server:后端服务
skywalking-ui:ui前端
skywalking-es-init:初始化es集群数据使用
elasticsearch:存储skywalking的数据指标

镜像包地址

# docker pull apache/skywalking-ui:8.7.0
# docker pull apache/skywalking-oap-server:8.7.0-es7
# docker  pull  busybox:1.30

2、skywalking在 k8s上面的部署

helm version

git clone https://github.com/apache/skywalking-kubernetes

cd skywalking-kubernetes/chart
helm repo add elastic https://helm.elastic.co
helm dep up skywalking
export SKYWALKING_RELEASE_NAME=skywalking
export SKYWALKING_RELEASE_NAMESPACE=dev-app

修改values.yaml文件

vim values.yaml

image:
    repository: skywalking.docker.scarf.sh/apache/skywalking-oap-server
  改为:
    172.16.43.156/app/skywalking-oap-server #修改为内网得访问地址

(1)使用现有 Elasticsearch 安装特定版本的 SkyWalking(本人用得此方式)

修改values-my-es.yaml

[root@k8s02-zongshuai skywalking]# cat  values-my-es.yaml 
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Default values for skywalking.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

oap:
  image:
    tag: 8.7.0-es7
  storageType: elasticsearch7

ui:
  image:
    tag: 8.7.0

elasticsearch:
  enabled: false
  config:               # For users of an existing elasticsearch cluster,takes effect when `elasticsearch.enabled` is false
    host: elasticsearch-master.dev-app.svc.cluster.local
    port:
      http: 9200
    user: "elastic"         # [optional]
    password: "elastic"     # [optional]

helm安装

[root@k8s02-zongshuai chart]# pwd
/data/k8s/skywalking-kubernetes-master/chart
[root@k8s02-zongshuai chart]# helm install "${SKYWALKING_RELEASE_NAME}"  ./skywalking -n "${SKYWALKING_RELEASE_NAMESPACE}"    -f ./skywalking/values-my-es.yaml

  

修改skywalking-ui的svc为nodeport模式,可供外网访问

(2)安装特定版本的 SkyWalking & Elasticsearch

helm install "${SKYWALKING_RELEASE_NAME}"  ./skywalking -n "${SKYWALKING_RELEASE_NAMESPACE}"   --set oap.image.tag=8.7.0-es7   --set oap.storageType=elasticsearch7   --set ui.image.tag=8.7.0  --set elasticsearch.imageTag=7.5.1

3、agent使用

(1)

镜像包拉取

# docker pull apache/skywalking-java-agent:8.7.0-jdk8

可以通过sidecar方式将agent挂载到需要监控的业务deployment中

initContainers:
      - name: init-agent
        image: 172.16.43.156/app/skywalking-java-agent:8.7.0-jdk8
        command:
        - 'sh'
        - '-c'
        - 'set -ex;mkdir -p /data/bxm/skywalking-agent;cp -r /skywalking/agent/* /data/bxm/skywalking-agent;'
        volumeMounts:
        - name: model
          mountPath: /data/bxm/skywalking-agent
          subPath: skywalking-agent
      containers:
      - name: $POD_NAME
        image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME
        imagePullPolicy: Always
        volumeMounts:- name: model
            mountPath: /data/bxm/skywalking-agent
            subPath: skywalking-agent

主要是两部分需要改动,一是通过initContainers初始化加载agent的镜像,二是通过volumesagent文件夹挂载到业务容器中。

还需要更改dockerfile中业务启动命令

ENTRYPOINT ["java","-server","-Xmx2g","-Xms1g","-Xss512k","-javaagent:/data/bxm/skywalking-agent/skywalking-agent.jar","-Dskywalking.agent.service_name=bxm-data-model","-Dskywalking.collector.backend_service=skywalking-oap.dev-app.svc:11800","-jar","xxx.jar"]

(2)

修改dockerfile把skywalking-agent.jar打包进去

posted @ 2022-04-27 17:18  灰蓝色的白云梦想  阅读(1495)  评论(0编辑  收藏  举报