仅用于测试环境es没做持久化,正式环境最好还是把es数据做一下持久化。
这里选择的是8.1.0版本须要对应
https://mirrors.tuna.tsinghua.edu.cn/apache/skywalking/8.1.0/apache-skywalking-apm-8.1.0.tar.gz
可以使用pvc方式或hostpath方式把agent目录挂载到容器内。
启动项目jar前加上javaagent文件地址。
- command:
- java
- -javaagent:/data/agent/skywalking-agent.jar # 这里的路径可以是相对路径
- -jar
- demo.jar
注入环境变量加入skywalking信息
env:
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: skywalking-oap-server.skywalking:11800 # 指定sw访问地址:端口
- name: SW_AGENT_NAME
value: demo # 指定注册上后服务名字
创建namespaces
kubectl create namespace skywalking
apiVersion: v1
kind: Service
metadata:
labels:
app: elasticsearch-service
name: elasticsearch
namespace: skywalking
spec:
ports:
- name: http
port: 9200
protocol: TCP
targetPort: 9200
- name: tcp
port: 9300
protocol: TCP
targetPort: 9300
selector:
app: elasticsearch
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: elasticsearch
name: elasticsearch
namespace: skywalking
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
spec:
containers:
- env:
- name: TZ
value: CST-8
- name: discovery.type
value: single-node
# image: elasticsearch:6.8.14
image: registry.cn-chengdu.aliyuncs.com/lswzw/elasticsearch:6.8.14
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 2
successThreshold: 1
tcpSocket:
port: 9300
timeoutSeconds: 2
name: elasticsearch
ports:
- containerPort: 9200
name: http
protocol: TCP
- containerPort: 9300
name: tcp
protocol: TCP
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 2
successThreshold: 2
tcpSocket:
port: 9300
timeoutSeconds: 2
resources:
limits:
cpu: "2"
memory: 2Gi
requests:
cpu: 200m
memory: 512Mi
apiVersion: v1
kind: Service
metadata:
labels:
app: skywalking-oap-server-service
name: skywalking-oap-server
namespace: skywalking
spec:
ports:
- name: grpc
port: 11800
protocol: TCP
targetPort: 11800
- name: tcp
port: 12800
protocol: TCP
targetPort: 12800
selector:
app: skywalking-oap-server
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: skywalking-oap-server
name: skywalking-oap-server
namespace: skywalking
spec:
replicas: 1
selector:
matchLabels:
app: skywalking-oap-server
template:
metadata:
labels:
app: skywalking-oap-server
spec:
containers:
- env:
- name: SW_STORAGE
value: elasticsearch
- name: SW_STORAGE_ES_CLUSTER_NODES
value: elasticsearch:9200
- name: TZ
value: CST-8
# image: apache/skywalking-oap-server:8.1.0-es6
image: registry.cn-chengdu.aliyuncs.com/lswzw/skywalking-oap-server:8.1.0-es6
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 2
successThreshold: 1
tcpSocket:
port: 12800
timeoutSeconds: 2
name: skywalking-oap-server
ports:
- containerPort: 11800
name: grpc
protocol: TCP
- containerPort: 12800
name: tcp
protocol: TCP
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 2
successThreshold: 2
tcpSocket:
port: 12800
timeoutSeconds: 2
resources:
limits:
cpu: "2"
memory: 4Gi
requests:
cpu: 200m
memory: 512Mi
apiVersion: v1
kind: Service
metadata:
labels:
app: skywalking-ui-service
name: skywalking-ui
namespace: skywalking
spec:
ports:
- name: tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: skywalking-ui
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: skywalking-ui
name: skywalking-ui
namespace: skywalking
spec:
replicas: 1
selector:
matchLabels:
app: skywalking-ui
template:
metadata:
labels:
app: skywalking-ui
spec:
containers:
- env:
- name: SW_OAP_ADDRESS
value: skywalking-oap-server:12800
- name: TZ
value: CST-8
# image: apache/skywalking-ui:8.1.0
image: registry.cn-chengdu.aliyuncs.com/lswzw/skywalking-ui:8.1.0
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 15
periodSeconds: 2
successThreshold: 1
tcpSocket:
port: 8080
timeoutSeconds: 2
name: skywalking-ui
ports:
- containerPort: 8080
name: tcp
protocol: TCP
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 15
periodSeconds: 2
successThreshold: 2
tcpSocket:
port: 8080
timeoutSeconds: 2
resources:
limits:
cpu: "2"
memory: 1Gi
requests:
cpu: 200m
memory: 128Mi
apiVersion: v1
kind: Service
metadata:
labels:
app: elasticsearch-hq-service
name: elasticsearch-hq
namespace: skywalking
spec:
ports:
- name: http
port: 5000
protocol: TCP
targetPort: 5000
selector:
app: elasticsearch-hq
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: elasticsearch-hq
name: elasticsearch-hq
namespace: skywalking
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch-hq
template:
metadata:
labels:
app: elasticsearch-hq
spec:
containers:
- env:
- name: TZ
value: CST-8
# image: elastichq/elasticsearch-hq
image: registry.cn-chengdu.aliyuncs.com/lswzw/elasticsearch-hq:3.5.12
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 2
successThreshold: 1
tcpSocket:
port: 5000
timeoutSeconds: 2
name: elasticsearch-hq
ports:
- containerPort: 5000
name: http
protocol: TCP
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 2
successThreshold: 2
tcpSocket:
port: 5000
timeoutSeconds: 2
resources:
limits:
cpu: "2"
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi