1.下载sentinel的jar包
wget https://github.com/alibaba/Sentinel/releases/download/1.8.3/sentinel-dashboard-1.8.3.jar
2.编写dockerfile
[root@k8s-matser01 teste]# cat Dockerfile
FROM openjdk:8-jdk-alpine
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV LC_ALL "zh_CN.UTF-8"
COPY sentinel-dashboard-1.8.3.jar /tmp/sentinel-dashboard-1.8.1.jar
CMD java ${JAVA_OPTS} -jar /tmp/sentinel-dashboard-1.8.1.jar
3.编写yaml文件
[root@k8s-matser01 teste]# cat sentinel.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: sentinel
spec:
serviceName: sentinel
replicas: 1
template:
metadata:
labels:
app: sentinel
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
containers:
- name: sentinel
imagePullPolicy: IfNotPresent
image: sentinel:v1
ports:
- containerPort: 8080
name: client
env:
- name: TZ
value: Asia/Shanghai
- name: JAVA_OPTS
value: "-Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dsentinel.dashboard.auth.username=sentinel -Dsentinel.dashboard.auth.password=sentinel -Dserver.servlet.session.timeout=7200" # 配置端口 配置账号密码 配置session超时时间,默认账号密码都是sentinel
selector:
matchLabels:
app: sentinel
---
apiVersion: v1
kind: Service
metadata:
name: sentinel-svc
labels:
app: sentinel
spec:
ports:
- protocol: TCP
name: http
port: 8080
targetPort: 8080
nodePort: 31808
type: NodePort
selector:
app: sentinel
4.查看服务
[root@k8s-matser01 teste]# kubectl get pod |grep sentinel
sentinel-0 1/1 Running 0 12m
[root@k8s-matser01 teste]# kubectl get svc |grep sentinel
sentinel-svc NodePort 10.100.189.97 <none> 8080:31808/TCP 12m
###