本文介绍: 一、安装K8S集群kubeadm部署K8s集群V1.19.0二、部署skywalking2.1.创建命名空间2.2.给节点打标签。
一、安装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
原文地址:https://blog.csdn.net/zhangjunli/article/details/135335175
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_52416.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。