# cluster-xxl-job-admin

* MySQL:  参考  external-mysql 文章
* 日志存储采用 hostpath 方式
* Pod 多节点反亲和性调度，单节点失效
* Node 调度， 只运行在指定的节点上
* 数据库导入:  <https://github.com/xuxueli/xxl-job/blob/2.4.1/doc/db/tables\\_xxl\\_job.sql>

```yaml
[root@master test]# cat cluster-xxl-job-admin-statefulset.yaml 
# web访问服务
apiVersion: v1
kind: Service
metadata:
  name: xxl-job-admin-svc
  labels:
    app: xxl-job-admin
spec:
  type: NodePort
  ports:
    - name: web
      port: 8080
      targetPort: 8080
      nodePort: 30080
  selector:
    app: xxl-job-admin
---
# 数据库导入: https://github.com/xuxueli/xxl-job/blob/2.4.1/doc/db/tables_xxl_job.sql
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: xxl-job-admin
  namespace: default
  labels:
    app: xxl-job-admin
spec:
  serviceName: xxl-job-admin-svc
  replicas: 3
  selector:
    matchLabels:
      app: xxl-job-admin
  template:
    metadata:
      labels:
        app: xxl-job-admin
    spec:
      # 节点打上中间件标签并污染：kubectl taint nodes <node-name> middleware=true:NoSchedule
      #tolerations:
      #  - key: "middleware"
      #    operator: "Equal"
      #    value: "true"
      #    effect: "NoSchedule"
      
      # 当多节点生效：不允许同一个pod调度到同一个节点
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: "app"
                    operator: In
                    values:
                      - middleware
              topologyKey: "kubernetes.io/hostname"
      containers:
        - name: xxl-job-admin
          image: xuxueli/xxl-job-admin:2.4.0
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              memory: "300Mi"
              cpu: "0.2"
            limits:
              memory: "8Gi"
              cpu: "8"
          livenessProbe:
            httpGet:
              path: /xxl-job-admin/actuator/health
              port: 8080
              scheme: HTTP
            failureThreshold: 10
            initialDelaySeconds: 10
            periodSeconds: 5
            timeoutSeconds: 1
          readinessProbe:
            httpGet:
              path: /xxl-job-admin/actuator/health
              port: 8080
              scheme: HTTP
            failureThreshold: 10
            initialDelaySeconds: 10
            periodSeconds: 5
            timeoutSeconds: 1
          env:
            - name: TZ
              value: America/Sao_Paulo # 巴西: America/Sao_Paulo; 上海：Asia/Shanghai
            - name: PARAMS
              value: "--spring.datasource.url=jdbc:mysql://external-mysql:3306/xxl_job?Unicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=America/Sao_Paulo --spring.datasource.username=root --spring.datasource.password=123456"
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: xxl-job-admin-log
              mountPath: /data/applogs
      volumes:
        - name: xxl-job-admin-log
          hostPath:
            path: /data/k8s/xxl-job-admin/
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://close.gitbook.io/yun-wei-bi-ji/kubernetes/chang-yong-yaml-mu-ban/cluster-xxl-job-admin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
