xxl-job本地部署到容器部署到k8s部署
1,环境要求环境Maven3+Jdk1.8+Mysql5.7+我的环境采用的mysql 8.0 maven 3.0openjdk1.8虚拟机 10.1.234.141 10.1.234.142 10.1.234.143yum -y install java-1.8.0-openjdkyum -y install maven[root@linux-host1 ~]# mvn -vApache Mav
·
1,环境要求环境
- Maven3+
- Jdk1.8+
- Mysql5.7+
- 我的环境采用的mysql 8.0 maven 3.0 openjdk1.8
- 虚拟机 10.1.234.141 10.1.234.142 10.1.234.143 centos7.6
- 架构图
yum -y install java-1.8.0-openjdk
yum -y install maven
[root@linux-host1 ~]# mvn -v
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_262, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.el7.x86_64", arch: "amd64", family: "unix"
导入数据
修改mav 加速地址,添加
<mirror>
<id>central</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
源码地址 http://gitee.com/xuxueli0323/xxl-job/releases
git clone https://gitee.com/xuxueli0323/xxl-job.git
[root@linux-host1 xxl-job]# cat xxl-job-admin/src/main/resources/application.properties
### web
server.port=8080
server.servlet.context-path=/xxl-job-admin
### actuator
management.server.servlet.context-path=/actuator
management.health.mail.enabled=false
### resources
spring.mvc.servlet.load-on-startup=0
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/static/
### freemarker
spring.freemarker.templateLoaderPath=classpath:/templates/
spring.freemarker.suffix=.ftl
spring.freemarker.charset=UTF-8
spring.freemarker.request-context-attribute=request
spring.freemarker.settings.number_format=0.##########
### mybatis
mybatis.mapper-locations=classpath:/mybatis-mapper/*Mapper.xml
#mybatis.type-aliases-package=com.xxl.job.admin.core.model
### xxl-job, datasource
spring.datasource.url=jdbc:mysql://10.1.1.245:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=Rp000000
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
### datasource-pool
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.maximum-pool-size=30
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=HikariCP
spring.datasource.hikari.max-lifetime=900000
spring.datasource.hikari.connection-timeout=10000
spring.datasource.hikari.connection-test-query=SELECT 1
spring.datasource.hikari.validation-timeout=1000
### xxl-job, email
spring.mail.host=smtp.qq.com
spring.mail.port=25
spring.mail.username=xxx@qq.com
spring.mail.from=xxx@qq.com
spring.mail.password=xxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
### xxl-job, access token
xxl.job.accessToken=
### xxl-job, i18n (default is zh_CN, and you can choose "zh_CN", "zh_TC" and "en")
xxl.job.i18n=zh_CN
## xxl-job, triggerpool max size
xxl.job.triggerpool.fast.max=200
xxl.job.triggerpool.slow.max=100
### xxl-job, log retention days
xxl.job.logretentiondays=7 #日志保留天数
#编译
mvn clean package -Dmaven.test.skip=true
运行
java -jar xxl-job-admin/target/xxl-job-admin-2.2.1-SNAPSHOT.jar
访问:http://10.1.234.141:8080/xxl-job-admin/toLogin 账户密码 : admin 123456
封装镜像
/root/xxl-job/xxl-job-admin
[root@linux-host1 xxl-job-admin]# cat Dockerfile
FROM openjdk:8-jre-slim
MAINTAINER xuxueli
ENV PARAMS=""
ENV TZ=PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ADD target/xxl-job-admin-*.jar /app.jar
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /app.jar $PARAMS"]
docker build -t 10.1.234.11/data/xxl-job:v2 .
docker push 10.1.234.11/data/xxl-job:v2
docker run -itd --name xxl-admin -p 8080:8080 10.1.234.11/data/xxl-job:v2
k8s部署
[root@k8s-master1 k8s]# cat xxl-job-admin.yaml
#apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: xxl-job-admin
spec:
replicas: 1
selector:
matchLabels:
app: xxl-job-admin
template:
metadata:
labels:
app: xxl-job-admin
spec:
imagePullSecrets:
- name: registry-pull-secret
containers:
- name: xxl-job-admin
image: 10.1.234.11/data/xxl-job:v2
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: xxl-job-admin
labels:
app: xxl-job-admin
spec:
type: NodePort
ports:
- port: 8080
protocol: TCP
name: http
selector:
app: xxl-job-admin
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: xxl-job-admin
spec:
rules:
- host: xxl.rpdns.com
http:
paths:
- path: '/'
backend:
serviceName: xxl-job-admin
servicePort: 8080
[root@k8s-master1 k8s]# kubectl get pods,svc
NAME READY STATUS RESTARTS AGE
pod/jenkins-fcc9d45fc-mjgnj 1/1 Running 5 41d
pod/nfs-client-provisioner-6f757c7c9-txk9m 1/1 Running 4 42d
pod/xxl-job-admin-7d98875dc7-pxrn9 1/1 Running 0 35m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/jenkins NodePort 10.0.0.121 <none> 80:30006/TCP,50000:30052/TCP 41d
service/kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 46d
service/xxl-job-admin NodePort 10.0.0.21 <none> 8080:31724/TCP 39m
更多推荐
已为社区贡献4条内容
所有评论(0)