diff --git a/deployment/README.md b/deployment/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3fd3550771355286e8b2aa38d212610f86afca5f --- /dev/null +++ b/deployment/README.md @@ -0,0 +1,54 @@ +# Kubernates 部署Ruoyi-Cloud项目 + +本部署所用到的k8s配置均为简易版,仅作为初步入门学习使用,有不合理的地方还请见谅。 + +### 后期考虑功能: +* HPA自动扩缩容 +* MySQL主从、Redis集群、服务集群 +* ELK日志收集 + +## 容器分布 +~~~ +namespace +├── redis +│ └── redis // StatefulSet +├── kube-ruoyi +│ └── ruoyi-mysql // Deployment +│ └── ruoyi-nacos +│ └── ruoyi-nginx +│ └── ruoyi-sentinel +│ └── ruoyi-gateway +│ └── ruoyi-auth +│ └── ruoyi-system +│ └── ruoyi-gen +│ └── ruoyi-job +│ └── ruoyi-file +│ └── ruoyi-monitor +│ └── elasticsearch +│ └── skywalking +│ └── skywalking-ui +├── minio +│ └── minio +├── monitor-sa +│ └── node-exporter +│ └── prometheus-server +│ └── monitoring-grafana +~~~ + +## 部署顺序及要点 +1. Redis +2. MySQL,手动Dockerfile打包镜像,初始化准备好的数据脚本。使用了Secret加密密码等配置。 +3. Nacos, 配置好MODE=standalone,使用configMap设置数据库。 +4. Sentinel +5. Gateway,本服务需要用Dockerfile打包镜像,否则会报错。其他RuoYi服务可以直接使用spring-boot的image命令一键打包生成镜像[每个服务都有使用额外的SpringBoot配置文件(bootstrap-k8s.yml)加入到服务中,同时在原配置文件中把active换成${SPRING_PROFILES_ACTIVE:dev}后再打包,以读取deployment的env变量。启动服务前记得提前在nacos中克隆,新增服务配置以把dev改成k8s(deployment中启动的环境是SPRING_PROFILES_ACTIVE=k8s),修改好Redis地址(redis.redis)、MySQL地址(ruoyi-mysql)、Sentinel地址(ruoyi-sentinel)] +6. Nginx,部署之前先打包好前端静态文件,使用本地磁盘方式挂载到容器 (注:我使用的是Window的DockerDesktop启动的K8s,挂载磁盘路径必须带/run/desktop/mnt/host),修改好nginx配置ruoyi-gateway就可以启动(启动后输入localhost:30080就可以访问前端项目)。 +7. Auth +8. System,配置好后就可以登录了 +9. Gen +10. Job +11. File,改成minio服务之后需要修改静态文件中读取文件的端口地址 +12. Monitor,需要修改前端静态文件中的Monitor端口地址 +13. Minio,挂载本地文件。修改ruoyi-file服务中@Primary注释改到MinioServer上以使用Minio服务(记得修改nacos配置) +14. Elasticsearch,部署文件一并放入到了skywalking文件夹中 +15. skywalking,需要在Java服务中使用agent进行跟踪(自制agent镜像然后使用initContainers方式挂载到同一个容器,模板放到了agent-in-server文件) +16. skywalking-ui \ No newline at end of file diff --git a/deployment/minio/minio-deployment.yaml b/deployment/minio/minio-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cd0313037af9ceee212db778db7f9387b2b800ef --- /dev/null +++ b/deployment/minio/minio-deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + name: minio + name: minio + namespace: minio +spec: + replicas: 1 + selector: + matchLabels: + app: minio + template: + metadata: + labels: + app: minio + spec: + containers: + - name: minio + image: minio/minio + imagePullPolicy: Always + ports: + - containerPort: 9000 + name: tcp + - containerPort: 9090 + protocol: TCP + name: console + command: + - /bin/sh + - -c + - minio server /data --console-address ":9090" + env: + - name: MINIO_ACCESS_KEY + value: minioadmin + - name: MINIO_SECRET_KEY + value: minioadmin + readinessProbe: + failureThreshold: 3 + httpGet: + path: /minio/health/ready + port: 9000 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + volumeMounts: + - mountPath: /data + name: minio-data + volumes: + - name: minio-data + hostPath: + path: /run/desktop/mnt/host/c/k8sVolume/minio/data + type: Directory \ No newline at end of file diff --git a/deployment/minio/minio-namespace.yaml b/deployment/minio/minio-namespace.yaml new file mode 100644 index 0000000000000000000000000000000000000000..428108a9e17b7549835616a77e92972a5940c2fd --- /dev/null +++ b/deployment/minio/minio-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: minio \ No newline at end of file diff --git a/deployment/minio/minio-svc.yaml b/deployment/minio/minio-svc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4bae185524c48ff7c28dcffff3c7e15117ef5774 --- /dev/null +++ b/deployment/minio/minio-svc.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: minio + namespace: minio + labels: + app: minio +spec: + type: NodePort + publishNotReadyAddresses: true + ports: + - port: 9000 + name: tcp + targetPort: 9000 + - port: 9090 + name: console + targetPort: 9090 + nodePort: 30090 + selector: + app: minio \ No newline at end of file diff --git a/deployment/monitor/monitor-namespace.yaml b/deployment/monitor/monitor-namespace.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c82fa3545ca4d1f911721bb22839fe1065d3c321 --- /dev/null +++ b/deployment/monitor/monitor-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitor-sa diff --git a/deployment/monitor/node-exporter.yaml b/deployment/monitor/node-exporter.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c9c90dba8ddc015815289a0edfca69daa3b219d4 --- /dev/null +++ b/deployment/monitor/node-exporter.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: node-exporter + namespace: monitor-sa + labels: + name: node-exporter +spec: + selector: + matchLabels: + name: node-exporter + template: + metadata: + labels: + name: node-exporter + spec: + hostPID: true + hostIPC: true + hostNetwork: true # 共享宿主机网络和进程 + containers: + - name: node-exporter + image: prom/node-exporter:v0.16.0 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 9100 # 容器暴露端口为9100 + resources: + requests: + cpu: 0.15 + securityContext: + privileged: true # 开启特权模式 + args: + - --path.procfs + - /host/proc + - --path.sysfs + - /host/sys + - --collector.filesystem.ignored-mount-points + - '"^/(sys|proc|dev|host|etc)($|/)"' + volumeMounts: # 挂载宿主机目录以收集宿主机信息 + - name: dev + mountPath: /host/dev + - name: proc + mountPath: /host/proc + - name: sys + mountPath: /host/sys + - name: rootfs + mountPath: /rootfs + tolerations: # 定义容忍度,使其可调度到默认有污点的master + - key: "node-role.kubernetes.io/master" + operator: "Exists" + effect: "NoSchedule" + volumes: # 定义存储卷 + - name: proc + hostPath: + path: /proc + - name: dev + hostPath: + path: /dev + - name: sys + hostPath: + path: /sys + - name: rootfs + hostPath: + path: / \ No newline at end of file diff --git a/deployment/monitor/prometheus-config.yaml b/deployment/monitor/prometheus-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d0327098dc7358510725d9cc04b7007b58e789d7 --- /dev/null +++ b/deployment/monitor/prometheus-config.yaml @@ -0,0 +1,169 @@ +apiVersion: v1 +kind: ConfigMap # +metadata: + name: prometheus-config + namespace: kube-system + labels: + kubernetes.io/cluster-service: "true" + addonmanager.kubernetes.io/mode: EnsureExists +data: + prometheus.yml: | + rule_files: + - /etc/config/rules/*.rules + + scrape_configs: + - job_name: prometheus + static_configs: + - targets: + - localhost:9090 + + - job_name: kubernetes-nodes + scrape_interval: 30s + static_configs: + - targets: + - 192.168.73.135:9100 + - 192.168.73.138:9100 + - 192.168.73.139:9100 + - 192.168.73.140:9100 + + - job_name: kubernetes-apiservers + kubernetes_sd_configs: + - role: endpoints + relabel_configs: + - action: keep + regex: default;kubernetes;https + source_labels: + - __meta_kubernetes_namespace + - __meta_kubernetes_service_name + - __meta_kubernetes_endpoint_port_name + scheme: https + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + insecure_skip_verify: true + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + + - job_name: kubernetes-nodes-kubelet + kubernetes_sd_configs: + - role: node + relabel_configs: + - action: labelmap + regex: __meta_kubernetes_node_label_(.+) + scheme: https + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + insecure_skip_verify: true + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + + - job_name: kubernetes-nodes-cadvisor + kubernetes_sd_configs: + - role: node + relabel_configs: + - action: labelmap + regex: __meta_kubernetes_node_label_(.+) + - target_label: __metrics_path__ + replacement: /metrics/cadvisor + scheme: https + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + insecure_skip_verify: true + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + + - job_name: kubernetes-service-endpoints + kubernetes_sd_configs: + - role: endpoints + relabel_configs: + - action: keep + regex: true + source_labels: + - __meta_kubernetes_service_annotation_prometheus_io_scrape + - action: replace + regex: (https?) + source_labels: + - __meta_kubernetes_service_annotation_prometheus_io_scheme + target_label: __scheme__ + - action: replace + regex: (.+) + source_labels: + - __meta_kubernetes_service_annotation_prometheus_io_path + target_label: __metrics_path__ + - action: replace + regex: ([^:]+)(?::\d+)?;(\d+) + replacement: $1:$2 + source_labels: + - __address__ + - __meta_kubernetes_service_annotation_prometheus_io_port + target_label: __address__ + - action: labelmap + regex: __meta_kubernetes_service_label_(.+) + - action: replace + source_labels: + - __meta_kubernetes_namespace + target_label: kubernetes_namespace + - action: replace + source_labels: + - __meta_kubernetes_service_name + target_label: kubernetes_name + + - job_name: kubernetes-services + kubernetes_sd_configs: + - role: service + metrics_path: /probe + params: + module: + - http_2xx + relabel_configs: + - action: keep + regex: true + source_labels: + - __meta_kubernetes_service_annotation_prometheus_io_probe + - source_labels: + - __address__ + target_label: __param_target + - replacement: blackbox + target_label: __address__ + - source_labels: + - __param_target + target_label: instance + - action: labelmap + regex: __meta_kubernetes_service_label_(.+) + - source_labels: + - __meta_kubernetes_namespace + target_label: kubernetes_namespace + - source_labels: + - __meta_kubernetes_service_name + target_label: kubernetes_name + + - job_name: kubernetes-pods + kubernetes_sd_configs: + - role: pod + relabel_configs: + - action: keep + regex: true + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_scrape + - action: replace + regex: (.+) + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_path + target_label: __metrics_path__ + - action: replace + regex: ([^:]+)(?::\d+)?;(\d+) + replacement: $1:$2 + source_labels: + - __address__ + - __meta_kubernetes_pod_annotation_prometheus_io_port + target_label: __address__ + - action: labelmap + regex: __meta_kubernetes_pod_label_(.+) + - action: replace + source_labels: + - __meta_kubernetes_namespace + target_label: kubernetes_namespace + - action: replace + source_labels: + - __meta_kubernetes_pod_name + target_label: kubernetes_pod_name + alerting: + alertmanagers: + - static_configs: + - targets: ["alertmanager:80"] \ No newline at end of file diff --git a/deployment/mysql/db/readme.txt b/deployment/mysql/db/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..0b22f3fe7ea5741925618cf00cc4978d066b64b9 --- /dev/null +++ b/deployment/mysql/db/readme.txt @@ -0,0 +1 @@ +sqlĿ¼µнűdockerԶִС \ No newline at end of file diff --git a/deployment/mysql/dockerfile b/deployment/mysql/dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..28cb6cf1b812b24d11b37e1c59bd875775b96f1b --- /dev/null +++ b/deployment/mysql/dockerfile @@ -0,0 +1,5 @@ +# 基础镜像 +FROM mysql:5.7 + +# 执行sql脚本 +ADD ./db/*.sql /docker-entrypoint-initdb.d/ \ No newline at end of file diff --git a/deployment/mysql/mysql-deployment.yaml b/deployment/mysql/mysql-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2a664f97a8eef887200b096dc94149f30c627a50 --- /dev/null +++ b/deployment/mysql/mysql-deployment.yaml @@ -0,0 +1,47 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ruoyi-mysql #指定deployment的名字 + namespace: kube-ruoyi + labels: + app: ruoyi-mysql-local +spec: #规约 + replicas: 1 #pod的副本数量,就是希望创建多少个pod的副本.可p选字段。它的默认值是1。 + selector: #selector 字段定义 Deployment 如何查找要管理的 Pods。必须匹配 .spec.template.metadata.labels,否则请求会被 API 拒绝。 + matchLabels: + app: ruoyi-mysql-local + template: #Deployment Pod 模板;它和 Pod 的语法规则完全相同。 只是这里它是嵌套的,因此不需要 apiVersion 或 kind。 + metadata: + labels: + app: ruoyi-mysql-local + spec: #pod模板规约 + containers: #容器 + - name: ruoyi-mysql #容器的名称 + image: ruoyi/mysql:5.7 #容器使用的镜像 + ports: + - containerPort: 3306 + volumeMounts: + - name: mysql-local-data #pv的name + mountPath: /var/lib/mysql #MySQL容器的数据都是存在这个目录的,要对这个目录做数据持久化 + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: # Read environment variables from kubernetes secrets + secretKeyRef: + name: ruoyi-mysql-secret + key: mysql-root-pass + - name: MYSQL_USER + valueFrom: + secretKeyRef: + name: ruoyi-mysql-secret + key: mysql-user + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: ruoyi-mysql-secret + key: mysql-password + volumes: + - name: mysql-local-data #pv的name + hostPath: + path: /run/desktop/mnt/host/c/k8sVolume/mysql/data + type: Directory + restartPolicy: Always #Deployment 中的 Pod 模板必须指定适当的标签和适当的重新启动策略。只有 .spec.template.spec.restartPolicy 等于 Always 才是被允许的,这也是在没有指定时的默认设置 \ No newline at end of file diff --git a/deployment/mysql/mysql-pv-pvc.yaml b/deployment/mysql/mysql-pv-pvc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c2dae08f89d15ebf55ac12ca82f328bde7896de7 --- /dev/null +++ b/deployment/mysql/mysql-pv-pvc.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: mysql-pv + namespace: kube-ruoyi +spec: + capacity: + storage: 3Gi + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain # 手动删除 + storageClassName: hostpath #表明这个pv所属的storageClass + hostPath: + path: /mnt/data #节点上卷的完整路径。(必须是存在的路径,不然容器无法创建,deployment会报错)可以是目录或块设备(磁盘、分区…)。 + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-pvc-local + namespace: kube-ruoyi +spec: + accessModes: #访问模式 申领在请求具有特定访问模式的存储时,使用与卷相同的访问模式约定。 + - ReadWriteMany + volumeMode: Filesystem #卷模式 + resources: + requests: + storage: 1Gi + storageClassName: hostpath # 此处须显式设置空字符串或指定值,否则会被设置为默认的 StorageClass diff --git a/deployment/mysql/mysql-secret.yaml b/deployment/mysql/mysql-secret.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f127ca172085f12d9bdd389e48e8236d76be4f0b --- /dev/null +++ b/deployment/mysql/mysql-secret.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: ruoyi-mysql-secret + namespace: kube-ruoyi +type: Opaque #base-64加密 +data: + mysql-root-pass: cGFzc3dvcmQ= + mysql-user: YWRtaW4= + mysql-password: MTIzNDU2 \ No newline at end of file diff --git a/deployment/mysql/mysql-svc.yaml b/deployment/mysql/mysql-svc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2bbb67f462efe41cf3c54006ab9990aaf73f0c2a --- /dev/null +++ b/deployment/mysql/mysql-svc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: ruoyi-mysql + namespace: kube-ruoyi +spec: + ports: + - port: 3306 + nodePort: 30060 + selector: + app: ruoyi-mysql-local # 该 Service 会将所有具有标签 app: mysql-labels-app暴露到一个抽象的 Service 端口上(targetPort:容器接收流量的端口;port:可任意取值的抽象的 Service 端口,其他 Pod 通过该端口访问 Service + type: NodePort \ No newline at end of file diff --git a/deployment/nacos/nacos-config.yaml b/deployment/nacos/nacos-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6395468bcca3fdfc229b60122245cc65a992c6d2 --- /dev/null +++ b/deployment/nacos/nacos-config.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: ruoyi-nacos-config + namespace: kube-ruoyi +data: + application.properties: | + spring.datasource.platform=mysql + db.num=1 + db.url.0=jdbc:mysql://ruoyi-mysql:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC + db.user=root + db.password=password + nacos.naming.empty-service.auto-clean=true + nacos.naming.empty-service.clean.initial-delay-ms=50000 + nacos.naming.empty-service.clean.period-time-ms=30000 + management.endpoints.web.exposure.include=* + management.metrics.export.elastic.enabled=false + management.metrics.export.influx.enabled=false + server.tomcat.accesslog.enabled=true + server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i + server.tomcat.basedir=/home/ruoyi/nacos/tomcat/logs + nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** + nacos.core.auth.system.type=nacos + nacos.core.auth.enabled=false + nacos.core.auth.plugin.nacos.token.expire.seconds=18000 + nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789 + nacos.core.auth.caching.enabled=true + nacos.core.auth.enable.userAgentAuthWhite=false + nacos.core.auth.server.identity.key=serverIdentity + nacos.core.auth.server.identity.value=security + nacos.istio.mcp.server.enabled=false \ No newline at end of file diff --git a/deployment/nacos/nacos-deployment.yaml b/deployment/nacos/nacos-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7745b9d3974acec6e9af409f20984f15597d1a2f --- /dev/null +++ b/deployment/nacos/nacos-deployment.yaml @@ -0,0 +1,37 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ruoyi-nacos + namespace: kube-ruoyi +spec: + replicas: 1 + selector: + matchLabels: + app: ruoyi-nacos + template: + metadata: + labels: + app: ruoyi-nacos + spec: + containers: + - name: ruoyi-nacos + image: nacos/nacos-server + imagePullPolicy: Always + ports: + - containerPort: 8848 + name: client + - containerPort: 9848 + name: client-rpc + - containerPort: 9849 + name: raft-rpc + env: + - name: MODE + value: standalone + volumeMounts: + - mountPath: /home/nacos/conf/application.properties + name: nacos-conf + subPath: application.properties + volumes: + - name: nacos-conf + configMap: + name: ruoyi-nacos-config diff --git a/deployment/nacos/nacos-svc.yaml b/deployment/nacos/nacos-svc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6411449e75779b644a62e681c2dfd2871d08df98 --- /dev/null +++ b/deployment/nacos/nacos-svc.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Service +metadata: + name: ruoyi-nacos + namespace: kube-ruoyi + labels: + app: ruoyi-nacos +spec: + type: NodePort + publishNotReadyAddresses: true + ports: + - port: 8848 + name: server + targetPort: 8848 + nodePort: 30848 + - port: 9848 + name: client-rpc + targetPort: 9848 + - port: 9849 + name: raft-rpc + targetPort: 9849 + selector: + app: ruoyi-nacos \ No newline at end of file diff --git a/deployment/nginx/nginx-config.yaml b/deployment/nginx/nginx-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3ffedbeb6ac82b9b256c7eca9b0d5407cdf98bfb --- /dev/null +++ b/deployment/nginx/nginx-config.yaml @@ -0,0 +1,37 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: ruoyi-nginx-config + namespace: kube-ruoyi +data: + nginx.conf: | + worker_processes 1; + events { + worker_connections 1024; + } + http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + server { + listen 80; + server_name localhost; + location / { + root /home/ruoyi/projects/ruoyi-ui; + try_files $uri $uri/ /index.html; + index index.html index.htm; + } + location /prod-api/{ + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header REMOTE-HOST $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://ruoyi-gateway:8080/; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + } \ No newline at end of file diff --git a/deployment/nginx/nginx-deployment.yaml b/deployment/nginx/nginx-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6ebdbfe2c060e12881478553f55066a30a668ef2 --- /dev/null +++ b/deployment/nginx/nginx-deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ruoyi-nginx + namespace: kube-ruoyi +spec: + replicas: 1 + selector: + matchLabels: + app: ruoyi-nginx + template: + metadata: + labels: + app: ruoyi-nginx + spec: + containers: + - name: ruoyi-nginx + image: nginx + imagePullPolicy: Always + ports: + - containerPort: 80 + volumeMounts: + - mountPath: /etc/nginx/nginx.conf + name: nginx-conf + subPath: nginx.conf + - mountPath: /home/ruoyi/projects/ruoyi-ui + name: local-path #/usr/share/nginx/html 挂载到volumes中server+path + volumes: + - name: nginx-conf + configMap: + name: ruoyi-nginx-config + - name: local-path + hostPath: + path: /run/desktop/mnt/host/c/k8sVolume/dist + type: Directory + +--- +apiVersion: v1 +kind: Service +metadata: + name: ruoyi-nginx + namespace: kube-ruoyi + labels: + name: ruoyi-nginx +spec: + type: NodePort + ports: + - port: 80 + targetPort: 80 + nodePort: 30080 + selector: + app: ruoyi-nginx + diff --git a/deployment/redis/redis-config.yaml b/deployment/redis/redis-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..aaba6d250c905023d66558d0539a501b219868fb --- /dev/null +++ b/deployment/redis/redis-config.yaml @@ -0,0 +1,58 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: redis-config + namespace: redis +data: + redis.conf: |- + maxmemory 1000mb + maxmemory-policy allkeys-lru + protected-mode no + tcp-backlog 511 + daemonize no + supervised no + dir /data + pidfile /data/redis_6379.pid + port 6379 + loglevel notice + logfile "" + databases 16 + stop-writes-on-bgsave-error yes + rdbcompression yes + rdbchecksum yes + dbfilename dump.rdb + replica-serve-stale-data yes + replica-read-only no + repl-diskless-sync no + repl-diskless-sync-delay 5 + repl-disable-tcp-nodelay no + replica-priority 100 + lazyfree-lazy-eviction no + lazyfree-lazy-expire no + lazyfree-lazy-server-del no + replica-lazy-flush no + appendonly no + appendfilename "appendonly.aof" + appendfsync everysec + no-appendfsync-on-rewrite no + auto-aof-rewrite-percentage 100 + auto-aof-rewrite-min-size 64mb + aof-load-truncated yes + aof-use-rdb-preamble yes + lua-time-limit 5000 + slowlog-log-slower-than 10000 + slowlog-max-len 128 + latency-monitor-threshold 0 + notify-keyspace-events "" + set-max-intset-entries 512 + hll-sparse-max-bytes 3000 + stream-node-max-bytes 4096 + stream-node-max-entries 100 + activerehashing yes + client-output-buffer-limit normal 0 0 0 + client-output-buffer-limit replica 256mb 64mb 60 + client-output-buffer-limit pubsub 32mb 8mb 60 + hz 10 + dynamic-hz yes + aof-rewrite-incremental-fsync yes + rdb-save-incremental-fsync yes diff --git a/deployment/redis/redis-namespace.yaml b/deployment/redis/redis-namespace.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7b5a5b558a83238725a6071a31f35c19c04fa8d5 --- /dev/null +++ b/deployment/redis/redis-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: redis diff --git a/deployment/redis/redis-stateful-set.yaml b/deployment/redis/redis-stateful-set.yaml new file mode 100644 index 0000000000000000000000000000000000000000..579725cc95fec4a38bebb9461c574a07a3d696db --- /dev/null +++ b/deployment/redis/redis-stateful-set.yaml @@ -0,0 +1,98 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: redis + labels: + app: redis + namespace: redis +spec: + serviceName: redis + replicas: 1 + selector: + matchLabels: + app: redis + template: + metadata: + labels: + app: redis + spec: + initContainers: + - name: config + image: redis:7.0.6 + command: [ "sh", "-c" ] + args: + - | + cp /tmp/redis/redis.conf /etc/redis/redis.conf + + echo "finding master..." + MASTER_FDQN=`hostname -f | sed -e 's/redis-[0-9]\./redis-0./'` + if [ "$(redis-cli -h sentinel -p 5000 ping)" != "PONG" ]; then + echo "master not found, defaulting to redis-0" + if [ "$(hostname)" = "redis-0" ]; then + echo "this is redis-0, not updating config..." + else + echo "updating redis.conf..." + echo "\nslaveof $MASTER_FDQN 6379" >> /etc/redis/redis.conf + fi + else + echo "sentinel found, finding master" + MASTER="$(redis-cli -h sentinel -p 5000 sentinel get-master-addr-by-name mymaster | grep -E '(^redis-\d{1,})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})')" + echo "master found : $MASTER, updating redis.conf" + echo "slaveof $MASTER 6379" >> /etc/redis/redis.conf + fi + volumeMounts: + - name: redis-config + mountPath: /etc/redis/ + - name: config + mountPath: /tmp/redis/ + containers: + - name: redis + image: redis:7.0.6 + command: [ "redis-server" ] + args: [ "/etc/redis/redis.conf" ] + ports: + - containerPort: 6379 + name: redis + volumeMounts: + - name: data + mountPath: /data + - name: redis-config + mountPath: /etc/redis/ + resources: + limits: + memory: 1100Mi + requests: + memory: 1100Mi + volumes: + - name: redis-config + emptyDir: { } + - name: config + configMap: + name: redis-config + volumeClaimTemplates: + - metadata: + name: data + spec: + storageClassName: hostpath + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 500Mi + +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: redis # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: redis + namespace: redis +spec: + selector: + app: redis # The service exposes Pods with label `app=redis` + ports: + - name: redis-port + port: 6379 + nodePort: 30079 + type: NodePort diff --git a/deployment/ruoyi-namespace.yaml b/deployment/ruoyi-namespace.yaml new file mode 100644 index 0000000000000000000000000000000000000000..339fba788c69c0bbfbe66ee676c84308b0261577 --- /dev/null +++ b/deployment/ruoyi-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: kube-ruoyi diff --git a/deployment/sentinel/sentinel-deployment.yaml b/deployment/sentinel/sentinel-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8f0437cbba57deaee230e0dc81f88fa14ca529ab --- /dev/null +++ b/deployment/sentinel/sentinel-deployment.yaml @@ -0,0 +1,41 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ruoyi-sentinel + namespace: kube-ruoyi +spec: + replicas: 1 + selector: + matchLabels: + app: ruoyi-sentinel + template: + metadata: + labels: + app: ruoyi-sentinel + spec: + containers: + - name: ruoyi-sentinel + image: bladex/sentinel-dashboard + imagePullPolicy: Always + ports: + - containerPort: 8858 + env: # Environment variables supplied to the Pod + - name: JAVA_TOOL_OPTIONS + value: "-Dserver.port=8858 -Dcsp.sentinel.dashboard.server=localhost:8858 -Dproject.name=sentinel-dashboard" +--- +apiVersion: v1 +kind: Service +metadata: + name: ruoyi-sentinel + namespace: kube-ruoyi + labels: + name: ruoyi-sentinel +spec: + type: NodePort + ports: + - port: 8858 + targetPort: 8858 + nodePort: 30858 + selector: + app: ruoyi-sentinel + diff --git a/deployment/servers/ruoyi-auth-server-k8s-deployment.yaml b/deployment/servers/ruoyi-auth-server-k8s-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d773fa2ac92662de71371ba0e389b79c47619987 --- /dev/null +++ b/deployment/servers/ruoyi-auth-server-k8s-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 # API version +kind: Deployment # Type of kubernetes resource +metadata: + name: ruoyi-auth # Name of the kubernetes resource + namespace: kube-ruoyi + labels: # Labels that will be applied to this resource + app: ruoyi-auth +spec: + replicas: 1 # No. of replicas/pods to run in this deployment + selector: + matchLabels: # The deployment applies to any pods matching the specified labels + app: ruoyi-auth + template: # Template for creating the pods in this deployment + metadata: + labels: # Labels that will be applied to each Pod in this deployment + app: ruoyi-auth + spec: # Spec for the containers that will be run in the Pods + containers: + - name: ruoyi-auth-server + image: ruoyi-auth:3.6.2 + ports: + - name: http + containerPort: 9200 # The port that the container exposes + env: # Environment variables supplied to the Pod + - name: SPRING_PROFILES_ACTIVE + value: k8s + - name: SERVER_NAME + value: ruoyi-auth + - name: NACOS_SERVER + value: ruoyi-nacos # nacos svc name + - name: NACOS_PORT + value: "8848" + - name: NACOS_SHARED_CONFIGS + value: application-dev.yml +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: ruoyi-auth # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: ruoyi-auth + namespace: kube-ruoyi +spec: + type: NodePort # The service will be exposed by opening a Port on each node and proxying it. + selector: + app: ruoyi-auth # The service exposes Pods with label `app=ruoyi-auth` + ports: # Forward incoming connections on port 9200 to the target port 9200 + - name: http + port: 9200 + targetPort: 9200 diff --git a/deployment/servers/ruoyi-gateway-server-k8s-deployment.yaml b/deployment/servers/ruoyi-gateway-server-k8s-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..264e7d8c31602d085e8421baea54ecfd8dd7bca9 --- /dev/null +++ b/deployment/servers/ruoyi-gateway-server-k8s-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 # API version +kind: Deployment # Type of kubernetes resource +metadata: + name: ruoyi-gateway # Name of the kubernetes resource + namespace: kube-ruoyi + labels: # Labels that will be applied to this resource + app: ruoyi-gateway +spec: + replicas: 1 # No. of replicas/pods to run in this deployment + selector: + matchLabels: # The deployment applies to any pods matching the specified labels + app: ruoyi-gateway + template: # Template for creating the pods in this deployment + metadata: + labels: # Labels that will be applied to each Pod in this deployment + app: ruoyi-gateway + spec: # Spec for the containers that will be run in the Pods + containers: + - name: ruoyi-gateway-server + image: ruoyi-gateway:3.6.2 + ports: + - name: http + containerPort: 8080 # The port that the container exposes + env: # Environment variables supplied to the Pod + - name: SPRING_PROFILES_ACTIVE + value: k8s + - name: SERVER_NAME + value: ruoyi-gateway + - name: NACOS_SERVER + value: ruoyi-nacos # nacos svc name + - name: NACOS_PORT + value: "8848" + - name: NACOS_SHARED_CONFIGS + value: application-dev.yml +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: ruoyi-gateway # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: ruoyi-gateway + namespace: kube-ruoyi +spec: + type: NodePort # The service will be exposed by opening a Port on each node and proxying it. + selector: + app: ruoyi-gateway # The service exposes Pods with label `app=ruoyi-gateway` + ports: # Forward incoming connections on port 8080 to the target port 8080 + - name: http + port: 8080 + targetPort: 8080 diff --git a/deployment/servers/ruoyi-modules-file-server-k8s-deployment.yaml b/deployment/servers/ruoyi-modules-file-server-k8s-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..92631158025a885e9776dfc64b63c5912dbeea98 --- /dev/null +++ b/deployment/servers/ruoyi-modules-file-server-k8s-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 # API version +kind: Deployment # Type of kubernetes resource +metadata: + name: ruoyi-file # Name of the kubernetes resource + namespace: kube-ruoyi + labels: # Labels that will be applied to this resource + app: ruoyi-file +spec: + replicas: 1 # No. of replicas/pods to run in this deployment + selector: + matchLabels: # The deployment applies to any pods matching the specified labels + app: ruoyi-file + template: # Template for creating the pods in this deployment + metadata: + labels: # Labels that will be applied to each Pod in this deployment + app: ruoyi-file + spec: # Spec for the containers that will be run in the Pods + containers: + - name: ruoyi-file-server + image: ruoyi-modules-file:3.6.2 + ports: + - name: http + containerPort: 9300 # The port that the container exposes + env: # Environment variables supplied to the Pod + - name: SPRING_PROFILES_ACTIVE + value: k8s + - name: SERVER_NAME + value: ruoyi-file + - name: NACOS_SERVER + value: ruoyi-nacos # nacos svc name + - name: NACOS_PORT + value: "8848" + - name: NACOS_SHARED_CONFIGS + value: application-dev.yml +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: ruoyi-file # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: ruoyi-file + namespace: kube-ruoyi +spec: + type: NodePort # The service will be exposed by opening a Port on each node and proxying it. + selector: + app: ruoyi-file # The service exposes Pods with label `app=ruoyi-file` + ports: # Forward incoming connections on port 9300 to the target port 9300 + - name: http + port: 9300 + targetPort: 9300 diff --git a/deployment/servers/ruoyi-modules-gen-server-k8s-deployment.yaml b/deployment/servers/ruoyi-modules-gen-server-k8s-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e96dd1f37ba9fadc11ad81d4b43a2e34fc9fd43d --- /dev/null +++ b/deployment/servers/ruoyi-modules-gen-server-k8s-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 # API version +kind: Deployment # Type of kubernetes resource +metadata: + name: ruoyi-gen # Name of the kubernetes resource + namespace: kube-ruoyi + labels: # Labels that will be applied to this resource + app: ruoyi-gen +spec: + replicas: 1 # No. of replicas/pods to run in this deployment + selector: + matchLabels: # The deployment applies to any pods matching the specified labels + app: ruoyi-gen + template: # Template for creating the pods in this deployment + metadata: + labels: # Labels that will be applied to each Pod in this deployment + app: ruoyi-gen + spec: # Spec for the containers that will be run in the Pods + containers: + - name: ruoyi-gen-server + image: ruoyi-modules-gen:3.6.2 + ports: + - name: http + containerPort: 9202 # The port that the container exposes + env: # Environment variables supplied to the Pod + - name: SPRING_PROFILES_ACTIVE + value: k8s + - name: SERVER_NAME + value: ruoyi-gen + - name: NACOS_SERVER + value: ruoyi-nacos # nacos svc name + - name: NACOS_PORT + value: "8848" + - name: NACOS_SHARED_CONFIGS + value: application-dev.yml +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: ruoyi-gen # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: ruoyi-gen + namespace: kube-ruoyi +spec: + type: NodePort # The service will be exposed by opening a Port on each node and proxying it. + selector: + app: ruoyi-gen # The service exposes Pods with label `app=ruoyi-gen` + ports: # Forward incoming connections on port 9202 to the target port 9202 + - name: http + port: 9202 + targetPort: 9202 diff --git a/deployment/servers/ruoyi-modules-job-server-k8s-deployment.yaml b/deployment/servers/ruoyi-modules-job-server-k8s-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9819eb31966b894d13045e0bca5968f0edb47abe --- /dev/null +++ b/deployment/servers/ruoyi-modules-job-server-k8s-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 # API version +kind: Deployment # Type of kubernetes resource +metadata: + name: ruoyi-job # Name of the kubernetes resource + namespace: kube-ruoyi + labels: # Labels that will be applied to this resource + app: ruoyi-job +spec: + replicas: 1 # No. of replicas/pods to run in this deployment + selector: + matchLabels: # The deployment applies to any pods matching the specified labels + app: ruoyi-job + template: # Template for creating the pods in this deployment + metadata: + labels: # Labels that will be applied to each Pod in this deployment + app: ruoyi-job + spec: # Spec for the containers that will be run in the Pods + containers: + - name: ruoyi-job-server + image: ruoyi-modules-job:3.6.2 + ports: + - name: http + containerPort: 9203 # The port that the container exposes + env: # Environment variables supplied to the Pod + - name: SPRING_PROFILES_ACTIVE + value: k8s + - name: SERVER_NAME + value: ruoyi-job + - name: NACOS_SERVER + value: ruoyi-nacos # nacos svc name + - name: NACOS_PORT + value: "8848" + - name: NACOS_SHARED_CONFIGS + value: application-dev.yml +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: ruoyi-job # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: ruoyi-job + namespace: kube-ruoyi +spec: + type: NodePort # The service will be exposed by opening a Port on each node and proxying it. + selector: + app: ruoyi-job # The service exposes Pods with label `app=ruoyi-job` + ports: # Forward incoming connections on port 9203 to the target port 9203 + - name: http + port: 9203 + targetPort: 9203 diff --git a/deployment/servers/ruoyi-modules-system-server-k8s-deployment.yaml b/deployment/servers/ruoyi-modules-system-server-k8s-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dd8e5a4ef28b3162c30ab8b990956f078f4f69ac --- /dev/null +++ b/deployment/servers/ruoyi-modules-system-server-k8s-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 # API version +kind: Deployment # Type of kubernetes resource +metadata: + name: ruoyi-system # Name of the kubernetes resource + namespace: kube-ruoyi + labels: # Labels that will be applied to this resource + app: ruoyi-system +spec: + replicas: 1 # No. of replicas/pods to run in this deployment + selector: + matchLabels: # The deployment applies to any pods matching the specified labels + app: ruoyi-system + template: # Template for creating the pods in this deployment + metadata: + labels: # Labels that will be applied to each Pod in this deployment + app: ruoyi-system + spec: # Spec for the containers that will be run in the Pods + containers: + - name: ruoyi-system-server + image: ruoyi-modules-system:3.6.2 + ports: + - name: http + containerPort: 9201 # The port that the container exposes + env: # Environment variables supplied to the Pod + - name: SPRING_PROFILES_ACTIVE + value: k8s + - name: SERVER_NAME + value: ruoyi-system + - name: NACOS_SERVER + value: ruoyi-nacos # nacos svc name + - name: NACOS_PORT + value: "8848" + - name: NACOS_SHARED_CONFIGS + value: application-dev.yml +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: ruoyi-system # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: ruoyi-system + namespace: kube-ruoyi +spec: + type: NodePort # The service will be exposed by opening a Port on each node and proxying it. + selector: + app: ruoyi-system # The service exposes Pods with label `app=ruoyi-system` + ports: # Forward incoming connections on port 9201 to the target port 9201 + - name: http + port: 9201 + targetPort: 9201 diff --git a/deployment/servers/ruoyi-monitor-server-k8s-deployment.yaml b/deployment/servers/ruoyi-monitor-server-k8s-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4e3a2656ea3cec34da8e82f304afdfd7a679a93d --- /dev/null +++ b/deployment/servers/ruoyi-monitor-server-k8s-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 # API version +kind: Deployment # Type of kubernetes resource +metadata: + name: ruoyi-monitor # Name of the kubernetes resource + namespace: kube-ruoyi + labels: # Labels that will be applied to this resource + app: ruoyi-monitor +spec: + replicas: 1 # No. of replicas/pods to run in this deployment + selector: + matchLabels: # The deployment applies to any pods matching the specified labels + app: ruoyi-monitor + template: # Template for creating the pods in this deployment + metadata: + labels: # Labels that will be applied to each Pod in this deployment + app: ruoyi-monitor + spec: # Spec for the containers that will be run in the Pods + containers: + - name: ruoyi-monitor-server + image: ruoyi-visual-monitor:3.6.2 + ports: + - name: http + containerPort: 9100 # The port that the container exposes + env: # Environment variables supplied to the Pod + - name: SPRING_PROFILES_ACTIVE + value: k8s + - name: SERVER_NAME + value: ruoyi-monitor + - name: NACOS_SERVER + value: ruoyi-nacos # nacos svc name + - name: NACOS_PORT + value: "8848" + - name: NACOS_SHARED_CONFIGS + value: application-dev.yml +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: ruoyi-monitor # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: ruoyi-monitor + namespace: kube-ruoyi +spec: + type: NodePort # The service will be exposed by opening a Port on each node and proxying it. + selector: + app: ruoyi-monitor # The service exposes Pods with label `app=ruoyi-monitor` + ports: # Forward incoming connections on port 9100 to the target port 9100 + - name: http + port: 9100 + targetPort: 9100 diff --git a/deployment/servers/ruoyi/gateway/bootstrap-k8s.yml b/deployment/servers/ruoyi/gateway/bootstrap-k8s.yml new file mode 100644 index 0000000000000000000000000000000000000000..4151679459891cd0d533b011036c46fc38f43f95 --- /dev/null +++ b/deployment/servers/ruoyi/gateway/bootstrap-k8s.yml @@ -0,0 +1,37 @@ +# Tomcat +server: + port: 8080 + +# Spring +spring: + application: + # 应用名称 + name: ${SERVER_NAME} + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + config: + # 配置中心地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - ${NACOS_SHARED_CONFIGS} + sentinel: + # 取消控制台懒加载 + eager: true + transport: + # 控制台地址 + dashboard: 127.0.0.1:8718 + # nacos配置持久化 + datasource: + ds1: + nacos: + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + dataId: sentinel-ruoyi-gateway + groupId: DEFAULT_GROUP + data-type: json + rule-type: gw-flow diff --git a/deployment/servers/ruoyi/gateway/dockerfile b/deployment/servers/ruoyi/gateway/dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0e8f612ed860ff1bdc0c5550f6250c07af262a53 --- /dev/null +++ b/deployment/servers/ruoyi/gateway/dockerfile @@ -0,0 +1,15 @@ +# 基础镜像 +FROM openjdk:8-jre +# author +MAINTAINER ruoyi + +# 挂载目录 +VOLUME /home/ruoyi +# 创建目录 +RUN mkdir -p /home/ruoyi +# 指定路径 +WORKDIR /home/ruoyi +# 复制jar文件到路径 +COPY ./jar/ruoyi-gateway.jar /home/ruoyi/ruoyi-gateway.jar +# 启动网关服务 +ENTRYPOINT ["java","-jar","ruoyi-gateway.jar"] \ No newline at end of file diff --git a/deployment/servers/ruoyi/gateway/jar/readme.txt b/deployment/servers/ruoyi/gateway/jar/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..5dfbec761b307025b1e0febe0f4e3d1baf3e570d --- /dev/null +++ b/deployment/servers/ruoyi/gateway/jar/readme.txt @@ -0,0 +1 @@ +ģõjarļdockerӦá \ No newline at end of file diff --git a/deployment/skywalking/agent-in-server/ruoyi-modules-system-server-agent-k8s-deployment.yaml b/deployment/skywalking/agent-in-server/ruoyi-modules-system-server-agent-k8s-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..16b6caa2800f2616b81f1c234f7bc97dd2b4ef7f --- /dev/null +++ b/deployment/skywalking/agent-in-server/ruoyi-modules-system-server-agent-k8s-deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 # API version +kind: Deployment # Type of kubernetes resource +metadata: + name: ruoyi-system # Name of the kubernetes resource + namespace: kube-ruoyi + labels: # Labels that will be applied to this resource + app: ruoyi-system +spec: + replicas: 1 # No. of replicas/pods to run in this deployment + selector: + matchLabels: # The deployment applies to any pods matching the specified labels + app: ruoyi-system + template: # Template for creating the pods in this deployment + metadata: + labels: # Labels that will be applied to each Pod in this deployment + app: ruoyi-system + spec: # Spec for the containers that will be run in the Pods + containers: + - name: ruoyi-system-server + image: ruoyi-modules-system:3.6.2 + ports: + - name: http + containerPort: 9201 # The port that the container exposes + env: # Environment variables supplied to the Pod + - name: SPRING_PROFILES_ACTIVE + value: k8s + - name: SERVER_NAME + value: ruoyi-system + - name: NACOS_SERVER + value: ruoyi-nacos # nacos svc name + - name: NACOS_PORT + value: "8848" + - name: NACOS_SHARED_CONFIGS + value: application-dev.yml + - name: JAVA_OPTS + value: -javaagent:/javaagent/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=k8s::$(SERVER_NAME) -Dskywalking.collector.backend_service=skywalking:11800 + volumeMounts: + - mountPath: /javaagent + name: agent-jar + volumes: + - emptyDir: { } + name: agent-jar + initContainers: + # 官网用脚本命令行+args的方式执行多条command语句 + - command: ['sh'] + args: + - "-c" + - | + cp -r /opt/skywalking-agent /javaagent + chown -R 65534:65534 /javaagent + /bin/chmod -R 777 /javaagent + image: skywalking-agent:8.14.0 + imagePullPolicy: IfNotPresent + name: skywalking-agent + volumeMounts: + - mountPath: /javaagent + name: agent-jar +--- +apiVersion: v1 # API version +kind: Service # Type of the kubernetes resource +metadata: + name: ruoyi-system # Name of the kubernetes resource + labels: # Labels that will be applied to this resource + app: ruoyi-system + namespace: kube-ruoyi +spec: + type: NodePort # The service will be exposed by opening a Port on each node and proxying it. + selector: + app: ruoyi-system # The service exposes Pods with label `app=ruoyi-system` + ports: # Forward incoming connections on port 9201 to the target port 9201 + - name: http + port: 9201 + targetPort: 9201 diff --git a/deployment/skywalking/agent.dockerfile b/deployment/skywalking/agent.dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..94aae35defab27d35bf0440b06b62b8359027821 --- /dev/null +++ b/deployment/skywalking/agent.dockerfile @@ -0,0 +1,17 @@ +## cat Dcokerfile + +FROM docker.io/library/busybox:latest AS base + +# 使用 ADD 下载 java-agent,你也可以使用其他下载命令,或者下载到本地,再 使用 COPY或者ADD 指令添加到 镜像里 +ADD https://dlcdn.apache.org/skywalking/java-agent/9.0.0/apache-skywalking-java-agent-9.0.0.tgz /tmp/ +RUN mkdir -p /opt \ + && tar -xzf /tmp/apache-skywalking-java-agent-9.0.0.tgz -C /opt/ \ + && rm -rf /tmp/* +#ADD skywalking-agent.tar.gz /opt/ +RUN mkdir -p /javaagent + +## java-agent 使用 方法 +## https://skywalking.apache.org/docs/skywalking-java/next/en/setup/service-agent/java-agent/readme/ +## java -javaagent:/opt/skywalking-agent/skywalking-agent.jar -jar yourApp.jar +## -javaagent:/opt/skywalking-agent/skywalking-agent.jar=agent.service_name=yourAppName,collector.backend_service=127.0.0.1:11800 +## -javaagent:/opt/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=yourAppName -Dskywalking.collector.backend_service=127.0.0.1:11800 \ No newline at end of file diff --git a/deployment/skywalking/elasticsearch-deployment.yaml b/deployment/skywalking/elasticsearch-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4eea54ff2991d851ed8d644df9d783fcc90ee192 --- /dev/null +++ b/deployment/skywalking/elasticsearch-deployment.yaml @@ -0,0 +1,44 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + name: elasticsearch + name: elasticsearch + namespace: kube-ruoyi +spec: + replicas: 1 + selector: + matchLabels: + app: elasticsearch + template: + metadata: + labels: + app: elasticsearch + spec: + containers: + - name: elasticsearch + image: elasticsearch:7.14.2 + ports: + - containerPort: 9200 + name: cluster-node + env: + - name: discovery.type + value: single-node + - name: TZ + value: Asia/Shanghai + - name: ES_JAVA_OPTS + value: -Xms512m -Xmx512m +--- +apiVersion: v1 +kind: Service +metadata: + name: elasticsearch + namespace: kube-ruoyi +spec: + ports: + - port: 9220 # 和auth-server的端口冲突了,对外暴露换一个端口访问 + targetPort: 9200 + name: cluster-node + selector: + app: elasticsearch # 该 Service 会将所有具有标签 app: mysql-labels-app暴露到一个抽象的 Service 端口上(targetPort:容器接收流量的端口;port:可任意取值的抽象的 Service 端口,其他 Pod 通过该端口访问 Service + type: NodePort \ No newline at end of file diff --git a/deployment/skywalking/skywalking-deployment.yaml b/deployment/skywalking/skywalking-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..04d84aa5ac4132647414d3d5c77104505d050e54 --- /dev/null +++ b/deployment/skywalking/skywalking-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + name: skywalking + name: skywalking + namespace: kube-ruoyi +spec: + replicas: 1 + selector: + matchLabels: + app: skywalking + template: + metadata: + labels: + app: skywalking + spec: + containers: + - name: skywalking + image: apache/skywalking-oap-server + imagePullPolicy: Always + ports: + - containerPort: 11800 + name: collector + - containerPort: 12800 + name: oap + env: + - name: SW_STORAGE + value: elasticsearch + - name: TZ + value: Asia/Shanghai + - name: SW_STORAGE_ES_CLUSTER_NODES + value: elasticsearch:9220 +--- +apiVersion: v1 +kind: Service +metadata: + name: skywalking + namespace: kube-ruoyi +spec: + ports: + - port: 11800 + targetPort: 11800 + name: collector + - port: 12800 + targetPort: 12800 + name: oap + selector: + app: skywalking # 该 Service 会将所有具有标签 app: mysql-labels-app暴露到一个抽象的 Service 端口上(targetPort:容器接收流量的端口;port:可任意取值的抽象的 Service 端口,其他 Pod 通过该端口访问 Service + type: NodePort \ No newline at end of file diff --git a/deployment/skywalking/skywalking-ui-deployment.yaml b/deployment/skywalking/skywalking-ui-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f4b4e9861986becdf2fe86bf6977fe0c38e26013 --- /dev/null +++ b/deployment/skywalking/skywalking-ui-deployment.yaml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + name: skywalking-ui + name: skywalking-ui + namespace: kube-ruoyi +spec: + replicas: 1 + selector: + matchLabels: + app: skywalking-ui + template: + metadata: + labels: + app: skywalking-ui + spec: + containers: + - name: skywalking-ui + image: apache/skywalking-ui + imagePullPolicy: Always + ports: + - containerPort: 8080 + name: console + env: + - name: SW_OAP_ADDRESS + value: http://skywalking:12800 + - name: TZ + value: Asia/Shanghai +--- +apiVersion: v1 +kind: Service +metadata: + name: skywalking-ui + namespace: kube-ruoyi +spec: + ports: + - port: 8080 + nodePort: 30088 + selector: + app: skywalking-ui # 该 Service 会将所有具有标签 app: mysql-labels-app暴露到一个抽象的 Service 端口上(targetPort:容器接收流量的端口;port:可任意取值的抽象的 Service 端口,其他 Pod 通过该端口访问 Service + type: NodePort \ No newline at end of file diff --git a/ruoyi-auth/src/main/resources/bootstrap-k8s.yml b/ruoyi-auth/src/main/resources/bootstrap-k8s.yml new file mode 100644 index 0000000000000000000000000000000000000000..41cce32c0e98d7665271a69091b2c3d0fb135e92 --- /dev/null +++ b/ruoyi-auth/src/main/resources/bootstrap-k8s.yml @@ -0,0 +1,22 @@ +# Tomcat +server: + port: 9200 + +# Spring +spring: + application: + # 应用名称 + name: ${SERVER_NAME} + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + config: + # 配置中心地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - ${NACOS_SHARED_CONFIGS} diff --git a/ruoyi-auth/src/main/resources/bootstrap.yml b/ruoyi-auth/src/main/resources/bootstrap.yml index f456b03c078c102ad0bebd39cef6d639436e50eb..0effec805daeed2e5d7eccad5144865ee45513da 100644 --- a/ruoyi-auth/src/main/resources/bootstrap.yml +++ b/ruoyi-auth/src/main/resources/bootstrap.yml @@ -9,7 +9,7 @@ spring: name: ruoyi-auth profiles: # 环境配置 - active: dev + active: ${SPRING_PROFILES_ACTIVE:dev} cloud: nacos: discovery: diff --git a/ruoyi-gateway/src/main/resources/bootstrap-k8s.yml b/ruoyi-gateway/src/main/resources/bootstrap-k8s.yml new file mode 100644 index 0000000000000000000000000000000000000000..4151679459891cd0d533b011036c46fc38f43f95 --- /dev/null +++ b/ruoyi-gateway/src/main/resources/bootstrap-k8s.yml @@ -0,0 +1,37 @@ +# Tomcat +server: + port: 8080 + +# Spring +spring: + application: + # 应用名称 + name: ${SERVER_NAME} + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + config: + # 配置中心地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - ${NACOS_SHARED_CONFIGS} + sentinel: + # 取消控制台懒加载 + eager: true + transport: + # 控制台地址 + dashboard: 127.0.0.1:8718 + # nacos配置持久化 + datasource: + ds1: + nacos: + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + dataId: sentinel-ruoyi-gateway + groupId: DEFAULT_GROUP + data-type: json + rule-type: gw-flow diff --git a/ruoyi-gateway/src/main/resources/bootstrap.yml b/ruoyi-gateway/src/main/resources/bootstrap.yml index b6dc98ae6d5541e2a17e36112c63ee95ed653db1..10a83d80049b0082201cebbcb47f09257f01059a 100644 --- a/ruoyi-gateway/src/main/resources/bootstrap.yml +++ b/ruoyi-gateway/src/main/resources/bootstrap.yml @@ -9,7 +9,7 @@ spring: name: ruoyi-gateway profiles: # 环境配置 - active: dev + active: ${SPRING_PROFILES_ACTIVE:dev} cloud: nacos: discovery: diff --git a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap-k8s.yml b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap-k8s.yml new file mode 100644 index 0000000000000000000000000000000000000000..d73935d03a14641b86957c5b1eff37086a376ccd --- /dev/null +++ b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap-k8s.yml @@ -0,0 +1,23 @@ +# Tomcat +server: + port: 9300 + +# Spring +spring: + application: + # 应用名称 + name: ${SERVER_NAME} + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + config: + # 配置中心地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - ${NACOS_SHARED_CONFIGS} + diff --git a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml index 55ff4112540131e250eaa81d01d244470c631c17..a7912b7fe89ecd88e4b3c113a61f8666fd61be64 100644 --- a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml @@ -9,7 +9,7 @@ spring: name: ruoyi-file profiles: # 环境配置 - active: dev + active: ${SPRING_PROFILES_ACTIVE:dev} cloud: nacos: discovery: diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap-k8s.yml b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap-k8s.yml new file mode 100644 index 0000000000000000000000000000000000000000..9681970717d5c9382294f386b1b08222951672a8 --- /dev/null +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap-k8s.yml @@ -0,0 +1,23 @@ +# Tomcat +server: + port: 9202 + +# Spring +spring: + application: + # 应用名称 + name: ${SERVER_NAME} + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + config: + # 配置中心地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - ${NACOS_SHARED_CONFIGS} + diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml index 0ef5a457597c3b6528e93a78854d51c4e5681941..3561ca3fa01feaec4d95ebeac646a5b7859002ab 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml @@ -9,7 +9,7 @@ spring: name: ruoyi-gen profiles: # 环境配置 - active: dev + active: ${SPRING_PROFILES_ACTIVE:dev} cloud: nacos: discovery: diff --git a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap-k8s.yml b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap-k8s.yml new file mode 100644 index 0000000000000000000000000000000000000000..8edce7015498167105ecf436ebb07452e620846e --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap-k8s.yml @@ -0,0 +1,22 @@ +# Tomcat +server: + port: 9203 + +# Spring +spring: + application: + # 应用名称 + name: ${SERVER_NAME} + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + config: + # 配置中心地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - ${NACOS_SHARED_CONFIGS} diff --git a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml index b86f8c9e1c2ebccb833c5ed196926711f4b40ac2..0dd2bdda5635c69d0fb0e947f74a6edd640556ba 100644 --- a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml @@ -9,7 +9,7 @@ spring: name: ruoyi-job profiles: # 环境配置 - active: dev + active: ${SPRING_PROFILES_ACTIVE:dev} cloud: nacos: discovery: diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap-k8s.yml b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap-k8s.yml new file mode 100644 index 0000000000000000000000000000000000000000..68a8268d8ccba8ba789e71616bfeecdb5d94ad01 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap-k8s.yml @@ -0,0 +1,22 @@ +# Tomcat +server: + port: 9201 + +# Spring +spring: + application: + # 应用名称 + name: ${SERVER_NAME} + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + config: + # 配置中心地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - ${NACOS_SHARED_CONFIGS} diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml index 40ab78165fc1caa51e54d1b088c03872626ed153..eb592e4326786490f17b2f6db31bae056141021d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml @@ -9,7 +9,7 @@ spring: name: ruoyi-system profiles: # 环境配置 - active: dev + active: ${SPRING_PROFILES_ACTIVE:dev} cloud: nacos: discovery: diff --git a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap-k8s.yml b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap-k8s.yml new file mode 100644 index 0000000000000000000000000000000000000000..3edb9cea6b9ff8d7cfb9dd269049757bdeefe7ba --- /dev/null +++ b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap-k8s.yml @@ -0,0 +1,22 @@ +# Tomcat +server: + port: 9100 + +# Spring +spring: + application: + # 应用名称 + name: ${SERVER_NAME} + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + config: + # 配置中心地址 + server-addr: ${NACOS_SERVER}:${NACOS_PORT} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - ${NACOS_SHARED_CONFIGS} diff --git a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml index 13d90cd72b70832ec4878fbb2ec988dff47ae26b..f8080951d3977c026c7c58484648f2a8a7a73609 100644 --- a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml +++ b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml @@ -9,7 +9,7 @@ spring: name: ruoyi-monitor profiles: # 环境配置 - active: dev + active: ${SPRING_PROFILES_ACTIVE:dev} cloud: nacos: discovery: