• XXLJOB



    1. 修改jar包中的文件

      # 修改datasource地址
      <root@SYS-OPS-JKS02 ~/a># cat BOOT-INF/classes/application.properties
      ### web
      server.port=8080
      server.context-path=/admin
       
      ### resources
      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
       
      ### xxl-job, datasource
      spring.datasource.url=jdbc:mysql://rm-bp16vh718ptga7fpy.mysql.rds.aliyuncs.com:3306/xl-job?Unicode=true&characterEncoding=UTF-8
       
      ## 重新打包 
      <root@SYS-OPS-JKS02 ~/a># jar uvf xxl-job.jar BOOT-INF/classes/application.properties
      adding: BOOT-INF/classes/application.properties(in = 1560) (out= 668)(deflated 57%)
    2. Dockerfile如下

      ## pre-xxl-job Dockerfile
      #####################
      ### xxl-job 2.1.1 ###
      #####################
      FROM openjdk:8u262
        
      ENV XXL_HOME /usr/local/xxl-job-admin
      WORKDIR $XXL_HOME
      ADD xxl-job.jar ./xxl-job.jar
        
      RUN set -x \
          && apt-get update \
          && apt-get install --no-install-recommends --no-install-suggests -y net-tools vim telnet \
          && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
          && mkdir /opt/settings /opt/data
        
      EXPOSE 8080/tcp
        
      CMD ["sh","-c","java -jar $JAVA_OPTS xxl-job.jar"]
    3. 制作镜像,如下

      <root@Registry ~/pre-xxl-job># docker build -t hub.qiangyun.com/pre-xl-job -f Dockerfile .
      Sending build context to Docker daemon  28.76MB
      Step 1/7 : FROM openjdk:8u262
      8u262: Pulling from library/openjdk
      31dd5ebca5ef: Pull complete
      3ed641c4ae98: Pull complete
      bcd57146431e: Pull complete
      ac34a4d7c330: Pull complete
      d29274a3f575: Pull complete
      1b90ee88ecd5: Pull complete
      72ca6adee6d9: Pull complete
      Digest: sha256:a42c71e57f4787e4fadb62c99ebcf174f8fd531580a8e5a0f4b95d9c47886e95
      Status: Downloaded newer image for openjdk:8u262
       ---> 65070f0f6068
      Step 2/7 : ENV XXL_HOME /usr/local/xxl-job-admin
       ---> Running in 5cd54d6ac674
      Removing intermediate container 5cd54d6ac674
       ---> de97762745f3
      Step 3/7 : WORKDIR $XXL_HOME
       ---> Running in 9bc5f1e3199a
      Removing intermediate container 9bc5f1e3199a
       ---> 26a53022c1bf
      Step 4/7 : ADD pre-xxl-job.jar ./xxl-job.jar
       ---> f4c6a2848ec3
      Step 5/7 : RUN set -x     && apt-get update     && apt-get install --no-install-recommends --no-install-suggests -y net-tools vim telnet     && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime     && mkdir /opt/settings /opt/data
       ---> Running in 42af1d255503
      + apt-get update
      Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
      Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
      Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
      Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [272 kB]
      Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
      Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [9504 B]
      Fetched 8427 kB in 1s (5670 kB/s)
      Reading package lists...
      + apt-get install --no-install-recommends --no-install-suggests -y net-tools vim telnet
      Reading package lists...
      Building dependency tree...
      Reading state information...
      The following additional packages will be installed:
        libgpm2 vim-common vim-runtime xxd
      Suggested packages:
        gpm ctags vim-doc vim-scripts
      The following NEW packages will be installed:
        libgpm2 net-tools telnet vim vim-common vim-runtime xxd
      0 upgraded, 7 newly installed, 0 to remove and 36 not upgraded.
      Need to get 7743 kB of archives.
      After this operation, 35.0 MB of additional disk space will be used.
      Get:1 http://deb.debian.org/debian buster/main amd64 xxd amd64 2:8.1.0875-5 [140 kB]
      Get:2 http://deb.debian.org/debian buster/main amd64 vim-common all 2:8.1.0875-5 [195 kB]
      Get:3 http://deb.debian.org/debian buster/main amd64 telnet amd64 0.17-41.2 [70.4 kB]
      Get:4 http://deb.debian.org/debian buster/main amd64 libgpm2 amd64 1.20.7-5 [35.1 kB]
      Get:5 http://deb.debian.org/debian buster/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1 [248 kB]
      Get:6 http://deb.debian.org/debian buster/main amd64 vim-runtime all 2:8.1.0875-5 [5775 kB]
      Get:7 http://deb.debian.org/debian buster/main amd64 vim amd64 2:8.1.0875-5 [1280 kB]
      debconf: delaying package configuration, since apt-utils is not installed
      Fetched 7743 kB in 0s (61.3 MB/s)
      Selecting previously unselected package xxd.
      (Reading database ... 12561 files and directories currently installed.)
      Preparing to unpack .../0-xxd_2%3a8.1.0875-5_amd64.deb ...
      Unpacking xxd (2:8.1.0875-5) ...
      Selecting previously unselected package vim-common.
      Preparing to unpack .../1-vim-common_2%3a8.1.0875-5_all.deb ...
      Unpacking vim-common (2:8.1.0875-5) ...
      Selecting previously unselected package telnet.
      Preparing to unpack .../2-telnet_0.17-41.2_amd64.deb ...
      Unpacking telnet (0.17-41.2) ...
      Selecting previously unselected package libgpm2:amd64.
      Preparing to unpack .../3-libgpm2_1.20.7-5_amd64.deb ...
      Unpacking libgpm2:amd64 (1.20.7-5) ...
      Selecting previously unselected package net-tools.
      Preparing to unpack .../4-net-tools_1.60+git20180626.aebd88e-1_amd64.deb ...
      Unpacking net-tools (1.60+git20180626.aebd88e-1) ...
      Selecting previously unselected package vim-runtime.
      Preparing to unpack .../5-vim-runtime_2%3a8.1.0875-5_all.deb ...
      Adding 'diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime'
      Adding 'diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime'
      Unpacking vim-runtime (2:8.1.0875-5) ...
      Selecting previously unselected package vim.
      Preparing to unpack .../6-vim_2%3a8.1.0875-5_amd64.deb ...
      Unpacking vim (2:8.1.0875-5) ...
      Setting up net-tools (1.60+git20180626.aebd88e-1) ...
      Setting up libgpm2:amd64 (1.20.7-5) ...
      Setting up telnet (0.17-41.2) ...
      update-alternatives: using /usr/bin/telnet.netkit to provide /usr/bin/telnet (telnet) in auto mode
      Setting up xxd (2:8.1.0875-5) ...
      Setting up vim-common (2:8.1.0875-5) ...
      Setting up vim-runtime (2:8.1.0875-5) ...
      Setting up vim (2:8.1.0875-5) ...
      update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
      update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
      update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
      update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
      update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
      update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
      update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
      update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in auto mode
      Processing triggers for libc-bin (2.28-10) ...
      Processing triggers for mime-support (3.62) ...
      + cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
      + mkdir /opt/settings /opt/data
      Removing intermediate container 42af1d255503
       ---> fd4d9ba05593
      Step 6/7 : EXPOSE 8080/tcp
       ---> Running in bfe844d8dcea
      Removing intermediate container bfe844d8dcea
       ---> 1e463485d87f
      Step 7/7 : CMD ["sh","-c","java -jar $JAVA_OPTS xxl-job.jar"]
       ---> Running in a88eb08a191b
      Removing intermediate container a88eb08a191b
       ---> 48f30c6a8258
      Successfully built 48f30c6a8258
      Successfully tagged hub.qiangyun.com/pre-xxl-job:latest
       
      ## 将制作好的镜像推送至仓库
      <root@Registry ~/pre-xxl-job># docker push hub.qiangyun.com/pre-xxl-job
      Using default tag: latest
      The push refers to repository [hub.qiangyun.com/pre-xxl-job]
      0ff0933afd53: Pushed
      705f7ac3fa7c: Pushed
      c481f4c8ef74: Pushed
      b350fb2b877c: Pushed
      99ca731afd41: Pushed
      4c2b0eaf4b81: Pushed
      46a297e68c47: Pushed
      cf47dfabe081: Pushed
      c53d956ebfec: Pushed
      6086e1b289d9: Pushed
      latest: digest: sha256:35237ad89d263f5d0a71e11c5d14e14554012dbaca07ad98ba6621dffbcce74b size: 2425
    4. deployment.yaml

      ## pre-xl-job deployment.yaml
      apiVersion: v1
      kind: Service
      metadata:
        name: pre-xl-job
        namespace: pre
        labels:
          job: pre-xl-job
      spec:
        ports:
        - port: 8080
          name: pre-xl-job
        selector:
          job: pre-xl-job
      ---
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: pre-xl-job
        namespace: pre
      spec:
        selector:
          matchLabels:
            job: pre-xl-job
        replicas: 1
        #updateStrategy:
        #  type: RollingUpdate
        #podManagementPolicy: OrderedReady
        template:
          metadata:
            labels:
              job: pre-xl-job
          spec:
            affinity:
              nodeAffinity:
                requiredDuringSchedulingIgnoredDuringExecution:
                  nodeSelectorTerms:
                  - matchExpressions:
                    - key: kubernetes.io/resource
                      operator: In
                      values:
                      - pre-base
            containers:
            - name: pre-xxl-job
              imagePullPolicy: IfNotPresent
              image: "hub.qiangyun.com/pre-xl-job"
              resources:
                requests:
                  memory: "512Mi"
                  cpu: "0.5"
                limits:
                  memory: "1024Mi"
                  cpu: "1"
              ports:
              - containerPort: 8080
                name: pre-xxl-job
              env:
                - name: JAVA_OPTS
                  value: '-Xmx512m -Duser.timezone=GMT+08'
              readinessProbe:
                tcpSocket:
                  port: 8080
                initialDelaySeconds: 120
                timeoutSeconds: 10
              livenessProbe:
                tcpSocket:
                  port: 8080
                initialDelaySeconds: 120
                timeoutSeconds: 10
    5. 创建ingress

      ## pre-xl-job-ingress.yaml
      apiVersion: networking.k8s.io/v1beta1
      kind: Ingress
      metadata:
        name: pre-xl-job.qiangyun.com
        namespace: pre
        annotations:
          # use the shared ingress-nginx
          kubernetes.io/ingress.class: "pre"
          #nginx.ingress.kubernetes.io/enable-cors: "true"
          #nginx.ingress.kubernetes.io/cors-allow-headers: "X-Forwarded-For"
        labels:
         job: pre-xl-job
      spec:
        rules:
        - host: pre-xl-job.qiangyun.com
          http:
            paths:
            - path: /
              backend:
                serviceName: pre-xl-job
                servicePort: 8080
       
       
       
       
      <root@PRE-K8S-CP1 ~># kubectl apply -f pre-xl-job-ingress.yaml
      ingress.networking.k8s.io/pre-xl-job.qiangyun.com created
    6. 配置SLB域名及DNS解析

  • 相关阅读:
    oracle多表关联删除的两种方法
    T100——汇总错误消息显示
    T100——程序从标准签出客制后注意r.c和r.l
    本地DataGrip连接阿里云MySQL
    mysql for mac 上的安装及用DataGrip连接
    mac 上安装vue模版-D2 Admin
    Python 3.7版本关于json.dump失效
    设置第三方的SMTP服务
    Apache 配置代理服务
    PyCharm 通过Github和Git上管理代码
  • 原文地址:https://www.cnblogs.com/apink/p/16294993.html
Copyright © 2020-2023  润新知