Openshift或者K8S上部署xxl-job

本案例以版本2.3.0为例

1. package jar by source code

source code:
https://github.com/xuxueli/xxl-job/blob/2.3.0/

2. init mysql database

sql code:
https://github.com/xuxueli/xxl-job/blob/2.3.0/doc/db/tables_xxl_job.sql

3. build image:

refer to:
https://github.com/xuxueli/xxl-job/blob/2.3.0/xxl-job-admin/Dockerfile

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"]

4. deploy on ocp

yaml 复制代码
kind: Deployment
apiVersion: apps/v1
metadata:
  name: xxl-job
  labels:
    app.kubernetes.io/instance: xxl-job
spec:
  replicas: 1
  selector:
    matchLabels:
      app: xxl-job
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: xxl-job
        deployment: xxl-job
    spec:
      containers:
        - resources:
            limits:
              cpu: '1'
              memory: 4Gi
            requests:
              cpu: 500m
              memory: 4Gi
          readinessProbe:
            tcpSocket:
              port: 8080
            initialDelaySeconds: 30
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          name: xxl-job
          livenessProbe:
            tcpSocket:
              port: 8080
            initialDelaySeconds: 30
            timeoutSeconds: 1
            periodSeconds: 30
            successThreshold: 1
            failureThreshold: 3
          env:
            - name: PARAMS
              value: '--spring.datasource.url=jdbc:mysql://xxx:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai  --spring.datasource.username=xxx --spring.datasource.password=xxx' ###这里需要填写mysql的连接信息
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          image: 'xxx' ## xxl-job的镜像地址
      restartPolicy: Always
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  revisionHistoryLimit: 1
---
kind: Service
apiVersion: v1
metadata:
  name: xxl-job
spec:
  ports:
    - name: 8080-tcp
      protocol: TCP
      port: 8080
      targetPort: 8080
  type: ClusterIP
  selector:
    deployment: xxl-job
---
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
  name: xxl-job
spec:
  ingressClassName: openshift-default
  rules:
    - host: xxx ## 这边填写域名
      http:
        paths:
          - path: /xxl-job-admin
            pathType: Prefix
            backend:
              service:
                name: xxl-job
                port:
                  name: 8080-tcp

5. visit xxl-job web

初始的

username: admin

password: 123456

相关推荐
ghostwritten1 小时前
Docker Registry Clean
运维·docker·容器
宋冠巡2 小时前
Windows安装Docker(Docker Desktop)
windows·docker·容器
小马爱打代码3 小时前
Kubernetes 中部署 Ceph,构建高可用分布式存储服务
分布式·ceph·kubernetes
阿噜噜小栈3 小时前
最新国内可用的Docker镜像加速器地址收集
运维·笔记·docker·容器
云上艺旅3 小时前
K8S学习之基础六十八:Rancher创建deployments资源
学习·云原生·容器·kubernetes·rancher
rider1893 小时前
【4】搭建k8s集群系列(二进制部署)之安装master节点服务(kube-apiserver)
云原生·容器·kubernetes
海鸥815 小时前
podman和与docker的比较 及podman使用
docker·容器·podman
GreenMountainEcho11 小时前
Kubernetes 入门篇之 Node 安装与部署
云原生·容器·kubernetes
zyk_52012 小时前
Docker desktop如何汉化
运维·docker·容器
韭菜盖饭12 小时前
解决Docker端口映射后外网无法访问的问题
运维·docker·容器