k8s部署xxl-job-admin

1. 下载源码

地址 https://gitee.com/xuxueli0323/xxl-job/tree/2.1.2

2. 创建数据库

k8s部署xxl-job-admin_第1张图片

3. 如果本地跑的话,修改数据库连接和邮箱地址

k8s部署xxl-job-admin_第2张图片

4. 编写k8s yaml文件

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: xxl-job-admin
spec:
  template:
    metadata:
      labels:
        app: xxl-job-admin
    spec:
      containers:
      - name: xxl-job-admin
        image: registry.cn-shanghai.aliyuncs.com/wanfei/xxl-job-admin:2.1.2
        ports:
        - containerPort: 8080
        env:
        - name: PARAMS
          value: "--spring.datasource.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/xxl_job?Unicode=true&characterEncoding=UTF-8&useSSL=false --spring.datasource.username=root --spring.datasource.password=root [email protected] --spring.mail.password=xxxxxx"
---
apiVersion: v1
kind: Service
metadata:
  name: xxl-job-admin
  labels:
    app: xxl-job-admin
spec:
  ports:
  - port: 8080
    protocol: TCP
    name: http
  selector:
    app: xxl-job-admin
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: xxl-job-admin
  annotations:
    kubernetes.io/ingress.class: "nginx"
    kubernetes.io/tls-acme: "true"
spec:
  tls:
  - hosts:
    - xxl.wanfei.wang
    secretName: xxl-job-tls
  rules:
  - host: xxl.wanfei.wang
    http:
      paths:
      - path: '/'
        backend:
          serviceName: xxl-job-admin
          servicePort: 8080
  • - name: PARAMS: 指定application.properties配置参数,从Dockerfile中设置的PARAMS环境变量
    k8s部署xxl-job-admin_第3张图片

5. 运行

[root@master nginx]# ls
xxl-job-admin.yaml
[root@master nginx]# kubectl apply -f xxl-job-admin.yaml 
deployment.extensions/xxl-job-admin created
service/xxl-job-admin created
ingress.extensions/xxl-job-admin created
[root@master nginx]# kubectl get pods | grep xxl-job-admin
xxl-job-admin-6c4b9498c6-x7snf           1/1     Running   0          43s

6. 访问调度中心

https://xxl.wanfei.wang/xxl-job-admin

默认账号密码: admin/123456
k8s部署xxl-job-admin_第4张图片

你可能感兴趣的:(K8S)