OpenTelemetry

otel

installation

doc https://opentelemetry.io/docs/collector/installation/

1
2
3
4
❯ helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
"open-telemetry" has been added to your repositories
❯ helm pull open-telemetry/opentelemetry-collector
❯ tar -zxvf opentelemetry-collector-0.102.1.tgz -C ./monitor
1
2
3
4
5
❯ helm template my-release ./opentelemetry-collector/  --values ./opentelemetry-collector/value.yaml
Error: execution error at (opentelemetry-collector/templates/NOTES.txt:6:3): [ERROR] 'mode' must be set. See https://github.com/open-telemetry/opentelemetry-helm-charts/blob/main/charts/opentelemetry-collector/UPGRADING.md for instructions.

Use --debug flag to render out invalid YAML

mode**=**<daemonset**|**deployment**|**statefulset>

network cidr ip

ip

kube-apiserver

kube-controller-manager

kubelet

flannel

etcd

coredns

1
2
3
4
5
[root@k8s01 opt]#  zgrep "cluster-cidr\|cluster-ip" /etc/kubernetes/manifests/*
/etc/kubernetes/manifests/kube-apiserver.yaml: - --service-cluster-ip-range=10.96.0.0/12
/etc/kubernetes/manifests/kube-controller-manager.yaml: - --cluster-cidr=121.21.0.0/16
/etc/kubernetes/manifests/kube-controller-manager.yaml: - --service-cluster-ip-range=10.96.0.0/12

service-cluster-ip-range 用于指定服务(Service)的ClusterIP的IP地址范围

cluster-cidr 集群的Pod网络地址范围,所有Pod都应该在这个范围内分配IP地址

monitor exporter

OpenTelemetry

1
./otelcol --config=customconfig.yaml

doc https://opentelemetry.io/docs/collector/configuration/

1
2
3
4
❯ ./otelcol validate --config=otel-collector-config.yaml
Error: failed to get config: cannot resolve the configuration: retrieved value (type=string) cannot be used as a Conf
2024/08/23 17:57:26 collector server run finished with error: failed to get config: cannot resolve the configuration: retrieved value (type=string) cannot be used as a Conf
❯ ./otelcol validate --config=otel-collector-config.yaml
otel-collector-config.yaml
otel-collector-config.yaml
##接收器
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
  prometheus:
    config:
     scrape_configs:
       - job_name: 'elasticsearch-monitoring'
         scrape_interval: 10s
         static_configs:
           - targets: ['local.org:9114']
       - job_name: 'skywalking-so11y'
         scrape_interval: 8s
         static_configs:
           - targets: ['local.org:11234']
             labels:
               host_name: http://localhost:11234
               service: oap-server
       - job_name: 'nginx-monitoring'
         scrape_interval: 10s
         metrics_path: "/metrics"
         static_configs:
            - targets: ['local.org:9145']
              labels:
                 service: nginx-service
                 service_instance_id: e2e-test-instance
       # - job_name: 'apisix-monitoring'
       #   scrape_interval: 10s
       #   metrics_path: "/apisix/prometheus/metrics"
       #   static_configs:
       #      - targets: ['local.org:9091']
       #        labels:
       #          skywalking_service: showcase-apisix-service
       - job_name: "vm-monitoring" # make sure to use this in the vm.yaml to filter only VM metrics
         scrape_interval: 10s
         static_configs:
            - targets: ["local.org:9100"]
       - job_name: 'mysql-monitoring'
         scrape_interval: 5s
         static_configs:
           - targets: ['local.org:9104']
             labels:
               host_name: local.org:3305
       - job_name: "postgresql-monitoring"
         scrape_interval: 5s
         static_configs: #["postgres-exporter:9187","postgres-exporter_2:9187","postgres-exporter_3:9187"]
            - targets: ["local.org:9187"]
              labels:
                host_name: local.org:5433
       - job_name: 'redis-monitoring'
         scrape_interval: 5s
         static_configs:
           - targets: ['local.org:9121']
             labels:
               host_name: local.org:9121                

processors: batch:
##导出器 exporters: otlp: endpoint: local.org:11800 tls: insecure: true debug:
##扩展组件 extensions: health_check: endpoint: 0.0.0.0:13133 pprof: endpoint: 0.0.0.0:1888 zpages: endpoint: 0.0.0.0:55679
service: extensions: [health_check, pprof, zpages] pipelines: traces: receivers: [otlp] processors: [batch] exporters: [otlp,debug] metrics: receivers: [otlp,prometheus] processors: [batch] exporters: [otlp,debug] logs: receivers: [otlp] processors: [batch] exporters: [otlp]

gitlab ci

eg 多环境
stages stage only
stages:
  - build
  - test
  - deploy

job_build: stage: build script: - echo "Building the project..." # 添加构建项目的命令
job_test: stage: test script: - echo "Running tests..." # 添加运行测试的命令
job_deploy_staging: stage: deploy environment: staging script: - echo "Deploying to staging server..." # 添加部署到staging服务器的命令 only: - master
job_deploy_production: stage: deploy environment: production script: - echo "Deploying to production server..." # 添加部署到production服务器的命令 only: - tags

k8s upgrade

upgrade

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
❯ curl -O https://gh-proxy.com/https://github.com/kubernetes/kubernetes/archive/refs/tags/v1.27.16.tar.gz


❯ cd kubernetes-1.27.16
❯ make kubectl kubeadm kubelet
go version go1.22.5 linux/amd64
+++ [0813 15:12:42] Building go targets for linux/amd64
k8s.io/kubernetes/cmd/kubectl (static)
go version go1.22.5 linux/amd64
+++ [0813 15:13:28] Building go targets for linux/amd64
k8s.io/kubernetes/cmd/kubeadm (static)
go version go1.22.5 linux/amd64
+++ [0813 15:13:42] Building go targets for linux/amd64
k8s.io/kubernetes/cmd/kubelet (non-static)

./_output/local/bin/linux/amd64/kubectl version
1
2
3
4
5
6
7
8
9
10
❯ ./kubeadm  --image-repository registry.aliyuncs.com/google_containers config images list
I0813 15:17:23.993040 121529 version.go:256] remote version is much newer: v1.30.3; falling back to: stable-1.27
registry.aliyuncs.com/google_containers/kube-apiserver:v1.27.16
registry.aliyuncs.com/google_containers/kube-controller-manager:v1.27.16
registry.aliyuncs.com/google_containers/kube-scheduler:v1.27.16
registry.aliyuncs.com/google_containers/kube-proxy:v1.27.16
registry.aliyuncs.com/google_containers/pause:3.9
registry.aliyuncs.com/google_containers/etcd:3.5.12-0
registry.aliyuncs.com/google_containers/coredns:v1.10.1

载入天数...载入时分秒... ,