k8s:部署sentinel-dashboard
1、构建镜像(DockerFile)FROM java8-alpineMAINTAINER lusainVOLUME /tmpADD ./sentinel-dashboard/target/*.jar sentinel-dashboard.jarEXPOSE 8080CMD java ${JAVA_OPTS} -jar sentinel-dashboard.jar构建:目录1、构建镜像(Docke
·
目录
1、构建镜像(DockerFile)
FROM java8-alpine
MAINTAINER lusain
VOLUME /tmp
ADD ./sentinel-dashboard/target/*.jar sentinel-dashboard.jar
EXPOSE 8080
CMD java ${JAVA_OPTS} -jar sentinel-dashboard.jar
构建:
docker build -t hub.com/sentinel-dashboard:v2 .
2、本地测试镜像(docker-compose)
version: "2"
services:
namesrv:
image: hub.com/sentinel-dashboard:v2
container_name: sentinel-dashboard
ports:
- 30080:8080
environment:
- JAVA_OPTS= -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dsentinel.dashboard.auth.username=sentinel -Dsentinel.dashboard.auth.password=sentinel -Dserver.servlet.session.timeout=7200
启动容器:
docker-compose up -d
浏览器访问:localhost:30080
3、创建StatefulSet和service
新增sentinel.yaml
# 外部访问服务
apiVersion: v1
kind: Service
metadata:
name: sentinel
labels:
app: sentinel
spec:
ports:
- protocol: TCP
name: http
port: 8858
targetPort: 8080
type: ClusterIP
selector:
app: sentinel
---
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: hub.com//sentinel-dashboard:v2
resources:
limits:
memory: "1Gi"
cpu: "1"
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"
selector:
matchLabels:
app: sentinel
k8s部署:
kubectl apply -f sentinel.yaml
4、通过serviceIP访问
更多推荐
已为社区贡献1条内容
所有评论(0)