k8s skywalking pod

k8s skywalking pod

docker spring boot tomcat skywalking k8s skywalking pod

helm skywalking

k8s helm helm helm

helm helm.sh/docs/intro/

skywalking , Artifact Hub chart GitHub GitHub Artifact Hub

1 Artifact Hub chart skywalking

Artifact Hub chart skywalking

INSTALL helm

skywalking chart

helm repo add choerodon https://openchart.choerodon.com.cn/choerodon/c7n

repo

helm repo list NAME URL oteemocharts https://oteemo.github.io/charts kubeview https://benc-uk.github.io/kubeview/charts oteemo-charts https://oteemo.github.io/charts jenkinsci https://charts.jenkins.io/ ygqygq2 https://ygqygq2.github.io/charts/ prometheus-community https://prometheus-community.github.io/helm-charts my-chart https://wangedison.github.io/k8s-helm-chart/ carlosjgp https://carlosjgp.github.io/open-charts/ choerodon https://openchart.choerodon.com.cn/choerodon/c7n

skywalking

helm search repo skywalking NAME CHART VERSION APP VERSION DESCRIPTION choerodon/skywalking 6.6.0 6.6.0 Apache SkyWalking APM System choerodon/skywalking-oap 0.1.3 0.1.3 skywalking-oap for Choerodon choerodon/skywalking-ui 0.1.4 0.1.4 skywalking-ui for Choerodon choerodon/chart-test 1.0.0 1.0.0 skywalking-ui for Choerodon

chart

# chart [root@k8s-node01 chart-test]# helm pull choerodon/skywalking # [root@k8s-node01 chart-test]# ll total 12 -rw-r--r-- 1 root root 10341 Apr 21 11:12 skywalking-6.6.0.tgz # chart [root@k8s-node01 chart-test]# tar -zxvf skywalking-6.6.0.tgz skywalking/Chart.yaml skywalking/values.yaml skywalking/templates/_helpers.tpl skywalking/templates/istio-adapter/adapter.yaml skywalking/templates/istio-adapter/handler.yaml skywalking/templates/istio-adapter/instance.yaml skywalking/templates/istio-adapter/rule.yaml skywalking/templates/mysql-init.job.yaml skywalking/templates/oap-clusterrole.yaml skywalking/templates/oap-clusterrolebinding.yaml skywalking/templates/oap-deployment.yaml skywalking/templates/oap-role.yaml skywalking/templates/oap-rolebinding.yaml skywalking/templates/oap-serviceaccount.yaml skywalking/templates/oap-svc.yaml skywalking/templates/ui-deployment.yaml skywalking/templates/ui-ingress.yaml skywalking/templates/ui-svc.yaml skywalking/.auto_devops.sh skywalking/.choerodon/.docker/config.json skywalking/.gitlab-ci.yml skywalking/.helmignore skywalking/Dockerfile skywalking/README.md

values.yaml
file:

vim skywalking/values.yamlCopy code

As you can see, the skywalking here uses the mysql database by default, and the version of skywalking used is 6.6.0. You can modify the corresponding version number according to your needs, and save and exit after the modification is completed. For more configuration modification instructions, please refer to the official chart instructions of skywalking .

You can use the following command to install the chart and specify a custom configuration file:

# Usage: helm install [NAME] [CHART] [flags] helm install skywalking skywaling -f skywalking/values.yaml Copy code

Using the above command will install skywalking on

default
Namespace, we can use
-n namespace
The parameter is assigned to a specific namespace, provided that the namespace must exist.

After the installation is successful, you can use the following command to view the installed chart. The installed chart is called release:

helm listcopy code

You can use the following command to uninstall the chart:

# Usage: helm uninstall RELEASE_NAME [...] [flags] helm uninstall skywalking -n default Copy code

2. Download the chart source file from GitHub to deploy skywalking

The GitHub address of skywalking chart is: github.com/apache/skyw...

Use the following command to install in the Linux system

git
:

yum install -y git duplicated code

Use the following command to clone the code:

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

Go to the chart directory of skywalking, you can see the following content:

[root@k8s-node01 chart-test]# cd skywalking-kubernetes/chart/skywalking/ [root@k8s-node01 skywalking]# ll total 84 -rw-r--r-- 1 root root 1382 Apr 21 11:35 Chart.yaml drwxr-xr-x 3 root root 4096 Apr 21 11:35 files -rw-r--r-- 1 root root 877 Apr 21 11:35 OWNERS -rw-r--r-- 1 root root 42593 Apr 21 11:35 README.md drwxr-xr-x 3 root root 4096 Apr 21 11:35 templates -rw-r--r-- 1 root root 1030 Apr 21 11:35 values-es6.yaml -rw-r--r-- 1 root root 1031 Apr 21 11:35 values-es7.yaml -rw-r--r-- 1 root root 1366 Apr 21 11:35 values-my-es.yaml -rw-r--r-- 1 root root 10184 Apr 21 11:35 values.yaml Copy code

You can see that the author has defined three custom configuration files for us very intimately:

values-es6.yaml
,
values-es7.yaml
with
values-my-es.yaml
es6 es7 es es es 6.7.0
values-my-es.yaml

# Default values for skywalking. # This is a YAML-formatted file. # Declare variables to be passed into your templates. oap: image: tag: 8.5.0-es6 # Set the right tag according to the existing Elasticsearch version storageType: elasticsearch # elasticsearch es6 elasticsearch7 es7 ui: image: tag: 8.5.0 elasticsearch: enabled: false # es false true k8s es config: # For users of an existing elasticsearch cluster,takes effect when `elasticsearch.enabled` is false host: your.elasticsearch.host.or.ip port: http: 9200 user: "xxx" # [optional] password: "xxx" # [optional]

values.yaml
ingress GitHub skywalking-kubernetes chart

helm install "${SKYWALKING_RELEASE_NAME}" skywalking -n "${SKYWALKING_RELEASE_NAMESPACE}" -f ./skywalking/values-my-es.yaml

pod

[root@k8s-node01 ~]# kubectl get pod -n default NAME READY STATUS RESTARTS AGE skywalking-es-init-v6sbn 0/1 Completed 0 1h skywalking-oap-5c4d5bf887-4cvjk 1/1 Running 0 1h skywalking-oap-5c4d5bf887-g75fj 1/1 Running 0 1h skywalking-ui-6cd4bbd858-sbpvt 1/1 Running 0 1h

sidecar pod

helm skywalking sidecar pod Java skywalking

SkyWalking Java Agent
java
-javaagent:<skywalking-agent-path>
skywalking agent

  • skywalking-base
  • agent
  • sidecar agent

sidecar pod sidecar volume agent sidecar pod skywalking agent pod

1 init container

Init Container Init Container Pod Init Container

2 skywalking agent

sidecar java skywalking skywalking agent

  • skywalking agent
# skywalking-8.5.0 for es6 skywalking wget https://www.apache.org/dyn/closer.cgi/skywalking/8.5.0/apache-skywalking-apm-8.5.0.tar.gz # tar -zxvf apache-skywalking-apm-8.5.0.tar.gz
  • skywalking Dockerfile
FROM busybox:latest LABEL maintainer="xiniao" COPY apache-skywalking-apm-bin/agent//usr/skywalking/agent/

Dockefile bosybox SkyWalking sidecar

docker build -t skywalking-agent-sidecar:8.5.0 .

docker images |grep agent skywalking-agent-sidecar 8.5.0 98290e961b49 5 days ago 32.6MB
docker tag skywalking-agent-sidecar:8.5.0 registry.cn-shenzhen.aliyuncs.com/devan/skywalking-agent-sidecar:8.5.0

docker push registry.cn-shenzhen.aliyuncs.com/devan/skywalking-agent-sidecar:8.5.0

3 sidecar skywalking

SkyWalking Java Agent Docker Kubernetes Java K8s SideCar Agent SkyWalking

  • deploy-skywalking.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: spring-boot-skywalking-demo namespace: default labels: app: spring-boot-skywalking-demo spec: replicas: 1 selector: matchLabels: app: spring-boot-skywalking-demo template: metadata: labels: app: spring-boot-skywalking-demo spec: # ( SkyWalking Agent) initContainers: - image: registry.cn-shenzhen.aliyuncs.com/devan/skywalking-agent-sidecar:8.5.0 name: sw-agent-sidecar imagePullPolicy: IfNotPresent command: [ "sh" ] args: [ "-c", "cp -R/usr/skywalking/agent/*/skywalking/agent", ] volumeMounts: - mountPath: /skywalking/agent name: sw-agent containers: - name: spring-boot-skywalking-demo image: ${ORIGIN_REPO}/spring-boot-skywalking-demo:${IMAGE_TAG} imagePullPolicy: Always env: - name: TZ value: Asia/Shanghai - name: BUILD_TAG value: ${BUILD_TAG} - name: NAMESPACE value: default # JAVA_TOOL_OPTIONS JAVA_OPTS agent java jvm agent - name: JAVA_TOOL_OPTIONS value: -javaagent:/usr/skywalking/agent/skywalking-agent.jar - name: SW_AGENT_NAME value: spring-boot-skywalking-demo - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES # FQDN: servicename.namespacename.svc.cluster.local value: skywalking-oap.default.svc:11800 ports: - containerPort: 8080 resources: requests: cpu: 200m memory: 500Mi volumeMounts: - mountPath: /usr/skywalking/agent name: sw-agent volumes: - name: sw-agent emptyDir: { } --- apiVersion: v1 kind: Service metadata: name: spring-boot-skywalking-demo namespace: default labels: app: spring-boot-skywalking-demo spec: ports: - name: port port: 80 protocol: TCP targetPort: 8080 selector: app: spring-boot-skywalking-demo type: ClusterIP

spec.volumes
pod
spec.containers.volumeMounts
mount docker
-v
emptyDir{}
Pod
sh -c cp -R/usr/skywalking/agent/*/skywalking/agent
skywalking agent skywalking agent

kubectl apply -f deploy-skywalking.yaml

helm skywalking helm chart pod SideCar SkyWalking initContainers

k8s SkyWalking