加载中...

K8s部署 Skywalking监控应用性能


一 简介

SkyWalking 是一个APM (应用程序性能监视器)系统,专门为微服务,云原生和基于容器 (Docker,Kubernetes,Mesos)的体系结构而设计。
SkyWalking 的功能包括对Cloud Native 体系结构中的分布式系统的监视,跟踪,诊断功能。核心功能如下:

  • 服务、服务实例、端点指标分析
  • 根本原因分析,在运行时分析代码
  • 服务拓扑图分析
  • 服务、服务实例和端点依赖关系分析
  • 检测慢速服务和端点
  • 性能优化
  • 分布式跟踪和上下文传播
  • 数据库访问指标,检测慢速数据库访问语句(包括SQL语句)
  • 报警
  • 浏览器性能监控

安装

skywalking_ns.yaml

yaml
apiVersion: v1
kind: Namespace
metadata:
  name: skywalking

oap-serviceaccount.yaml

yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app: skywalking-oap-server
    release: 8.3.0
  name: skywalking-oap-server
  namespace: skywalking
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: skywalking-oap-server
  namespace: skywalking
  labels:
    app: skywalking-oap-server
    release: 8.3.0
rules:
  - apiGroups: [""]
    resources: ["pods","configmaps"]
    verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: skywalking-oap-server
  namespace: skywalking
  labels:
    app: skywalking-oap-server
    release: 8.3.0
rules:
- apiGroups: [""]
  resources: ["pods", "endpoints", "services"]
  verbs: ["get", "watch", "list"]
- apiGroups: ["extensions"]
  resources: ["deployments", "replicasets"]
  verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: skywalking-oap-server
  namespace: skywalking
  labels:
    app: skywalking-oap-server
    release: 8.3.0
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: skywalking-oap-server
subjects:
  - kind: ServiceAccount
    name: skywalking-oap-server
    namespace: skywalking
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: skywalking-oap-server
  labels:
    app: skywalking-oap-server
    release: 8.3.0
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: skywalking-oap-server
subjects:
- kind: ServiceAccount
  name: skywalking-oap-server
  namespace: skywalking

sky-deployment.yaml

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: skywalking-oap-server
  namespace: skywalking
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: skywalking-oap-server
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: skywalking-oap-server
    spec:
      containers:
      - env:
        - name: SW_STORAGE
          value: elasticsearch7
        - name: SW_NAMESPACE
          value: docker-cluster
        - name: SW_STORAGE_ES_CLUSTER_NODES
          value: elasticsearch.logs:9200
        - name: SW_STORAGE_ES_SUPER_DATASET_INDEX_SHARDS_FACTOR
          value: "6"
        - name: SW_STORAGE_ES_BULK_ACTIONS
          value: "4000"
        - name: SW_STORAGE_ES_FLUSH_INTERVAL
          value: "30"
        - name: SW_STORAGE_ES_QUERY_MAX_SIZE
          value: "10000"
        - name: SW_STORAGE_ES_QUERY_SEGMENT_SIZE
          value: "500"
        - name: SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE
          value: "500"
        image: harbor33.huhuhahei.com/library/apache/skywalking-oap-server:8.5.0-es7
        imagePullPolicy: IfNotPresent
        name: skywalking-oap-server
        resources: {}
        securityContext:
          privileged: false
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
  name: skywalking
  namespace: skywalking
spec:
  clusterIP: 10.111.92.41
  externalTrafficPolicy: Cluster
  ports:
  - name: http
    nodePort: 30258
    port: 12800
    protocol: TCP
    targetPort: 12800
  - name: grpc
    nodePort: 30320
    port: 11800
    protocol: TCP
    targetPort: 11800
  selector:
    app: skywalking-oap-server
  sessionAffinity: None
  type: NodePort

sky-uideploy.yaml

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: skyui
  namespace: skywalking
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: skyui
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: skyui
    spec:
      containers:
      - env:
        - name: SW_OAP_ADDRESS
          value: skywalking:12800
        - name: SW_TIMEOUT
          value: "20000"
        image: harbor.huhuhahei.cn/library/apache/skywalking-ui:8.5.0
        imagePullPolicy: Always
        name: skyui
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
  name: skyui
  namespace: skywalking
spec:
  clusterIP: 10.96.154.174
  externalTrafficPolicy: Cluster
  ports:
  - name: http-admin
    nodePort: 30185
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: skyui
  sessionAffinity: None
  type: NodePort

三 访问查看


服务端已经配置好了 后面可以接入agent端


文章作者: huhuhahei
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 huhuhahei !
评论
Powered By Valine
v1.4.18
  目录