01.新建命名空间middleware
02.部署Nacos
点击上图的【使用YAML创建资源】,如下图所示,选择自定义
模版中如下内容:
---
#deploy
apiVersion: apps/v1
kind: Deployment
#kind: StatefulSet
metadata:
name: nacos-server
namespace: middleware
spec:
selector:
matchLabels:
app: nacos-server
replicas: 1
template:
metadata:
labels:
app: nacos-server
spec:
containers:
- name: nacos-server
image: nacos/nacos-server:v2.2.0
imagePullPolicy: Always
env:
- name: MODE
value: "standalone"
- name: SPRING_DATASOURCE_PLATFORM
value: "mysql"
- name: MYSQL_SERVICE_HOST
value: "rm-tttesttt.mysql.rds.aliyuncs.com"
- name: MYSQL_SERVICE_PORT
value: "3306"
- name: MYSQL_SERVICE_DB_NAME
value: "nacos_config"
- name: MYSQL_SERVICE_USER
value: "nacos"
- name: MYSQL_SERVICE_PASSWORD
value: "1234444"
- name: MYSQL_SERVICE_DB_PARAM
value: "characterEncoding=utf8&useSSL=true&requireSSL=false&useUnicode=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai"
- name: NACOS_AUTH_CACHE_ENABLE
value: "true"
- name: JVM_XMS
value: "512m"
- name: JVM_XMX
value: "512m"
- name: JVM_XMN
value: "128m"
ports:
- containerPort: 8848
---
#service
apiVersion: v1
kind: Service
metadata:
name: nacos-server
namespace: middleware
spec:
type: NodePort
ports:
- port: 8080
protocol: TCP
targetPort: 8848
nodePort: 30090
selector:
app: nacos-server
---
其中数据库的初始化可以从github上下载,地址为https://github.com/alibaba/nacos/blob/2.2.0/config/src/main/resources/META-INF/nacos-db.sql
03.部署Xxl-job-admin
参考Nacos的YAML创建资源方式,填写如下模版内容:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: xxl-job-admin
namespace: middleware
spec:
replicas: 1
selector:
matchLabels:
app: xxl-job-admin
template:
metadata:
labels:
app: xxl-job-admin
spec:
containers:
- name: xxl-job-admin
image: xuxueli/xxl-job-admin:2.3.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
env:
- name: PARAMS
value: "--spring.datasource.url=jdbc:mysql://rm-tttestta.mysql.rds.aliyuncs.com:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&useSSL=true&autoReconnect=true&serverTimezone=Asia/Shanghai --spring.datasource.password=123454636 --spring.datasource.username=xxl_job"
---
apiVersion: v1
kind: Service
metadata:
name: xxl-job-admin
namespace: middleware
spec:
type: NodePort
ports:
- port: 8080
protocol: TCP
targetPort: 8080
nodePort: 30091
selector:
app: xxl-job-admin
---
其中数据库的初始化脚本,可以从github这个地址下载https://github.com/xuxueli/xxl-job/blob/2.3.0/doc/db/tables_xxl_job.sql