xxl-job-executor执行器部署到k8s中时,port报错

发布时间 2023-09-11 16:09:16作者: 开拓丿飞

错误:

15:48:21.902 logback [main] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxlJobConfig': Unsatisfied dependency expressed through field 'port'; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "tcp://10.97.252.95:9999"

 原因:xxl.job.executor.port配置被k8s重写了

解决方法:

传递启动参数 PARAMS=--xxl.job.executor.port=9999

apiVersion: apps/v1
kind: Deployment
metadata:
  name: xxl-job-executor
  labels:
    name: xxl-job-executor
spec:
  replicas: 1
  selector:
    matchLabels:
      name: xxl-job-executor
  template:
    metadata:
      labels:
        name: xxl-job-executor
    spec:
      containers:
      - name: xxl-job-executor
        image: xxl-job-executor:1.0.0
        ports:
        - containerPort: 9999
          protocol: TCP
        env: 
        - name: PARAMS
          value: --xxl.job.executor.port=9999
      imagePullSecrets:
        - name: public-docker-registry-secret

解决: