k8s部署xxl-job

https://www.xuxueli.com/xxl-job/

下载项目源码并解压,获取 "调度数据库初始化SQL脚本" 并执行即可

数据库初始化SQL脚本位置: /xxl-job/doc/db/tables_xxl_job.sql

Secret

yaml 复制代码
apiVersion: v1
data:
  mysql.database: eHhsX2pvYg==
  mysql.password: VFNIQG5hY29zZGIjMjAyNWxhbg==
  mysql.url: eHhsLWpvYi1hZG1pbi5zcHJpbmcuZGF0YXNvdXJjZS51cmw=
  mysql.user: eHhsLWpvYg==
kind: Secret
metadata:
  labels:
    app: xxl-job-admin
  name: xxl-job-admin-creds
  namespace: default
type: Opaque

ConfigMap

yaml 复制代码
apiVersion: v1
data:
  application.yaml: |-
    management:
      health:
        mail:
          enabled: false
      server:
        servlet:
          context-path: /actuator
    mybatis:
      mapper-locations: classpath:/mybatis-mapper/*Mapper.xml
    server:
      port: 8080
      servlet:
        context-path: /xxl-job-admin
    spring:
      datasource:
        driver-class-name: com.mysql.cj.jdbc.Driver
        hikari:
          auto-commit: true
          connection-test-query: SELECT 1
          connection-timeout: 10000
          idle-timeout: 30000
          max-lifetime: 900000
          maximum-pool-size: 30
          minimum-idle: 10
          pool-name: HikariCP
          validation-timeout: 1000
        password: xxxxxx
        type: com.zaxxer.hikari.HikariDataSource
        url: jdbc:mysql://x.x.x.x:3306/xxl_job?useUnicode=true&useSSL=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=UTC
        username: xxl_job
      freemarker:
        charset: UTF-8
        request-context-attribute: request
        settings:
          number_format: 0.##########
        suffix: .ftl
        templateLoaderPath: classpath:/templates/
      mail:
        properties:
          mail:
            smtp:
              auth: true
              socketFactory:
                class: javax.net.ssl.SSLSocketFactory
              starttls:
                enable: true
                required: true
      mvc:
        servlet:
          load-on-startup: 0
        static-path-pattern: /static/**
      resources:
        static-locations: classpath:/static/
    xxl:
      job:
        accessToken: LUX9CiMlatGviDtzLCTBJo4eElan
        i18n: zh_CN
        logretentiondays: 10
        triggerpool:
          fast:
            max: 200
          slow:
            max: 100
kind: ConfigMap
metadata:
  labels:
    app: xxl-job-admin
  name: xxl-job-admin-config
  namespace: default

Deployment

yaml 复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: xxl-job-admin
  name: xxl-job-admin
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: xxl-job-admin
  template:
    metadata:
      labels:
        app: xxl-job-admin
    spec:
      containers:
      - env:
        - name: SPRING_CONFIG_IMPORT
          value: optional:configtree:/var/run/secrets/spring/
        - name: TZ
          value: Asia/Shanghai
        image: xuxueli/xxl-job-admin
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /xxl-job-admin/actuator/health/liveness
            port: http
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: xxl-job-admin
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /xxl-job-admin/actuator/health/readiness
            port: http
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          limits:
            cpu: "1"
            memory: 2Gi
          requests:
            cpu: "1"
            memory: 2Gi
        startupProbe:
          failureThreshold: 30
          httpGet:
            path: /xxl-job-admin/actuator/health/liveness
            port: http
            scheme: HTTP
          initialDelaySeconds: 15
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        volumeMounts:
        - mountPath: /config
          name: config
        - mountPath: /var/run/secrets/spring/
          name: creds
        - mountPath: /etc
          name: timezone-conf
          subPath: timezone
      imagePullSecrets:
      - name: default-secret
      initContainers:
      - command:
        - cp
        - -rf
        - /usr/share/zoneinfo/Asia/Shanghai
        - /etc/localtime
        image: xuxueli/xxl-job-admin
        imagePullPolicy: IfNotPresent
        name: change-timezone
        volumeMounts:
        - mountPath: /etc
          name: timezone-conf
          subPath: timezone
      restartPolicy: Always
      volumes:
      - configMap:
          defaultMode: 420
          name: xxl-job-admin-config
        name: config
      - name: creds
        secret:
          defaultMode: 420
          secretName: xxl-job-admin-creds
      - emptyDir: {}
        name: timezone-conf

Service

yaml 复制代码
apiVersion: v1
kind: Service
metadata:
  labels:
    app: xxl-job-admin
  name: xxl-job-admin
  namespace: default
spec:
  allocateLoadBalancerNodePorts: true
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  ports:
  - name: http
    nodePort: 30970
    port: 32765
    protocol: TCP
    targetPort: 8080
  selector:
    app: xxl-job-admin
  type: LoadBalancer
相关推荐
liao__ran2 分钟前
Kubernetes攻防 Docker in Docker
docker·容器·kubernetes
Nice_Fold11 分钟前
Kubernetes命名空间与Pod核心概念(自用笔记)
笔记·容器·kubernetes
Dillon Dong12 小时前
【系列主题】Next.js 16 + Turbopack 的暗礁:深入剖析 Tailwind v4 的 CSS 模块解析陷阱
javascript·css·容器·turbopack
JellyfishMIX15 小时前
k8s 容器 cpu 概念
docker·容器·kubernetes
BIGmustang17 小时前
基于rancher-rke部署 k8s集群
容器·kubernetes·rancher
Cat_Rocky18 小时前
通过k8s实现单pod部署
java·容器·kubernetes
运维全栈笔记18 小时前
K8S部署WordPress+MySQL:模块化YAML配置详解
服务器·mysql·docker·云原生·容器·kubernetes·服务发现
眷蓝天19 小时前
k8s-pod资源对象实验
云原生·容器·kubernetes·pod资源对象
木雷坞19 小时前
Physical AI 数据工厂怎么落地?先把 CUDA、K8s、Quay 镜像拉取稳定下来
人工智能·容器·kubernetes
剩下了什么21 小时前
docker-compose up -d --build 和 docker-compose up -d 和 docker-compose build 区别
docker·容器·eureka