1.初始化数据库
wget https://raw.githubusercontent.com/xuxueli/xxl-job/2.1.2/doc/db/tables_xxl_job.sql mysql -uroot -p source /root/tables_xxl_job.sql; CREATE USER 'xxl_job'@'%' IDENTIFIED BY 'OYP!z5%0O2lALdLi'; GRANT ALL PRIVILEGES ON xxl_job.* TO 'xxl_job'@'%'; FLUSH PRIVILEGES; exit;
2.创建xxl-job配置文件
apiVersion: v1 kind: ConfigMap metadata: name: xxl-job-admin-config namespace: t1-zdbl data: PARAMS: >- --spring.datasource.url=jdbc:mysql://t1-zdbl-mysql.t1-zdbl.svc.cluster.local:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai --spring.datasource.username=xxl_job --spring.datasource.password=OYP!z5%0O2lALdLi --server.servlet.context-path=/
3.创建xxl-job部署文件
apiVersion: apps/v1 kind: Deployment metadata: name: t1-zdbl-xxl-job namespace: t1-zdbl spec: replicas: 1 selector: matchLabels: app: t1-zdbl-xxl-job template: metadata: labels: app: t1-zdbl-xxl-job spec: containers: - name: xxl-job image: xuxueli/xxl-job-admin:2.1.2 ports: - containerPort: 8080 env: - name: PARAMS valueFrom: configMapKeyRef: name: xxl-job-admin-config key: PARAMS
4.创建xxl-job svc文件
apiVersion: v1 kind: Service metadata: name: t1-zdbl-xxl-job namespace: t1-zdbl labels: app: t1-zdbl-xxl-job spec: type: NodePort ports: - name: web-8080 port: 8080 targetPort: 8080 nodePort: 31080 selector: app: t1-zdbl-xxl-job
初始数据库后,应用以上文件即可