制作镜像
OAP镜像
# cat oap/Dockerfile
FROM apache/skywalking-oap-server:8.5.0-es7
# 时区修改为东八区
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# docker build -t registry-vpc.cn-beijing.aliyuncs.com/hmy_repo/oap:8.5 .
#上传到私由仓库
# docker push registry-vpc.cn-beijing.aliyuncs.com/hmy_repo/oap:8.5
UI镜像
# cat ui/Dockerfile
FROM apache/skywalking-ui:8.5.0
# 时区修改为东八区
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# docker build -t registry-vpc.cn-beijing.aliyuncs.com/hmy_repo/oap-ui-8.5-v1 .
#上传到私由仓库
# docker push registry-vpc.cn-beijing.aliyuncs.com/hmy_repo/oap-ui-8.5-v1
Agent镜像
agent 下载地址没有变动项:https://archive.apache.org/dist/skywalking/8.5.0/apache-skywalking-apm-es7-8.5.0.tar.gz
# cat Dockerfile
FROM alpine:3
# 时区修改为东八区
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV LANG=C.UTF-8
RUN set -eux && mkdir -p /data
ADD agent /data/agent
WORKDIR /
# docker build -t registry-vpc.cn-beijing.aliyuncs.com/hmy_repo/skywalking-agent:8.5 .
#上传到私由仓库
# docker push registry-vpc.cn-beijing.aliyuncs.com/hmy_repo/skywalking-agent:8.5
部署skywalking服务
部署oap
# cat oap.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: skywalking-oap
namespace: skywalking
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: skywalking-oap
namespace: skywalking
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: skywalking-oap
subjects:
- kind: ServiceAccount
name: skywalking-oap
namespace: skywalking
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: skywalking
name: skywalking-oap
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: oap
release: oap
name: oap
namespace: skywalking
spec:
replicas: 1
selector:
matchLabels:
app: oap
release: oap
template:
metadata:
labels:
app: oap
release: oap
spec:
imagePullSecrets:
- name: harborsecret
containers:
- env:
- name: JAVA_OPTS
#value: -Dmode=no-init -Xmx2g -Xms2g
value: -Xmx2g -Xms2g
- name: SW_CLUSTER
value: kubernetes
- name: SW_CLUSTER_K8S_NAMESPACE #集群命名空间
value: skywalking
- name: SW_CLUSTER_K8S_LABEL
value: app=oap,release=oap
- name: SKYWALKING_COLLECTOR_UID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.uid
- name: SW_STORAGE #存储类型
value: elasticsearch7
- name: SW_STORAGE_ES_CLUSTER_NODES #es地址
value: 172.17.226.61:9200
# - name: SW_ES_USER
# value: ""
# - name: SW_ES_PASSWORD
# value: ""
image: registry.cn-beijing.aliyuncs.com/hmy_repo/oap:8.5v1
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 15
periodSeconds: 20
successThreshold: 1
tcpSocket:
port: 12800
timeoutSeconds: 1
name: oap
ports:
- containerPort: 11800
name: grpc
protocol: TCP
- containerPort: 12800
name: rest
protocol: TCP
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 15
periodSeconds: 20
successThreshold: 1
tcpSocket:
port: 12800
timeoutSeconds: 1
initContainers:
- command:
- sh
- -c
- for i in $(seq 1 60); do nc -z -w3 172.17.226.61 9200 && exit 0 || sleep
5; done; exit 1
image: busybox:1.30
imagePullPolicy: Always
name: wait-for-elasticsearch
restartPolicy: Always
serviceAccount: skywalking-oap
serviceAccountName: skywalking-oap
---
apiVersion: v1
kind: Service
metadata:
labels:
app: oap
name: oap-svc
namespace: skywalking
spec:
ports:
- name: rest
port: 12800
protocol: TCP
targetPort: 12800
- name: grpc
port: 11800
protocol: TCP
targetPort: 11800
selector:
app: oap
sessionAffinity: None
type: ClusterIP
部署ui
# cat ui.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: ui
release: ui
name: ui
namespace: skywalking
spec:
replicas: 1
selector:
matchLabels:
app: ui
release: ui
template:
metadata:
labels:
app: ui
release: ui
spec:
imagePullSecrets:
- name: harborsecret
containers:
- env:
- name: SW_OAP_ADDRESS #oap地址
value: oap-svc:12800
- name: security.user.admin.password #账号密码
value: admin
image: registry-vpc.cn-beijing.aliyuncs.com/hmy_repo/oap-ui-8.5-v1:latest
imagePullPolicy: Always
name: ui
ports:
- containerPort: 8080
name: page
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
labels:
app: ui
name: ui-svc
namespace: skywalking
spec:
externalTrafficPolicy: Cluster
ports:
- nodePort: 31234
port: 80
protocol: TCP
targetPort: 8080
selector:
app: ui
sessionAffinity: None
type: NodePort
查看获取对于的ui
kubectl get svc -n skywalking
skywalking ui-svc NodePort 10.68.98.32 <none> 80:31234/TCP 53s
集成sidecar
# cat x-admin.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: x-admin
namespace: skywalking
labels:
app: x-admin
spec:
replicas: 1
selector:
matchLabels:
app: x-admin
template:
metadata:
labels:
app: x-admin
spec:
imagePullSecrets:
- name: harborsecret
initContainers:
- name: sidecar
image: registry-vpc.cn-beijing.aliyuncs.com/hmy_repo/skywalking-agent:8.5 # 容器镜像,包含静态资源文件
imagePullPolicy: Always
command: ["cp", "-r", "/data/agent", "/sidecar"]
volumeMounts:
- name: sidecar
mountPath: /sidecar
containers:
- name: x-admin
image: registry.cn-beijing.aliyuncs.com/hmy_repo/x-admin:master-33
imagePullPolicy: Always
env:
- name: JAVA_TOOL_OPTIONS
value: -javaagent:/sidecar/agent/skywalking-agent.jar
- name: SW_AGENT_NAME
value: x-admin
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES #oap地址
value: oap-svc:11800
resources:
limits:
memory: "1Gi"
requests:
memory: "1Gi"
ports:
- name: http
containerPort: 8080
protocol: TCP
volumeMounts:
- name: date
mountPath: /etc/localtime
- name: sidecar
mountPath: /sidecar
volumes:
- name: date
hostPath:
path: /etc/localtime
- name: sidecar #共享agent文件夹
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: x-admin-svc
namespace: skywalking
labels:
app: x-admin
spec:
sessionAffinity: "ClientIP"
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
nodePort: 30836
selector:
app: x-admin
type: NodePort